diff --git a/docs/en/cfp.html b/docs/en/cfp.html index a7148f3..299c789 100644 --- a/docs/en/cfp.html +++ b/docs/en/cfp.html @@ -52,6 +52,7 @@ + diff --git a/docs/en/cfp_form.html b/docs/en/cfp_form.html index aeaa021..c860e0b 100644 --- a/docs/en/cfp_form.html +++ b/docs/en/cfp_form.html @@ -52,6 +52,7 @@ + diff --git a/docs/en/cfv.html b/docs/en/cfv.html index 99fd7fe..1521c8a 100644 --- a/docs/en/cfv.html +++ b/docs/en/cfv.html @@ -52,6 +52,7 @@ + diff --git a/docs/en/coc.html b/docs/en/coc.html index f60ec3d..b25160e 100644 --- a/docs/en/coc.html +++ b/docs/en/coc.html @@ -52,6 +52,7 @@ + diff --git a/docs/en/countdown.html b/docs/en/countdown.html index 00736d9..802761f 100644 --- a/docs/en/countdown.html +++ b/docs/en/countdown.html @@ -52,6 +52,7 @@ + diff --git a/docs/en/feed.rss b/docs/en/feed.rss new file mode 100644 index 0000000..26e7ff7 --- /dev/null +++ b/docs/en/feed.rss @@ -0,0 +1,44 @@ + + + + + + PyCon SK 2020 Newsroom + https://2020.pycon.sk/en/news.html + News from PyCon Sk 2020 community conference + en + + Conference chat. + https://join.slack.com/t/pyconsk/shared_invite/enQtODQ4NjU1NzM2NzI3LTA2ZGNiOTA4YzM5OWM3NmQyZjAxMDlmNzJjOGIzNjM4ZjEwZGI0MTJiYzAxZmNhZmVjMTZjZjliNWQ4ZjVlNjE + Last year we have used Slack as our conference chat so you can get in touch with organizers and also with fellow participants. For PyCon SK 2020 chat we are going to use the Slack. + Sat, 23 Nov 2019 00:00:00 +0100 + X1297842880833849801 + media + + + First batch of speakers. + https://2020.pycon.sk + We are honoured to announce the first batch of speakers that will be part of PyCon SK 2020. + Sat, 16 Nov 2019 00:00:00 +0100 + X7011295520301786405 + speakers + + + We celebrate the Day of Fighting for Freedom and Democracy. + https://en.wikipedia.org/wiki/Velvet_Revolution + On 17th November we celebrate the Day of Fighting for Freedom and Democracy. Thanks to this event we can freely organize PyCon SK. We want you to celebrate with us. During the holiday you can use 17% discount for tickets using discount code "30-rokov-slobody". + Fri, 15 Nov 2019 00:00:00 +0100 + 1930167262659116288 + conference + + + The Call for Proposals is open! + https://2020.pycon.sk/en/cfp.html + Do you know anyone in underrepresented group in IT who would like to do a conference talk? Let us know, and try to encourage him/her to submit Call for Proposals for PyCon SK 2020. We are trying to support diversity. Anyone can be part of the conference. + Sun, 20 Oct 2019 00:00:00 +0100 + 2475977916832491908 + speakers + + + + \ No newline at end of file diff --git a/docs/en/index.html b/docs/en/index.html index dd770a9..4c9ed5a 100644 --- a/docs/en/index.html +++ b/docs/en/index.html @@ -52,6 +52,7 @@ + diff --git a/docs/en/news.html b/docs/en/news.html index ac6a0a6..15d99c6 100644 --- a/docs/en/news.html +++ b/docs/en/news.html @@ -52,6 +52,7 @@ + diff --git a/docs/en/news/conference.html b/docs/en/news/conference.html index dc95074..778d677 100644 --- a/docs/en/news/conference.html +++ b/docs/en/news/conference.html @@ -52,6 +52,7 @@ + diff --git a/docs/en/news/media.html b/docs/en/news/media.html index c6e0a09..476613f 100644 --- a/docs/en/news/media.html +++ b/docs/en/news/media.html @@ -52,6 +52,7 @@ + diff --git a/docs/en/news/speakers.html b/docs/en/news/speakers.html index 3f48f5f..f831c17 100644 --- a/docs/en/news/speakers.html +++ b/docs/en/news/speakers.html @@ -52,6 +52,7 @@ + diff --git a/docs/en/privacy-policy.html b/docs/en/privacy-policy.html index 692c3f9..d18db3e 100644 --- a/docs/en/privacy-policy.html +++ b/docs/en/privacy-policy.html @@ -52,6 +52,7 @@ + diff --git a/docs/en/recording.html b/docs/en/recording.html index 0070006..69d4c03 100644 --- a/docs/en/recording.html +++ b/docs/en/recording.html @@ -52,6 +52,7 @@ + diff --git a/docs/en/thanks.html b/docs/en/thanks.html index cfd67be..3a7e677 100644 --- a/docs/en/thanks.html +++ b/docs/en/thanks.html @@ -52,6 +52,7 @@ + diff --git a/docs/en/tickets.html b/docs/en/tickets.html index 91cbcd1..43411a1 100644 --- a/docs/en/tickets.html +++ b/docs/en/tickets.html @@ -55,6 +55,7 @@ + diff --git a/docs/index.html b/docs/index.html index c73c07c..a4bddf0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -52,6 +52,7 @@ + diff --git a/docs/sitemap.xml b/docs/sitemap.xml index f8b436f..9200070 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -75,6 +75,11 @@ https://2020.pycon.sk/en/cfv.html 2020-01-04 + + + https://2020.pycon.sk/en/feed.rss + 2020-01-04 + https://2020.pycon.sk/ @@ -150,5 +155,10 @@ https://2020.pycon.sk/sk/cfv.html 2020-01-04 + + + https://2020.pycon.sk/sk/feed.rss + 2020-01-04 + \ No newline at end of file diff --git a/docs/sk/cfp.html b/docs/sk/cfp.html index 1c435fc..93dcb6f 100644 --- a/docs/sk/cfp.html +++ b/docs/sk/cfp.html @@ -52,6 +52,7 @@ + diff --git a/docs/sk/cfp_form.html b/docs/sk/cfp_form.html index f5ab0bf..0361654 100644 --- a/docs/sk/cfp_form.html +++ b/docs/sk/cfp_form.html @@ -52,6 +52,7 @@ + diff --git a/docs/sk/cfv.html b/docs/sk/cfv.html index 5f8d2e3..de37abd 100644 --- a/docs/sk/cfv.html +++ b/docs/sk/cfv.html @@ -52,6 +52,7 @@ + diff --git a/docs/sk/coc.html b/docs/sk/coc.html index ef47d1b..ebef8aa 100644 --- a/docs/sk/coc.html +++ b/docs/sk/coc.html @@ -52,6 +52,7 @@ + diff --git a/docs/sk/countdown.html b/docs/sk/countdown.html index 37ddcc0..7a7ec44 100644 --- a/docs/sk/countdown.html +++ b/docs/sk/countdown.html @@ -52,6 +52,7 @@ + diff --git a/docs/sk/feed.rss b/docs/sk/feed.rss new file mode 100644 index 0000000..4f0f718 --- /dev/null +++ b/docs/sk/feed.rss @@ -0,0 +1,44 @@ + + + + + + Novinky z PyCon SK 2020 + https://2020.pycon.sk/sk/news.html + Novinky z komunitnej konferencie PyCon SK + sk + + Konferenčný chat. + https://join.slack.com/t/pyconsk/shared_invite/enQtODQ4NjU1NzM2NzI3LTA2ZGNiOTA4YzM5OWM3NmQyZjAxMDlmNzJjOGIzNjM4ZjEwZGI0MTJiYzAxZmNhZmVjMTZjZjliNWQ4ZjVlNjE + Minulý rok sme používali Slack ako konferenčný chat, pomocou ktorého ste mohli komunikovať s organizátormi a aj s ďalšími účastníkmi. Aj na PyCon SK 2020 budeme používať Slack. + Sat, 23 Nov 2019 00:00:00 +0100 + X9117983569691494731 + media + + + Prvá várka rečníkov. + https://2020.pycon.sk + Je nám cťou predstaviť prvých potvrdených rečníkov na PyCon SK 2020. + Sat, 16 Nov 2019 00:00:00 +0100 + 9157616666749676994 + speakers + + + Oslavujeme Deň boja za slobodu a demokraciu. + https://en.wikipedia.org/wiki/Velvet_Revolution + 17. novembra oslavujeme Deň boja za slobodu a demokraciu. Vďaka tejto udalosti môžeme slobodne organizovať PyCon SK. Chceme, aby ste oslavovali aj vy. Počas celého sviatku môže využiť zľavu 17% na lístky s promo kódom "30-rokov-slobody". + Fri, 15 Nov 2019 00:00:00 +0100 + 9056812806562436807 + conference + + + Predkladanie prednášok a workshopov je otvorené! + https://2020.pycon.sk/en/cfp.html + Poznáš niekoho z málo zastúpenej skupiny v IT, kto by chcel urobiť prednášku na konferencii? Daj nám vedieť a povzbuď ho/ju, aby si podal/a návrh na prednášku na PyCon SK 2020. Snažíme sa podporovať rôznorodosť. + Sun, 20 Oct 2019 00:00:00 +0100 + 7258377453004018800 + speakers + + + + \ No newline at end of file diff --git a/docs/sk/index.html b/docs/sk/index.html index c73c07c..a4bddf0 100644 --- a/docs/sk/index.html +++ b/docs/sk/index.html @@ -52,6 +52,7 @@ + diff --git a/docs/sk/news.html b/docs/sk/news.html index 71a312c..9fc2d84 100644 --- a/docs/sk/news.html +++ b/docs/sk/news.html @@ -52,6 +52,7 @@ + diff --git a/docs/sk/news/conference.html b/docs/sk/news/conference.html index f41e919..d1491b9 100644 --- a/docs/sk/news/conference.html +++ b/docs/sk/news/conference.html @@ -52,6 +52,7 @@ + diff --git a/docs/sk/news/media.html b/docs/sk/news/media.html index 101ff43..67f38f7 100644 --- a/docs/sk/news/media.html +++ b/docs/sk/news/media.html @@ -52,6 +52,7 @@ + diff --git a/docs/sk/news/speakers.html b/docs/sk/news/speakers.html index a81c7c4..ae3b863 100644 --- a/docs/sk/news/speakers.html +++ b/docs/sk/news/speakers.html @@ -52,6 +52,7 @@ + diff --git a/docs/sk/privacy-policy.html b/docs/sk/privacy-policy.html index d14b86c..b338803 100644 --- a/docs/sk/privacy-policy.html +++ b/docs/sk/privacy-policy.html @@ -52,6 +52,7 @@ + diff --git a/docs/sk/recording.html b/docs/sk/recording.html index 0d2be57..7ff5b5e 100644 --- a/docs/sk/recording.html +++ b/docs/sk/recording.html @@ -52,6 +52,7 @@ + diff --git a/docs/sk/thanks.html b/docs/sk/thanks.html index d0d1bef..d78ff39 100644 --- a/docs/sk/thanks.html +++ b/docs/sk/thanks.html @@ -52,6 +52,7 @@ + diff --git a/docs/sk/tickets.html b/docs/sk/tickets.html index aa3e619..de0cae6 100644 --- a/docs/sk/tickets.html +++ b/docs/sk/tickets.html @@ -55,6 +55,7 @@ + diff --git a/pycon.py b/pycon.py index e8e8742..8c5cb2e 100755 --- a/pycon.py +++ b/pycon.py @@ -3,14 +3,8 @@ from flask import Flask, g, request, render_template, abort, make_response, url_for, redirect from flask_babel import Babel, gettext, lazy_gettext -from utils import get_news, get_speakers - -EVENT = gettext('PyCon SK 2020 | 27 - 29 March 2020 | Bratislava, Slovakia') -DOMAIN = 'https://2020.pycon.sk' -API_DOMAIN = 'https://api.pycon.sk' - -LANGS = ('en', 'sk') -TIME_FORMAT = '%Y-%m-%dT%H:%M:%S+00:00' +from settings import EVENT, DOMAIN, API_DOMAIN, LANGUAGES, TIME_FORMAT +from utils import get_news, get_rss, get_speakers app = Flask(__name__, static_url_path='/static') # pylint: disable=invalid-name app.config['BABEL_DEFAULT_LOCALE'] = 'sk' @@ -32,7 +26,7 @@ def sitemap(): excluded = {'static', 'sitemap'} pages = [] - for lang in LANGS: + for lang in LANGUAGES: for rule in app.url_map.iter_rules(): if 'GET' in rule.methods and rule.endpoint not in excluded: @@ -134,6 +128,15 @@ def countdown(): return render_template('countdown.html', **template_vars) +@app.route('//feed.rss') +def rss_feed(): + rss_content = get_rss(get_locale()) + rss_xml = render_template('rss.xml', **rss_content) + response = make_response(rss_xml) + response.headers['Content-Type'] = 'application/x-rss+xml' + return response + + def _get_template_variables(**kwargs): """Collect variables for template that repeats, e.g. are in body.html template""" variables = { @@ -150,7 +153,7 @@ def _get_template_variables(**kwargs): def before(): # pylint: disable=inconsistent-return-statements if request.view_args and 'lang_code' in request.view_args: g.current_lang = request.view_args['lang_code'] - if request.view_args['lang_code'] not in LANGS: + if request.view_args['lang_code'] not in LANGUAGES: return abort(404) request.view_args.pop('lang_code') diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..44d6f45 --- /dev/null +++ b/settings.py @@ -0,0 +1,9 @@ +from flask_babel import gettext + + +EVENT = gettext('PyCon SK 2020 | 27 - 29 March 2020 | Bratislava, Slovakia') +DOMAIN = 'https://2020.pycon.sk' +API_DOMAIN = 'https://api.pycon.sk' +LANGUAGES = ('en', 'sk') +TIME_FORMAT = '%Y-%m-%dT%H:%M:%S+00:00' + diff --git a/templates/body.html b/templates/body.html index 803cfd2..b4ffe0d 100644 --- a/templates/body.html +++ b/templates/body.html @@ -52,8 +52,10 @@ {% if lang_code == 'sk' %} + {% else %} + {% endif %} diff --git a/templates/rss.xml b/templates/rss.xml new file mode 100644 index 0000000..b5006f1 --- /dev/null +++ b/templates/rss.xml @@ -0,0 +1,20 @@ + + + + + + {{ title }} + https://2020.pycon.sk{{ url_for('news', lang_code=language) }} + {{ description }} + {{ language }}{% for item in items %} + + {{ item.title }} + {{ item.link }} + {{ item.description }} + {{ item.pubdate }} + {{ item.guid }}{% for cat in item.categories %} + {{ cat }}{% endfor %} + {% endfor %} + + + \ No newline at end of file diff --git a/translations/sk/LC_MESSAGES/messages.po b/translations/sk/LC_MESSAGES/messages.po index c241eb5..1f7315d 100644 --- a/translations/sk/LC_MESSAGES/messages.po +++ b/translations/sk/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2020-01-04 22:46+0100\n" +"POT-Creation-Date: 2020-01-05 19:55+0100\n" "PO-Revision-Date: 2018-11-27 22:00+0200\n" "Last-Translator: FULL NAME \n" "Language: sk\n" @@ -16,12 +16,24 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.8.0\n" +"Generated-By: Babel 2.7.0\n" -#: pycon.py:8 +#: settings.py:4 msgid "PyCon SK 2020 | 27 - 29 March 2020 | Bratislava, Slovakia" msgstr "PyCon SK 2020 | 27. - 29. marec 2020 | Bratislava" +#: utils.py:72 +msgid "Unnamed message" +msgstr "Správa bez názvu" + +#: utils.py:98 +msgid "PyCon SK 2020 Newsroom" +msgstr "Novinky z PyCon SK 2020" + +#: utils.py:100 +msgid "News from PyCon Sk 2020 community conference" +msgstr "Novinky z komunitnej konferencie PyCon SK" + #: templates/body.html:8 msgid "Official PyCon SK 2020 website" msgstr "Oficiálna stránka PyCon SK 2020" @@ -38,11 +50,11 @@ msgstr "" "PyCon SK je komunitou organizovaná konferencia pre programovací jazyk " "Python, ktorá sa bude konať v Bratislave 27. až 29. marca 2019." -#: templates/body.html:67 +#: templates/body.html:69 msgid "You are using an outdated browser." msgstr "Používate zastaraný prehliadač." -#: templates/body.html:68 +#: templates/body.html:70 msgid "" "Please upgrade your browser to " "improve your experience." @@ -50,46 +62,46 @@ msgstr "" "Prosím, nainštalujte si novšiu verziu" " prehliadača, aby ste si zlepšili zážitok z prehliadania stránok." -#: templates/body.html:117 templates/news.html:10 templates/news.html:18 +#: templates/body.html:119 templates/news.html:10 templates/news.html:18 msgid "Newsroom" msgstr "Novinky" -#: templates/body.html:120 templates/body.html:152 templates/cfp_form.html:15 +#: templates/body.html:122 templates/body.html:154 templates/cfp_form.html:15 #: templates/recording.html:15 msgid "Call for proposals" msgstr "Prihlás svoj príspevok" -#: templates/body.html:123 templates/body.html:155 +#: templates/body.html:125 templates/body.html:157 msgid "Call for volunteers" msgstr "Pridaj sa k nám" -#: templates/body.html:126 templates/body.html:158 templates/coc.html:10 +#: templates/body.html:128 templates/body.html:160 templates/coc.html:10 #: templates/coc.html:15 msgid "Code of Conduct" msgstr "Kódex správania" -#: templates/body.html:161 templates/body.html:186 templates/body.html:187 -#: templates/index.html:20 templates/index.html:277 +#: templates/body.html:163 templates/body.html:188 templates/body.html:189 +#: templates/index.html:20 templates/index.html:273 msgid "Buy Tickets" msgstr "Kúp si lístok" -#: templates/body.html:213 +#: templates/body.html:215 msgid "Event Organiser" msgstr "Organizátor podujatia" -#: templates/body.html:227 +#: templates/body.html:229 msgid "General Queries" msgstr "Všeobecné otázky" -#: templates/body.html:241 +#: templates/body.html:243 msgid "Ticket Queries" msgstr "Otázky o vstupenkách" -#: templates/body.html:255 +#: templates/body.html:257 msgid "Sponsor Queries" msgstr "Otázky o sponzorovaní" -#: templates/body.html:271 +#: templates/body.html:273 msgid "" "The PyCon SK 2020 conference, which will be held in Bratislava, is the " "annual gathering for the community using and developing the open-source " @@ -99,16 +111,16 @@ msgstr "" "každoročné stretnutie komunity využívajúcej a vyvíjajúcej open sourcový " "programovací jazyk Python." -#: templates/body.html:273 templates/body.html:323 templates/countdown.html:98 +#: templates/body.html:275 templates/body.html:325 templates/countdown.html:98 #, python-format msgid "PyCon SK is organized by volunteers from %(spy)s." msgstr "PyCon SK je organizovaný dobrovoľníkmi a dobrovoľníčkami z %(spy)s." -#: templates/body.html:274 templates/body.html:324 templates/countdown.html:99 +#: templates/body.html:276 templates/body.html:326 templates/countdown.html:99 msgid "SPy o.z." msgstr "SPy o.z." -#: templates/body.html:326 templates/countdown.html:94 +#: templates/body.html:328 templates/countdown.html:94 #, python-format msgid "" "%(pycontm)s is a trademark for worldwide conference activities claimed by" @@ -117,11 +129,11 @@ msgstr "" "%(pycontm)s je ochranná známka %(psf)s pre celosvetové konferenčné " "aktivity." -#: templates/body.html:328 templates/countdown.html:96 +#: templates/body.html:330 templates/countdown.html:96 msgid "Python Software Foundation" msgstr "Python Software Foundation" -#: templates/body.html:331 templates/countdown.html:102 +#: templates/body.html:333 templates/countdown.html:102 #, python-format msgid "" "Found a bug? Missing some information? This is a community managed " @@ -1066,11 +1078,11 @@ msgstr "Rečníci, ktorí už potvrdili účasť na PyCon SK 2020." msgid "You can fill the Call for Proposals and join this list..." msgstr "Vyplň návrh na prednášku a pridaj sa do zoznamu..." -#: templates/index.html:275 +#: templates/index.html:271 msgid "Get Your Ticket Now" msgstr "Kúp si lístok teraz" -#: templates/index.html:276 +#: templates/index.html:272 msgid "" "Conference tickets are available for purchase. So far each PyCon SK " "edition has sold out, so do not leave buying your ticket to the last " @@ -1080,19 +1092,19 @@ msgstr "" "vypredal, takže si nenechávaj nákup lístka na poslednú chvíľu, lebo už " "môžu byť vypredané..." -#: templates/index.html:288 +#: templates/index.html:284 msgid "Official Sponsors & Partners" msgstr "Oficiálni sponzori a partneri" -#: templates/index.html:289 +#: templates/index.html:285 msgid "We are looking for sponsors and partners. Please get in touch with us." msgstr "Hľadáme sponzorov a partnerov. Prosím, kontaktujte nás." -#: templates/index.html:290 +#: templates/index.html:286 msgid "Check Who Makes This Event Possible!" msgstr "Pozri sa, bez koho by táto konferencia nebola možná!" -#: templates/index.html:294 templates/index.html:295 +#: templates/index.html:290 templates/index.html:291 msgid "Become a Sponsor" msgstr "Staň sa sponzorom" diff --git a/utils.py b/utils.py index 1354caa..98be41c 100644 --- a/utils.py +++ b/utils.py @@ -1,7 +1,10 @@ +from datetime import datetime, date import os import json +from flask import url_for +from flask_babel import gettext as _ -from datetime import datetime +from settings import LANGUAGES, DOMAIN def read_json_file(path): @@ -38,3 +41,63 @@ def get_news(lang='sk'): def get_speakers(): return read_json_file(os.path.join('data', 'speakers.json')) + + +def rss_date(pub_date=None): + """ + Reformats date string from YYYY-MM-DD to RSS pubDate following RFC822 + in CET timezone (hardcoded) + """ + if pub_date is None: + pub_date = date(2019, 10, 1) + rss_formatted = pub_date.strftime("%a, %d %b %Y %H:%M:%S +0100") + return rss_formatted + + +def get_guid(title, pub_date): + # RSS validator requires GUID if multiple items + # as we do not use database, hash of date + title to get unique result is used + title = title[:20] + max(20 - len(title), 0) * '=' + unique = ':'.join([pub_date.strftime('%Y-%m-%d'), title]) + return str(hash(unique)).replace('-', 'X') + + +def fix_url(url): + if url.startswith('/') and not url.startswith('http://') and not url.startswith('https://'): + url = DOMAIN + url + return url + + +def get_item(story): + title = story.get('title', _('Unnamed message')) + pub_date = story.get('date') + return { + 'title': title, + 'link': fix_url(story.get('url', DOMAIN)), + 'description': story.get('meta', ''), + 'pubdate': rss_date(pub_date), + 'categories': story.get('categories', []), + 'guid': get_guid(title, pub_date) + } + + +def get_rss(lang=None): + """ + Generate RSS according to https://www.w3schools.com/XML/xml_rss.asp + As an input it uses data from /data/news.json + :param lang: string, if None fallback to default 'sk' + :return: RSS xml + """ + if not lang or lang not in LANGUAGES: + lang = 'sk' + news = get_news(lang) + ordered_news = sorted(news, key=lambda x: x.get('date'), reverse=True) + items = [get_item(story) for story in ordered_news] + + return { + 'title': _('PyCon SK 2020 Newsroom'), + 'link': url_for('news', lang_code=lang), + 'description': _('News from PyCon Sk 2020 community conference'), + 'language': lang, + 'items': items + }