Skip to content

Commit

Permalink
Add some template changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdooner committed May 28, 2012
1 parent 2b8a359 commit 4fa00c1
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 31 deletions.
8 changes: 4 additions & 4 deletions generate_database.py
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions server.py
Expand Up @@ -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):
Expand All @@ -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:
Expand Down
43 changes: 43 additions & 0 deletions 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;
}
28 changes: 28 additions & 0 deletions templates/base.html
@@ -0,0 +1,28 @@
<!doctype html>
<head>
<title>{{page_name}}</title>
{% block css %}
<link rel="stylesheet" href="static/style.css" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Pontano+Sans|Ruge+Boogie' rel='stylesheet' type='text/css'>
{% endblock %}
</head>
<body>
{%block header %}
<header>
<h1 class="site_title">To Be Named</h1>
<ul id="menu_bar">
<li class="menu_item">
<a href="/top" class="menu_link">top</a>
</li>
<li class="menu_item">
<a href="/new" class="menu_link">new</a>
</li>
</ul>
</header>
{% endblock header %}
<div class="content">
{% block body %}

{% endblock %}
</div>
</body>
37 changes: 13 additions & 24 deletions templates/stories.html
@@ -1,24 +1,13 @@
<!doctype html>
<title>{{page_name}}</title>
<header>
<ul id="menu_bar">
<li class="menu_item">
<a href="/top" class="menu_link">top</a>
</li>
<li class="menu_item">
<a href="/new" class="menu_link">new</a>
</li>
</ul>
</header>
<body>
<ul id="stories">
{% for story in stories %}
<li class="story_entry">
<a href="{{story.href}}" class="story_link">{{story.title}}</a> &nbsp - %nbsp
<a href="{{story.submitter.href}}" class="submitter_link">
{{story.submitter.name}}
</a>
</li>
{% endfor %}
</ul>
</body>
{% extends "base.html" %}
{% block body %}
<ul id="stories">
{% for story in stories %}
<li class="story_entry">
<a href="{{story.href}}" class="story_link">{{story.title}}</a> &nbsp; - &nbsp;
<a href="userid-{{story.user}}" class="submitter_link">
{{story.user.username}}
</a>
</li>
{% endfor %}
</ul>
{% endblock %}

0 comments on commit 4fa00c1

Please sign in to comment.