Merge pull request #33 from Ayreonaut/mst-rss-feed

rss: page content, german locale
pull/37/head
Johannes Thumshirn 4 years ago committed by GitHub
commit 647650442b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,6 +8,7 @@ from flask_fontawesome import FontAwesome
from datetime import datetime from datetime import datetime
from fotogrid import fotogrid from fotogrid import fotogrid
from feed import generate_feed from feed import generate_feed
import locale
# directly support jinja within markdown blogposts # directly support jinja within markdown blogposts
@ -74,4 +75,5 @@ def rss():
if __name__ == '__main__': if __name__ == '__main__':
locale.setlocale(locale.LC_TIME, "de_DE")
app.run(host='0.0.0.0') app.run(host='0.0.0.0')

@ -26,6 +26,7 @@ def generate_feed(pages):
fe.author(name=p.meta['author']) fe.author(name=p.meta['author'])
fe.description(p.meta['description']) fe.description(p.meta['description'])
fe.link(href='https://fdgl.rocks/' + p.path + '.html') fe.link(href='https://fdgl.rocks/' + p.path + '.html')
fe.content(p.html)
response = make_response(fg.rss_str()) response = make_response(fg.rss_str())
response.headers.set('Content-Type', 'application/rss+xml') response.headers.set('Content-Type', 'application/rss+xml')

@ -6,14 +6,22 @@ from lxml import etree
from io import StringIO from io import StringIO
def check_if_valid_html(html): def check_if_valid_html(html):
"""
GIVEN an html string
WHEN parsing the html string results in an error
THEN assert
"""
parser = etree.HTMLParser(recover=False) parser = etree.HTMLParser(recover=False)
etree.parse(StringIO(html), parser) etree.parse(StringIO(html), parser)
assert len(parser.error_log) == 0 assert len(parser.error_log) == 0
def test_fotogrid_empty_list(): def test_fotogrid_empty_list():
urls = [] """
html = fotogrid(urls) WHEN creating a fotogrid without any image url
THEN expecting an empty result (no html code at all)
"""
html = fotogrid([])
assert len(html) == 0 assert len(html) == 0
@ -26,7 +34,11 @@ def check_if_images_result_in(nbr_of_images, rows_expected, cols_expected):
assert html.count("<img ") == nbr_of_images assert html.count("<img ") == nbr_of_images
def test_fotogrid(app, client): def test_fotogrid():
"""
WHEN creating fotogrids whith 1 - 9 image urls
THEN expecting up to four generated columns
"""
check_if_images_result_in(1, 1, 1) check_if_images_result_in(1, 1, 1)
check_if_images_result_in(2, 1, 2) check_if_images_result_in(2, 1, 2)
check_if_images_result_in(3, 1, 3) check_if_images_result_in(3, 1, 3)

Loading…
Cancel
Save