diff --git a/flaskr/auth.py b/flaskr/auth.py index e41998c..5874e97 100644 --- a/flaskr/auth.py +++ b/flaskr/auth.py @@ -11,6 +11,7 @@ bp = Blueprint('auth', __name__, url_prefix='/auth') @bp.route('/register', methods=('GET', 'POST')) def register(): + return "Admin only", 403 if request.method == 'POST': username = request.form['username'] password = request.form['password'] diff --git a/flaskr/blog.py b/flaskr/blog.py index cfa78d8..523cfaf 100644 --- a/flaskr/blog.py +++ b/flaskr/blog.py @@ -7,6 +7,7 @@ from flaskr.auth import login_required from flaskr.db import get_db import markdown +import datetime bp = Blueprint('blog', __name__) @@ -20,6 +21,8 @@ def index(): ).fetchall() posts = [] for post in db_posts: + if post['created'] > datetime.datetime.utcnow(): + continue post = dict(post) post['body'] = markdown.markdown(post['body']) posts.append(post) @@ -74,19 +77,23 @@ def update(id): if request.method == 'POST': title = request.form['title'] body = request.form['body'] + created = request.form['created'] error = None if not title: error = 'Title is required.' + if not created: + error = "Created is required." + if error is not None: flash(error) else: db = get_db() db.execute( - 'UPDATE post SET title = ?, body = ?' + 'UPDATE post SET title = ?, body = ?, created = ?' ' WHERE id = ?', - (title, body, id) + (title, body, created, id) ) db.commit() return redirect(url_for('blog.index')) diff --git a/flaskr/static/favicon.png b/flaskr/static/favicon.png index 910818c..b8cb77d 100644 Binary files a/flaskr/static/favicon.png and b/flaskr/static/favicon.png differ diff --git a/flaskr/static/style.css b/flaskr/static/style.css index a45a73b..63f3f5b 100644 --- a/flaskr/static/style.css +++ b/flaskr/static/style.css @@ -1,6 +1,11 @@ html { font-family: sans-serif; background: #eee; padding: 1rem; } body { max-width: 960px; margin: 0 auto; background: white; } h1 { font-family: serif; color: #377ba8; margin: 1rem 0; } +h2 { color: #377ba8; margin: 1rem 0; } +h3 { color: #377ba8; margin: 1rem 0; } +h4 { color: #377ba8; margin: 1rem 0; } +h5 { color: #377ba8; margin: 1rem 0; } +h6 { color: #377ba8; margin: 1rem 0; } a { color: #377ba8; } hr { border: none; border-top: 1px solid lightgray; } nav { background: lightgray; display: flex; align-items: center; padding: 0 0.5rem; } @@ -14,7 +19,12 @@ nav ul li a, nav ul li span, header .action { display: block; padding: 0.5rem; } .flash { margin: 1em 0; padding: 1em; background: #cae6f6; border: 1px solid #377ba8; } .post > header { display: flex; align-items: flex-end; font-size: 0.85em; } .post > header > div:first-of-type { flex: auto; } -.post > header h1 { font-size: 1.5em; margin-bottom: 0; } +.post > header h1 { margin-bottom: 0; } +.post > h2 { margin-bottom: 0; } +.post > h3 { margin-bottom: 0; } +.post > h4 { margin-bottom: 0; } +.post > h5 { margin-bottom: 0; } +.post > h6 { margin-bottom: 0; } .post .about { color: slategray; font-style: italic; } .post .body { white-space: pre-line; } .content:last-child { margin-bottom: 0; } diff --git a/flaskr/templates/base.html b/flaskr/templates/base.html index a2c26cd..6c1d788 100644 --- a/flaskr/templates/base.html +++ b/flaskr/templates/base.html @@ -1,9 +1,9 @@ -