Quantcast
Viewing latest article 19
Browse Latest Browse All 31

blog.py

blog.py
@app.route('/blog/<int:year>/<int:month>/<int:day>')
def daypage(year, month, day):
y, m, d = str(year), str(month), str(day)
postlist = "content/posts"
results = {}
for post in os.listdir(postlist):
if fnmatch.fnmatch(file, '{0}-{1}-{2}:*.md'.format(y, m, d)):
year, month, day, slug = re.split("^([0-9]{4})-([0-9]{2})-([0-9]{2}):([a-z]*).md", post, flags=re.IGNORECASE)[1:5]
results[file].append("/blog/{0}/{1}/{2}/{3}".format(year, month, day, slug))
if results:
return render_template('posts.html', links=results, title='blog - {0} {1}, {2}'.format(m, d, y))
else:
abort(404)
@app.route('/blog/<int:year>/<int:month>/<int:day>/<slug>')
def postpage(year, month, day, slug):
page = "content/posts/{0}-{1}-{2}:{3}.md".format(year, month, day, slug)
if os.path.isfile(page):
with codecs.open(page, encoding='utf-8', mode='r+') as f:
content = f.read()
return render_template('post.html', page_html=content, title="blog - " + slug)
else:
abort(404)

Viewing latest article 19
Browse Latest Browse All 31

Trending Articles