From 4fa00c1105f9357de7781c81858dffeaa1126cf4 Mon Sep 17 00:00:00 2001 From: Tom Dooner Date: Sun, 27 May 2012 17:16:25 -0700 Subject: [PATCH] Add some template changes. --- generate_database.py | 8 ++++---- server.py | 8 +++++--- static/style.css | 43 ++++++++++++++++++++++++++++++++++++++++++ templates/base.html | 28 +++++++++++++++++++++++++++ templates/stories.html | 37 +++++++++++++----------------------- 5 files changed, 93 insertions(+), 31 deletions(-) create mode 100644 static/style.css create mode 100644 templates/base.html diff --git a/generate_database.py b/generate_database.py index 51903f9..4c1ae1f 100755 --- a/generate_database.py +++ b/generate_database.py @@ -17,10 +17,10 @@ db.session.commit() -s1 = Story(t.id, 'This is story 1') -s2 = Story(t.id, 'Story 2 is much cooler!') -s3 = Story(j.id, 'This, story 3, is superior.') -s4 = Story(j.id, 'Story 4 is the best! I think.') +s1 = Story(t.id, 'This is story 1', 'http://google.com') +s2 = Story(t.id, 'Story 2 is much cooler!', 'http://tomdooner.com') +s3 = Story(j.id, 'This, story 3, is superior.', 'http://causes.com') +s4 = Story(j.id, 'Story 4 is the best! I think.', 'http://johngunderman.com') db.session.add(s1) db.session.add(s2) diff --git a/server.py b/server.py index a3e2944..dd01c95 100644 --- a/server.py +++ b/server.py @@ -21,11 +21,13 @@ def __repr__(self): class Story(db.Model): id = db.Column(db.Integer, primary_key=True) + title = db.Column(db.String(255)) poster_id = db.Column(db.Integer, db.ForeignKey('user.id')) href = db.Column(db.String(255)) - def __init__(self, poster_id, href): + def __init__(self, poster_id, title, href): self.poster_id = poster_id + self.title = title self.href = href def __repr__(self): @@ -34,11 +36,11 @@ def __repr__(self): @app.route('/') @app.route('/top') def top_stories(): - return render_template('stories.html', page_name="Top Stories") + return render_template('stories.html', page_name="Top Stories", stories=Story.query.all()) @app.route('/new') def new_stories(): - return render_template('stories.html', page_name="New Stories") + return render_template('stories.html', page_name="New Stories", stories=Story.query.all()) def hello_world(): if 'user' in session: diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..a6e55bc --- /dev/null +++ b/static/style.css @@ -0,0 +1,43 @@ +* { padding:0;margin:0; } +body,html { + background-color:#063940; + font-family: 'Pontano Sans', sans-serif; +} +body > * { + width: 960px; + margin:auto; + padding:30px; +} +body header { + background-color:#8EBDB6; + height:50px; + padding:30px; +} +body header ul { + float:right; + list-style: none; +} +body header ul li { + float:left; + padding-right:20px; + font-size:2em; +} +body header a { + color: #3E838C; + font-variant: small-caps; +} +h1.site_title { + font-family: 'Ruge Boogie', cursive; + font-weight: 400; + font-size: 4em; + float:left; +} +div.content { + background-color: #ECE1C3; +} +div.content a:link { + color: #195E63; +} +div.content a:visited { + color: #8EBDB6; +} diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..56b2e46 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,28 @@ + + + {{page_name}} + {% block css %} + + + {% endblock %} + + +{%block header %} +
+

To Be Named

+ +
+{% endblock header %} +
+{% block body %} + +{% endblock %} +
+ diff --git a/templates/stories.html b/templates/stories.html index bed64a6..71d1ba1 100644 --- a/templates/stories.html +++ b/templates/stories.html @@ -1,24 +1,13 @@ - -{{page_name}} -
- -
- - - +{% extends "base.html" %} +{% block body %} + +{% endblock %}