From: Karim Hamidou Date: Sun, 27 Mar 2016 05:09:07 +0000 (-0700) Subject: (test) adding sitemap support X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=a141936b21c433b3a14ab153bed2798ec010eacd;p=rfcspot.git (test) adding sitemap support --- diff --git a/app.py b/app.py index 2e5826cf..315023cb 100644 --- a/app.py +++ b/app.py @@ -1,7 +1,8 @@ import os import json import datetime -from flask import Flask, render_template, request, redirect, url_for +from flask import (Flask, render_template, request, redirect, + url_for, make_response) from src.render_rfc import render_html_rfc @@ -52,6 +53,17 @@ def list_rfc(): untitled_rfc=sorted_untitled_list) +@app.route('/sitemap.xml') +def sitemap_view(): + """Render website's sitemap.""" + sitemap = render_template('sitemap.html', rfcs=metadata.values()) + + # We need to set the content-type header correctly. + response = make_response(sitemap) + response.headers['Content-Type'] = 'application/xml' + return response + + @app.after_request def add_header(response): """ diff --git a/templates/sitemap.html b/templates/sitemap.html new file mode 100644 index 00000000..42c707f2 --- /dev/null +++ b/templates/sitemap.html @@ -0,0 +1,18 @@ + + + + http://www.rfcspot.com/ + weekly + 0.8 + + {% for rfc in rfcs %} + {% if 'rfc' in rfc %} + + http://www.rfcspot.com/{{ rfc['rfc'] }} + weekly + 0.8 + + {% endif %} + {% endfor %} + +