aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/views/wiki/sitemap_xml.py
blob: 9b7f0980300d62f48e225eda7ae7b1f6ae6bdd14 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from flask import Response, url_for

from pysite.base_route import RouteView
from pysite.mixins import DBMixin


class SitemapXML(RouteView, DBMixin):
    path = "/sitemap.xml"
    name = "sitemap_xml"
    table_name = "wiki"

    def get(self):
        urls = []

        for page in self.db.get_all(self.table_name):
            urls.append({
                "change_frequency": "weekly",
                "type": "url",
                "url": url_for("wiki.page", page=page["slug"], _external=True)
            })

        return Response(self.render("sitemap.xml", urls=urls), content_type="application/xml")