mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2026-01-30 02:46:02 +00:00
Multi-language / Translations Support (#3696) - Complete internationalization system implemented - Support for 7 languages: Czech (cs), German (de), French (fr), Italian (it), Korean (ko), Chinese Simplified (zh), Chinese Traditional (zh_TW) - Language selector with localized flags and theming - Flash message translations - Multiple translation fixes and improvements across all languages - Language setting preserved across redirects Pluggable Content Fetchers (#3653) - New architecture for extensible content fetcher system - Allows custom fetcher implementations Image / Screenshot Comparison Processor (#3680) - New processor for visual change detection (disabled for this release) - Supporting CSS/JS infrastructure added UI Improvements Design & Layout - Auto-generated tag color schemes - Simplified login form styling - Removed hard-coded CSS, moved to SCSS variables - Tag UI cleanup and improvements - Automatic tab wrapper functionality - Menu refactoring for better organization - Cleanup of offset settings - Hide sticky tabs on narrow viewports - Improved responsive layout (#3702) User Experience - Modal alerts/confirmations on delete/clear operations (#3693, #3598, #3382) - Auto-add https:// to URLs in quickwatch form if not present - Better redirect handling on login (#3699) - 'Recheck all' now returns to correct group/tag (#3673) - Language set redirect keeps hash fragment - More friendly human-readable text throughout UI Performance & Reliability Scheduler & Processing - Soft delays instead of blocking time.sleep() calls (#3710) - More resilient handling of same UUID being processed (#3700) - Better Puppeteer timeout handling - Improved Puppeteer shutdown/cleanup (#3692) - Requests cleanup now properly async History & Rendering - Faster server-side "difference" rendering on History page (#3442) - Show ignored/triggered rows in history - API: Retry watch data if watch dict changed (more reliable) API Improvements - Watch get endpoint: retry mechanism for changed watch data - WatchHistoryDiff API endpoint includes extra format args (#3703) Testing Improvements - Replace time.sleep with wait_for_notification_endpoint_output (#3716) - Test for mode switching (#3701) - Test for #3720 added (#3725) - Extract-text difference test fixes - Improved dev workflow Bug Fixes - Notification error text output (#3672, #3669, #3280) - HTML validation fixes (#3704) - Template discovery path fixes - Notification debug log now uses system locale for dates/times - Puppeteer spelling mistake in log output - Recalculation on anchor change - Queue bubble update disabled temporarily Dependency Updates - beautifulsoup4 updated (#3724) - psutil 7.1.0 → 7.2.1 (#3723) - python-engineio ~=4.12.3 → ~=4.13.0 (#3707) - python-socketio ~=5.14.3 → ~=5.16.0 (#3706) - flask-socketio ~=5.5.1 → ~=5.6.0 (#3691) - brotli ~=1.1 → ~=1.2 (#3687) - lxml updated (#3590) - pytest ~=7.2 → ~=9.0 (#3676) - jsonschema ~=4.0 → ~=4.25 (#3618) - pluggy ~=1.5 → ~=1.6 (#3616) - cryptography 44.0.1 → 46.0.3 (security) (#3589) Documentation - README updated with viewport size setup information Development Infrastructure - Dev container only built on dev branch - Improved dev workflow tooling
106 lines
4.7 KiB
Python
106 lines
4.7 KiB
Python
from flask import make_response, request, url_for, redirect
|
|
|
|
|
|
|
|
def construct_main_feed_routes(rss_blueprint, datastore):
|
|
"""
|
|
Construct the main RSS feed routes.
|
|
|
|
Args:
|
|
rss_blueprint: The Flask blueprint to add routes to
|
|
datastore: The ChangeDetectionStore instance
|
|
"""
|
|
|
|
# Some RSS reader situations ended up with rss/ (forward slash after RSS) due
|
|
# to some earlier blueprint rerouting work, it should goto feed.
|
|
@rss_blueprint.route("/", methods=['GET'])
|
|
def extraslash():
|
|
return redirect(url_for('rss.feed'))
|
|
|
|
# Import the login decorator if needed
|
|
# from changedetectionio.auth_decorator import login_optionally_required
|
|
@rss_blueprint.route("", methods=['GET'])
|
|
def feed():
|
|
from feedgen.feed import FeedGenerator
|
|
from loguru import logger
|
|
import time
|
|
|
|
from . import RSS_TEMPLATE_HTML_DEFAULT, RSS_TEMPLATE_PLAINTEXT_DEFAULT
|
|
from ._util import (validate_rss_token, generate_watch_guid, get_rss_template,
|
|
get_watch_label, build_notification_context, render_notification,
|
|
populate_feed_entry, add_watch_categories)
|
|
from ...notification_service import NotificationService
|
|
|
|
now = time.time()
|
|
|
|
# Validate token
|
|
is_valid, error = validate_rss_token(datastore, request)
|
|
if not is_valid:
|
|
return error
|
|
|
|
rss_content_format = datastore.data['settings']['application'].get('rss_content_format')
|
|
|
|
limit_tag = request.args.get('tag', '').lower().strip()
|
|
# Be sure limit_tag is a uuid
|
|
for uuid, tag in datastore.data['settings']['application'].get('tags', {}).items():
|
|
if limit_tag == tag.get('title', '').lower().strip():
|
|
limit_tag = uuid
|
|
|
|
# Sort by last_changed and add the uuid which is usually the key..
|
|
sorted_watches = []
|
|
|
|
# @todo needs a .itemsWithTag() or something - then we can use that in Jinaj2 and throw this away
|
|
for uuid, watch in datastore.data['watching'].items():
|
|
# @todo tag notification_muted skip also (improve Watch model)
|
|
if datastore.data['settings']['application'].get('rss_hide_muted_watches') and watch.get('notification_muted'):
|
|
continue
|
|
if limit_tag and not limit_tag in watch['tags']:
|
|
continue
|
|
sorted_watches.append(watch)
|
|
|
|
sorted_watches.sort(key=lambda x: x.last_changed, reverse=False)
|
|
|
|
fg = FeedGenerator()
|
|
fg.title('changedetection.io')
|
|
fg.description('Feed description')
|
|
fg.link(href='https://changedetection.io')
|
|
notification_service = NotificationService(datastore=datastore, notification_q=False)
|
|
|
|
for watch in sorted_watches:
|
|
|
|
dates = list(watch.history.keys())
|
|
# Re #521 - Don't bother processing this one if theres less than 2 snapshots, means we never had a change detected.
|
|
if len(dates) < 2:
|
|
continue
|
|
|
|
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)
|
|
watch_label = get_watch_label(datastore, watch)
|
|
timestamp_to = dates[-1]
|
|
timestamp_from = dates[-2]
|
|
guid = generate_watch_guid(watch, timestamp_to)
|
|
# Because we are called via whatever web server, flask should figure out the right path
|
|
diff_link = {'href': url_for('ui.ui_diff.diff_history_page', uuid=watch['uuid'], _external=True)}
|
|
|
|
# Get template and build notification context
|
|
n_body_template = get_rss_template(datastore, watch, rss_content_format,
|
|
RSS_TEMPLATE_HTML_DEFAULT, RSS_TEMPLATE_PLAINTEXT_DEFAULT)
|
|
|
|
n_object = build_notification_context(watch, timestamp_from, timestamp_to,
|
|
watch_label, n_body_template, rss_content_format)
|
|
|
|
# Render notification
|
|
res = render_notification(n_object, notification_service, watch, datastore)
|
|
|
|
# Create and populate feed entry
|
|
fe = fg.add_entry()
|
|
populate_feed_entry(fe, watch, res['body'], guid, timestamp_to, link=diff_link)
|
|
fe.title(title=watch_label) # Override title to not include suffix
|
|
add_watch_categories(fe, watch, datastore)
|
|
|
|
response = make_response(fg.rss_str())
|
|
response.headers.set('Content-Type', 'application/rss+xml;charset=utf-8')
|
|
logger.trace(f"RSS generated in {time.time() - now:.3f}s")
|
|
return response
|