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