Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add syndication links and nice date formatting

  • Loading branch information...
commit c45d36986d292213bc10269412c1afe8ee94b589 1 parent e6fcc44
@dbrenneman authored
View
12 dontpanic.py
@@ -78,7 +78,9 @@ def show_homepage():
@app.route('/blog')
def show_articles():
cur = g.db.execute('select title, slug, published from articles order by published')
- articles = [dict(title=row[0], slug=row[1], published=row[2]) for row in cur.fetchall()]
+ articles = [dict(title=row[0],
+ slug=row[1],
+ published=row[2].strftime('%d %B, %Y')) for row in cur.fetchall()]
return render_template('blog.html', articles=articles, page_title='Blog | ', year=YEAR)
@@ -127,10 +129,12 @@ def add_article():
@app.route('/blog/<slug>')
def show_article(slug):
- query = "select title, body, slug, published from articles where slug='%s' order by published desc" % slug
- cur = g.db.execute(query)
+ cur = g.db.execute("select title, body, slug, published from articles where slug=? order by published desc", [slug])
article = None
- articles = [dict(title=row[0], body=row[1], slug=row[2], published=row[3]) for row in cur.fetchall()]
+ articles = [dict(title=row[0],
+ body=row[1],
+ slug=row[2],
+ published=row[3].strftime('%d %B, %Y')) for row in cur.fetchall()]
if articles:
article = articles[0]
article['body'] = markdown.markdown(article['body'], output_format="html5")
View
7 templates/base.html
@@ -12,6 +12,10 @@
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}" type="text/css" media="screen"/>
<link rel="stylesheet" href="{{ url_for('static', filename='css/font-awesome.css') }}" type="text/css" media="screen"/>
<link rel="stylesheet" href="{{ url_for('static', filename='css/dontpanic.css') }}" type="text/css" media="screen"/>
+ <link href="{{ url_for('recent_feed') }}"
+ rel="alternate"
+ title="Recent Articles"
+ type="application/atom+xml">
</head>
<body>
<div class="container-narrow content">
@@ -50,6 +54,9 @@
<a href="https://github.com/dbrenneman" target="_blank"><i class="icon-github"></i></a>
</li>
<li>
+ <a href="{{ url_for('recent_feed') }}" target="_blank"><i class="icon-rss"></i></a>
+ </li>
+ <li>
<a href="/">&copy; David Brenneman {{ year }}</a>
</li>
</ul>
View
4 templates/blog.html
@@ -3,10 +3,10 @@
{% block blog_highlight %}active{% endblock %}
{% block content %}
- <ul class=articles>
+ <ul class="unstyled">
{% for article in articles %}
<li>
- <h3><a href="{{ url_for('show_article', slug=article.slug) }}">{{ article.title }}</a></h3><p>{{ article.published }}</p>
+ <h3><a href="{{ url_for('show_article', slug=article.slug) }}">{{ article.title }}</a> <small><em>{{ article.published }}</em></small></h3>
</li>
{% else %}
<li><em>Unbelievable. No articles here so far!</em></li>
View
2  templates/blog_page.html
@@ -3,6 +3,6 @@
{% block blog_highlight %}active{% endblock %}
{% block content %}
-<h3>{{ article.title }}</h3>
+<h3>{{ article.title }}</h3><h3><small>{{ article.published }}</small></h3>
{{ article.body|safe }}
{% endblock %}
Please sign in to comment.
Something went wrong with that request. Please try again.