Skip to content
Snippets Groups Projects
Commit 54ef7bcf authored by Andreas Valder's avatar Andreas Valder
Browse files

added sitemap.xml closes #10

parent ed820782
No related branches found
No related tags found
No related merge requests found
......@@ -399,6 +399,24 @@ def new_featured():
return redirect(request.values['ref'])
return id, 200
@app.route('/sitemap.xml', methods=['GET'])
def sitemap():
pages=[]
# static pages
for rule in app.url_map.iter_rules():
if 'GET' in rule.methods and len(rule.arguments)==0:
if rule.endpoint not in mod_endpoints:
pages.append([rule.rule])
for i in query('select * from courses where visible and listed'):
pages.append([url_for('course',handle=i['handle'])])
for j in query('select * from lectures where (course_id = ? and visible)',i['id']):
pages.append([url_for('lecture',id=j['id'])])
return Response(render_template('sitemap.xml', pages=pages), 200, {'Content-Type': 'application/atom+xml'} )
import feeds
import importer
import schedule
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for page in pages %}
<url>
<loc>{{page[0]|safe}}</loc>
<lastmod>{{page[1]}}</lastmod>
</url>
{% endfor %}
</urlset>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment