diff --git a/admin.py b/admin.py new file mode 100644 index 0000000..edd558e --- /dev/null +++ b/admin.py @@ -0,0 +1,13 @@ +from flask import Flask, request, session, g, redirect, url_for, \ + abort, render_template, flash, Blueprint +from flask.ext.mysqldb import MySQL + +admin = Blueprint('admin', __name__, + template_folder='templates') + +@admin.route('/') +def home(): + if not session.get('logged_in'): + return redirect(url_for('login')) + else: + return render_template('admin/home.html') \ No newline at end of file diff --git a/admin/templates/home.html b/admin/templates/home.html new file mode 100644 index 0000000..eb7dee8 --- /dev/null +++ b/admin/templates/home.html @@ -0,0 +1,6 @@ +{% extends 'master.html' %} +{% block body %} +

+ congrats, it worked +

+{% endblock %} diff --git a/flask_site.py b/flask_site.py index 0fa5a8c..5df5343 100644 --- a/flask_site.py +++ b/flask_site.py @@ -1,13 +1,18 @@ -import sqlite3 from flask import Flask, request, session, g, redirect, url_for, \ abort, render_template, flash +from flask.ext.mysqldb import MySQL +from admin import admin app = Flask(__name__) app.config.from_pyfile('config.py') +app.secret_key = app.config['SECRET_KEY'] +mysql = MySQL(app) + +app.register_blueprint(admin, url_prefix='/admin') def connect_db(): - return sqlite3.connect(app.config['DATABASE']) - + return mysql.connection.cursor() + @app.before_request def before_request(): g.db = connect_db() @@ -20,8 +25,8 @@ def teardown_request(exception): @app.route('/') def home(): - cur = g.db.execute('select title, text from entries order by id desc') - entries = [dict(title=row[0], text=row[1]) for row in cur.fetchall()] + g.db.execute('SELECT * FROM blog_posts ORDER BY updated_on DESC') + entries = [dict(title=row[1], text=row[2], created=row[3].strftime("%B %d, %Y"), updated=row[4].strftime("%B %d, %Y")) for row in g.db.fetchall()] return render_template('home.html', entries=entries) @app.route('/bio') @@ -30,8 +35,8 @@ def bio(): @app.route('/blog') def blog(): - cur = g.db.execute('select title, text from entries order by id desc') - entries = [dict(title=row[0], text=row[1]) for row in cur.fetchall()] + g.db.execute('SELECT * FROM blog_posts ORDER BY id DESC') + entries = [dict(title=row[1], text=row[2], created=row[3].strftime("%B %d, %Y"), updated=row[4].strftime("%B %d, %Y")) for row in g.db.fetchall()] return render_template('blog.html', entries=entries) @app.route('/projects') @@ -46,11 +51,11 @@ def contact(): def add_entry(): if not session.get('logged_in'): abort(401) - g.db.execute('insert into entries (title, text) values (?, ?)', + g.db.execute('insert into blog_posts (title, text) values (?, ?)', [request.form['title'], request.form['text']]) g.db.commit() flash('New entry was successfully posted') - return redirect(url_for('show_entries')) + return redirect(url_for('blog')) @app.route('/login', methods=['GET', 'POST']) def login(): @@ -63,14 +68,14 @@ def login(): else: session['logged_in'] = True flash('You were logged in') - return redirect(url_for('show_entries')) + return redirect(url_for('admin.home')) return render_template('login.html', error=error) @app.route('/logout') def logout(): session.pop('logged_in', None) flash('You were logged out') - return redirect(url_for('show_entries')) + return redirect(url_for('blog')) if __name__ == '__main__': app.run() diff --git a/install.py b/install.py index f6f73de..73db2ed 100644 --- a/install.py +++ b/install.py @@ -1,11 +1,10 @@ from flask_site import * -from contextlib import closing def init_db(): - with closing(connect_db()) as db: - with app.open_resource('schema.sql', mode='r') as f: - db.cursor().executescript(f.read()) - db.commit() + with app.app_context(): + with open('/home/billy/flask-site/schema.sql', 'r') as f: + g.db = connect_db() + g.db.execute(f.read()) if __name__ == "__main__": init_db() diff --git a/schema.sql b/schema.sql index 6ace639..7c917c4 100644 --- a/schema.sql +++ b/schema.sql @@ -1,7 +1,7 @@ -drop table if exists entries; -create table entries ( - id integer primary key autoincrement, - title text not null, - text text not null - -); +CREATE TABLE blog_posts ( + id INT( 6 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , + title VARCHAR( 500 ) DEFAULT NULL , + text VARCHAR( 10000 ) DEFAULT NULL , + created_on DATETIME NOT NULL , + updated_on TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP +); \ No newline at end of file diff --git a/static/css/style.css b/static/css/style.css index d2eb966..21a5486 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -3,6 +3,7 @@ body { margin:0; padding:0; background-color:#fff; + overflow-x: hidden; } h1, h2, h3, h4, h5, h6 { @@ -21,12 +22,34 @@ pre { margin: auto; } +th {text-align: left;} + td { padding: 5px 20px; } td ul { display: inline-block; + margin: 5px; +} + +input { + background-color: #FFF; + color: #002900; + border: 1px solid #002900; + border-radius: 15px; + padding: 5px; + display: block; + margin: 5px auto; + width: 95%; + max-width: 450px; + text-align: center; +} +input[type='submit'] { + color: #FFFFFF; + background-color: #002900; + max-width: 464px; + cursor: pointer; } #nav { @@ -145,11 +168,43 @@ td ul { border-bottom: 1px solid #002900; } +#changing-text { + position: absolute; + top: 50%; + -webkit-transform: translateY(-50%); + transform: translateY(-50%); + left: 0; + right: 0; +} + .section { border-radius: 40px; padding:1px 15px 15px 15px; } +.blog-entry { + margin: 5px 20px 15px; + padding: 0 20px; +} + +.blog-entry:last-of-type { + margin-bottom: 5px; +} + +.blog-entry h3, .blog-entry h5, .blog-entry p { + margin: 5px 0; +} + +.blog-entry h5 { + font-style: italic; +} + +.one-half { + width: 45%; + margin: 0 2.5%; + float: left; +} + .one-third { width: 30%; margin: 5px 1.5%; @@ -175,6 +230,13 @@ a.insta-link { display: inline-block; float: left; position: relative; + padding: 10px; + width: 155px; + margin: auto; +} + +a.insta-link img { + border-radius: 50%; } a.insta-link span { @@ -218,9 +280,6 @@ span.insta-caption { div#instafeed { overflow: hidden; - width: 95%; - max-width: 1100px; - margin: 60px auto; } #home img { @@ -276,6 +335,10 @@ div#instafeed { margin: 5px auto; } +#projects a:hover { + color: #fff; +} + .project { width:75%%; margin: 0 auto 10px; @@ -298,22 +361,47 @@ div#instafeed { border: 1px solid white; } +.project-description { + margin: 5px 5px 50px; + overflow: hidden; + float: left; +} + +.project-description:last-of-type { + margin: 5px; +} + +.project-description h3 { + margin-top: 0; +} + +.project-description .project-logo { + border: 1px solid black; +} + .ff-store-link { height: auto; width: 40%; margin: auto; + max-width: 172px; } .chrome-webstore-link { height: auto; width: 51%; margin: auto; + max-width: 206px; } .project h4 { text-align:center; } +.logo-link { + float: left; + margin-right: 20px; +} + footer { display: block; width: 100%; @@ -365,35 +453,31 @@ a.social-link:hover, a.social-link:active { color: #fff; } -@media all and (max-width: 1192px) { - div#instafeed { - max-width: 510px; - } -} - @media screen and (max-width:1024px) { .main-nav, #nav { position: absolute; } #menu { - display:none; + display:block; width:100vw; position: absolute; top: 60px; - left: 0; + left: 100%; padding:0; background-color:#002900; float:none; + -webkit-transition: left 0.5s ease; + transition: left 0.5s ease; } #menu-icon { position:absolute; right:30px; display:inline; - height:20px; width:auto; - margin:10px; + margin: 2px 10px; + font-size: 24px; } .main-nav li { @@ -435,9 +519,15 @@ a.social-link:hover, a.social-link:active { } @media all and (max-width: 768px) { - div#instafeed { - max-width: 340px; - } + .one-half { + width: 95%; + text-align: center; + } + th, td { + float: left; + clear: left; + margin-left: 20px; + } } @media all and (max-width: 870px) { @@ -458,16 +548,4 @@ a.social-link:hover, a.social-link:active { width: 90%; margin: 5px 5% 40px; } -} - -@media all and (max-width: 596px) { - div#instafeed { - max-width: 340px; - } -} - -@media all and (max-width: 414px) { - div#instafeed { - max-width: 170px; - } -} +} \ No newline at end of file diff --git a/static/img/favicon.png b/static/img/favicon.png new file mode 100644 index 0000000..de9c179 Binary files /dev/null and b/static/img/favicon.png differ diff --git a/templates/admin/home.html b/templates/admin/home.html new file mode 100644 index 0000000..753cecd --- /dev/null +++ b/templates/admin/home.html @@ -0,0 +1,6 @@ +{% extends 'master.html' %} +{% block body %} +

+ congrats, it worked +

+{% endblock %} diff --git a/templates/bio.html b/templates/bio.html index 2e0afa7..78b69a3 100644 --- a/templates/bio.html +++ b/templates/bio.html @@ -2,6 +2,7 @@ {% block body %}

about me

-

extended bio coming soon...

+

I have work experience using HTML, CSS, JavaScript, jQuery, AngularJS, NodeJS, PHP, Laravel, WordPress, Magento. Shopify, Ruby on Rails, Python, Linux, Ubuntu Server 14.04, and I have the Certified System Administrator certification from the Linux Foundation. As far as software goes, I'm proficient in git, GIMP, and vim. All of my learning so far has been from self-study, so I am very independent and self-motivated; little to no direction isn’t a problem for me. I’m also a very quick learner and I’m detail-oriented. I tend to stay up late at night working and wake up early the next day to continue working when I have a big project. I love Open Source software, and I use Arch Linux as my primary operating system. I have made a few minor contributions to open source software, as seen on my GitHub profile.

+

When I was 16 years old I decided to go on a foreign exchange trip, and I wanted to go to Europe. I wasn’t too particular about where exactly though and I ended up going to Finland. Finnish is a very difficult language to learn and the people there are more reserved than most Americans. Add to that mix a nearly 6 month winter with temperatures as low as -24 F (-31 C) and you can see how this was quite a life-changing experience. I left Finland fluent in Spanish and conversational in Finnish. The Finns were rather shy, at least with me, so I spent most of my time with Latin American exchange students and actually met my current fiancée there. When I returned to the US, I finished my last year of high school and then moved to Mexico, precisely for my fiancée, who was only my girlfriend at the time. When I got to Mexico, I had a couple thousand dollars saved up, I had no visas or permissions to work, but I at least spoke Spanish. Within 2 weeks of being there I was able to find work teaching English, and I later found a better teaching position and got my visa situation taken care of. Prior to teaching I had only gained experience in sales and retail, so teaching was a completely new experience for me. It wasn’t my favorite thing to do, however, so I decided that I needed to get some more education in order to get into a field that I actually would enjoy. I began to teach myself HTML/CSS, JavaScript, and Python in my free time since I’ve always been a tech junkie. At 20 years old, I began my first job in web development, only 4 months after I began studying programming. In the 6 months that I've been there, I've learned PHP, Laravel, WordPress, some Magento, some Ruby on Rails, and Shopify development. I am also conversational in German, since German is a pretty popular language around the tech world from what I’ve seen. I’m currently 21 years old, I speak English, Spanish, Finnish, and German, and can code in HTML, CSS, JavaScript, PHP, Ruby and Python, am a certified Linux System Administrator, and I’d like to think that I’ve overcome more difficulties and had more life experiences than most people twice my age have.

{% endblock %} diff --git a/templates/blog.html b/templates/blog.html index 87bc4fe..8427aa2 100644 --- a/templates/blog.html +++ b/templates/blog.html @@ -11,12 +11,16 @@ {% endif %} -
+
+

blog

{% for entry in entries %} -

{{ entry.title }}

- {{ entry.text|safe }} +
+

{{ entry.title }}

+
{{ entry.updated }}
+

{{ entry.text|safe }}

+
{% else %} - Sorry, I still haven't gotten around to moving my blog posts over! + Sorry, I still haven't gotten around to moving my blog posts over! {% endfor %}
{% endblock %} diff --git a/templates/contact.html b/templates/contact.html index 77c2e49..80ad7a0 100644 --- a/templates/contact.html +++ b/templates/contact.html @@ -1,57 +1,27 @@ {% extends 'master.html' %} {% block body %} -

- web developer. -

- -
-

from my blog

-
-
-

projects

- - -