Merge pull request #9 from F-D-G-L/main

Followup
pull/33/head
Markus Steinlein 4 years ago committed by GitHub
commit 24bb3093d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,6 +7,7 @@ from flask_flatpages.utils import pygmented_markdown
from flask_fontawesome import FontAwesome
from datetime import datetime
from fotogrid import fotogrid
from feed import generate_feed
# directly support jinja within markdown blogposts
@ -67,5 +68,10 @@ def index():
return render_template('index.html', pages=sorted_pages)
@app.route('/rss')
def rss():
return generate_feed(pages)
if __name__ == '__main__':
app.run(host='0.0.0.0')

@ -0,0 +1,33 @@
# SPDX-License-Identifier: GPL-3.0
from feedgen.feed import FeedGenerator
from datetime import datetime
from flask import make_response
def generate_feed(pages):
"""
Provide a simple RSS feed for all articles on the page.
:param pages: The paghes instance from flask-flatpages extension.
:return: flask response that should be return when calling the feed url
"""
fg = FeedGenerator()
fg.title('FdgL- Website Feed')
fg.description(
'Neuigkeiten von den Freund*innen des geordneten Lärms e.V.')
fg.link(href='https://fdgl.rocks')
for p in pages:
fe = fg.add_entry()
fe.title(p.meta['title'])
date = datetime.strptime(p.meta["date"] +
' 00:00:00 +0100', "%d.%m.%Y %H:%M:%S %z")
fe.published(date)
fe.author(name=p.meta['author'])
fe.description(p.meta['description'])
fe.link(href='https://fdgl.rocks/' + p.path + '.html')
response = make_response(fg.rss_str())
response.headers.set('Content-Type', 'application/rss+xml')
return response

@ -1,6 +1,7 @@
flask
flask_flatpages
flask_fontawesome
feedgen
pytest
pytest-cov

@ -0,0 +1,8 @@
# SPDX-License-Identifier: GPL-3.0
import os
def test_index(app, client):
print("Checking presence of: rss feed")
res = client.get("/rss")
assert res.status_code == 200
Loading…
Cancel
Save