From 8f40f19328a1d3e0aed728036a1b53fecd29f15e Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Wed, 30 Mar 2022 10:51:10 +0200 Subject: [PATCH] RSS feed CDATA should contain difference output --- changedetectionio/__init__.py | 23 ++++++++++++++++++----- changedetectionio/tests/test_backend.py | 5 +++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index 02353778..6412ebf0 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -272,7 +272,7 @@ def changedetection_app(config=None, datastore_o=None): @app.route("/rss", methods=['GET']) @login_required def rss(): - + from . import diff limit_tag = request.args.get('tag') # Sort by last_changed and add the uuid which is usually the key.. @@ -301,6 +301,15 @@ def changedetection_app(config=None, datastore_o=None): fg.link(href='https://changedetection.io') for watch in sorted_watches: + + dates = list(watch['history'].keys()) + # Convert to int, sort and back to str again + # @todo replace datastore getter that does this automatically + dates = [int(i) for i in dates] + dates.sort(reverse=True) + dates = [str(i) for i in dates] + prev_fname = watch['history'][dates[1]] + if not watch['viewed']: # Re #239 - GUID needs to be individual for each event # @todo In the future make this a configurable link back (see work on BASE_URL https://github.com/dgtlmoon/changedetection.io/pull/228) @@ -316,12 +325,16 @@ def changedetection_app(config=None, datastore_o=None): diff_link = {'href': "{}{}".format(base_url, url_for('diff_history_page', uuid=watch['uuid']))} - # @todo use title if it exists fe.link(link=diff_link) - fe.title(title=watch['url']) - # @todo in the future Any code html is valid.]]> - fe.description(description=watch['url']) + # @todo watch should be a getter - watch.get('title') (internally if URL else..) + + watch_title = watch.get('title') if watch.get('title') else watch.get('url') + fe.title(title=watch_title) + latest_fname = watch['history'][dates[0]] + + html_diff = diff.render_diff(prev_fname, latest_fname, include_equal=False, line_feed_sep="
") + fe.description(description="

{}

{}".format(watch_title, html_diff)) fe.guid(guid, permalink=False) dt = datetime.datetime.fromtimestamp(int(watch['newest_history_key'])) diff --git a/changedetectionio/tests/test_backend.py b/changedetectionio/tests/test_backend.py index ddd32751..c23d01ee 100644 --- a/changedetectionio/tests/test_backend.py +++ b/changedetectionio/tests/test_backend.py @@ -70,6 +70,11 @@ def test_check_basic_change_detection_functionality(client, live_server): res = client.get(url_for("rss")) expected_url = url_for('test_endpoint', _external=True) assert b'