From be015e06836a0ddd023ce47887d16dca9fd5456a Mon Sep 17 00:00:00 2001 From: Hajime Morrita Date: Thu, 19 Dec 2019 05:50:22 -0800 Subject: [PATCH] Support feed URLs. --- main.py | 7 ++++++- main_test.py | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 361ab2c..bce5ecf 100644 --- a/main.py +++ b/main.py @@ -10,9 +10,14 @@ def _redirect_to_fallback(): return flask.redirect('https://anemone.dodgson.org/') +def _redirect_to_feed(): + return flask.redirect('https://anemone.dodgson.org/index.xml') @app.route('/') def all(path): + if path in ['atom.xml', 'index.rdf', 'no_comments.rdf']: + return _redirect_to_feed() + # All the relevant URL is (shold be able to) categorized solely based on the path part. # You don't have to look at the host name. @@ -20,7 +25,7 @@ def all(path): # http://www.dodgson.org/omo/t/?date=20080316 date_param = flask.request.args.get('date', None) if date_param: - match = re.match('(\d\d\d\d)(\d\d)(\d\d)', date_param) + match = re.match(r'(\d\d\d\d)(\d\d)(\d\d)', date_param) if not match: return _redirect_to_fallback() yyyy, mm, dd = match.group(1, 2, 3) diff --git a/main_test.py b/main_test.py index 9ea2e64..e6a222a 100644 --- a/main_test.py +++ b/main_test.py @@ -29,3 +29,6 @@ def test_octopress(): def test_octopress_pages(): _assert_redirect('/blog/archives/', 'https://blog.dodgson.org/blog/archives/') + +def test_feed(): + _assert_redirect('/atom.xml', 'https://anemone.dodgson.org/index.xml')