Skip to content

Commit

Permalink
KISS
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Mar 6, 2014
1 parent be77b45 commit 9b4a48d
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 55 deletions.
23 changes: 13 additions & 10 deletions exyr/__init__.py
@@ -1,7 +1,6 @@
import os
import io
import re
import math
import datetime
import itertools

Expand Down Expand Up @@ -95,25 +94,29 @@ def updated(self):
return self.meta.get('modified', self['published'])


def by_date(articles):
return sorted(articles, reverse=True, key=lambda p: p['published'])


@app.route('/')
def home():
return render_template(
'all_posts.html', posts=by_date(Page.all_articles()))
'all_posts.html',
posts_by_year=itertools.groupby(
sorted(
Page.all_articles(),
reverse=True,
key=lambda p: p['published']),
key=lambda p: p['published'].year))


@app.route('/about/')
def about():
return render_template('flatpage.html', page=Page.load('', 'about'))


@app.route('/<int:year>/')
def archives(year):
articles = by_date(Page.articles_by_year(str(year)))
return render_template('archives.html', **locals())
@app.route('/.htaccess')
def htaccess():
return '''
RedirectMatch /tags(/.*)? /
RedirectMatch /(\d+)/? /#$1
''', 200, {'Content-Type': 'application/octet-stream'}


@app.route('/<int:year>/<name>/')
Expand Down
6 changes: 0 additions & 6 deletions exyr/freezer.py
Expand Up @@ -12,12 +12,6 @@
freezer = Freezer(app)


@freezer.register_generator
def archives():
for year in Page.years():
yield {'year': int(year)}


@freezer.register_generator
def static_in_pages():
for year in Page.years():
Expand Down
18 changes: 15 additions & 3 deletions exyr/templates/all_posts.html
@@ -1,7 +1,19 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}

{% block content %}
<h2>All posts</h2>
{{ utils.article_list(posts) }}
<section class=article_list>
{% for year, posts in posts_by_year %}
<h2 id="{{ year }}">{{ year }}</h2>
{% for page in posts %}
<article>
<h3>
<a href="{{ page.url() }}">{{ page.title }}</a>
<time pubdate datetime="{{ page.published.isoformat() }}">{{
page.published.isoformat() }}</time>
</h3>
{{ page.summary|markdown|safe }}
</article>
{% endfor %}
{% endfor %}
</section>
{% endblock %}
9 changes: 0 additions & 9 deletions exyr/templates/archives.html

This file was deleted.

8 changes: 5 additions & 3 deletions exyr/templates/flatpage.html
@@ -1,5 +1,4 @@
{% extends "layout.html" %}
{% import 'utils.html' as utils %}

{% block title %}{{ page.title }}{% endblock %}

Expand All @@ -8,7 +7,11 @@
<article>
<header>
<h2>{{ page.title }}</h2>
<p>By Simon Sapin, on {{ utils.html5_date(page.published) }}</p>
<p>
Simon Sapin,
<time pubdate datetime="{{ page.published.isoformat() }}">{{
page.published.isoformat() }}</time>
</p>
</header>
{{ page.html|safe }}
</article>
Expand All @@ -22,5 +25,4 @@ <h2>{{ page.title }}</h2>
</section>
{% endif %}
{% endif %}
{{ utils.article_list(sub_pages|d) }}
{% endblock %}
1 change: 0 additions & 1 deletion exyr/templates/layout.html
Expand Up @@ -33,7 +33,6 @@
<h1><a href="/">{% block site_title %}Exyr.org{% endblock %}</a></h1>
<nav>
<ul>
<li><a href="{{ url_for('home') }}">Posts</a></li>
<li><a href="{{ url_for('about') }}">About</a></li>
<li><a href="{{ url_for('feed') }}">Subscribe <img alt=""
src="{{ url_for('static', filename='feed-icon.png') }}"></a></li>
Expand Down
11 changes: 9 additions & 2 deletions exyr/templates/style.css
Expand Up @@ -95,7 +95,7 @@ footer p {
padding: .5em 0 0;
}

header p, time {
header p {
font-style: italic;
}

Expand Down Expand Up @@ -141,7 +141,14 @@ hr:before {
}

.article_list h3 {
margin-bottom: 0;
margin: 2em 0 0;
font-size: 1.15em;
}

.article_list h3 time {
margin-left: .5em;
font-weight: normal;
font-size: 90%;
}

.article_list p {
Expand Down
21 changes: 0 additions & 21 deletions exyr/templates/utils.html

This file was deleted.

0 comments on commit 9b4a48d

Please sign in to comment.