diff options
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -4,7 +4,7 @@ browsing to certain pages """ import os from flask import request, send_from_directory, abort -from flask import render_template, render_template_string +from flask import render_template, render_template_string, make_response from siteconfig import siteconfig from server import app, cache from view_functions import default_context, index_dir, is_hidden_path @@ -19,6 +19,8 @@ CONTENT_BLOCK = ( @app.route("/") @app.route("/site") +@app.route("/site/home.html") +@app.route("/site/index.html") @cache.cached() def home(): """ @@ -48,7 +50,7 @@ def render_file(path): """ if is_hidden_path(path): abort(404) - abs_path = "./templates/site/" + path + abs_path = siteconfig.BASE_DIR + path context = default_context() context.update( { @@ -68,7 +70,7 @@ def render_file(path): else: # not an html file, so don't render it return send_from_directory( - 'templates/site/', + siteconfig.BASE_DIR, path, mimetype=siteconfig.MIMETYPES.get( f".{ path.split('.')[-1] }", @@ -101,7 +103,7 @@ def send_file_from_site(path): as with `render_file`, send the raw file to the user """ return send_from_directory( - 'templates/site/', + siteconfig.BASE_DIR, path, mimetype=siteconfig.MIMETYPES.get( f".{ path.split('.')[-1] }", siteconfig.DEFAULT_MIMETYPE @@ -122,3 +124,16 @@ def send_file_from_static(path): f".{ path.split('.')[-1] }", siteconfig.DEFAULT_MIMETYPE ), ) + + +@app.route("/feed.xml") +@cache.cached() +def render_rss_feed(): + context = { + 'config': siteconfig.rss_channel_config, + 'items': app.config['RSS_CHANNEL'], + } + feed = render_template("feed.xml", **context) + response = make_response(feed) + response.headers['Content-Type'] = siteconfig.MIMETYPES.get(".xml") + return response |