Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Video AG Infrastruktur
website
Commits
54ef7bcf
Commit
54ef7bcf
authored
Sep 08, 2016
by
Andreas Valder
Browse files
added sitemap.xml closes #10
parent
ed820782
Changes
2
Hide whitespace changes
Inline
Side-by-side
server.py
View file @
54ef7bcf
...
...
@@ -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
templates/sitemap.xml
0 → 100644
View file @
54ef7bcf
<?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>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment