Really get all pages and some cleanup
This commit is contained in:
parent
6c27c1d3f4
commit
ae0c4ee4ab
@ -5,7 +5,6 @@ from flask import Flask, render_template, request
|
||||
from flask_flatpages import FlatPages
|
||||
import arrow
|
||||
|
||||
|
||||
DEBUG = True
|
||||
FLATPAGES_AUTO_RELOAD = DEBUG
|
||||
FLATPAGES_EXTENSION = '.md'
|
||||
@ -42,14 +41,15 @@ blogposts = sorted(blogposts, key=lambda p: p.meta['date'], reverse=True)
|
||||
|
||||
|
||||
|
||||
|
||||
# Permalinks
|
||||
@app.route("/")
|
||||
@app.route("/<path:path>")
|
||||
def permalink(path=''):
|
||||
def page(path=''):
|
||||
page = permalinks['/'+path]
|
||||
template = 'blog_post.html' if page in blogposts else 'page.html'
|
||||
return render_template(template, page=page)
|
||||
|
||||
# Blog listings
|
||||
@app.route("/blog/")
|
||||
@app.route("/blog/<string:tag>/")
|
||||
def blog_listing(tag=None):
|
||||
@ -65,14 +65,26 @@ if __name__ == "__main__":
|
||||
from glob import iglob
|
||||
from shutil import move, rmtree
|
||||
freezer = Freezer(app)
|
||||
|
||||
# Make sure we get all pages
|
||||
@freezer.register_generator
|
||||
def page():
|
||||
yield from permalinks
|
||||
|
||||
# Freeze site
|
||||
freezer.freeze()
|
||||
|
||||
# Move static files
|
||||
for f in iglob('build/static/*'):
|
||||
move(f, 'build/'+f[len('build/static/'):])
|
||||
rmtree('build/static/')
|
||||
|
||||
else:
|
||||
# Serve static files too
|
||||
@app.route("/media/<path:path>")
|
||||
@app.route("/src/<path:path>")
|
||||
@app.route("/favicon.ico")
|
||||
def static_file(path):
|
||||
return app.send_static_file(request.path[1:])
|
||||
|
||||
app.run()
|
||||
|
0
static/robots.txt
Normal file
0
static/robots.txt
Normal file
@ -34,7 +34,7 @@
|
||||
|
||||
<div id="bottom">
|
||||
© 2012
|
||||
<a href="mailto:thomasloven@gmail.com">Thomas Lovén</a>
|
||||
<a href="mailto:thomas@thomasloven.com">Thomas Lovén</a>
|
||||
-
|
||||
<a href="http://twitter.com/thomasloven">@thomasloven</a>
|
||||
-
|
||||
|
@ -19,8 +19,7 @@
|
||||
<ol class="content-list">
|
||||
{% for post in posts %}
|
||||
<li class="content">
|
||||
<h3 class="postTitle"><a href="{{ url_for("permalink",
|
||||
path=post.url) }}">{{ post.title }}</a></h3><p class="postDate">{{ post.datestr }}</p><p class="postSubTitle">{{ post.subtitle }}<br>
|
||||
<h3 class="postTitle"><a href="{{ post.url }}">{{ post.title }}</a></h3><p class="postDate">{{ post.datestr }}</p><p class="postSubTitle">{{ post.subtitle }}<br>
|
||||
<a href="{{ post.url }}#disqus_thread" data-disqus-identifier="{{ post.url[:-1] }}"></a></p>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user