mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-05-15 02:33:51 -04:00
Closes FreshRSS/FreshRSS#6522. Refresh of FreshRSS/FreshRSS#6590 by @sgzmd, which has been stalled with merge conflicts since 2024. All original commits are preserved as-is in the history (authorship intact); this PR adds a merge with current `edge` plus minor fixes. ## Summary Adds a user setting `show_title_unread` (default `true`, so existing behavior is preserved) that hides the unread article counter from both the tab title and the favicon overlay. A single toggle controls both, matching the request in #6522. ## Screenshots Toggle in display settings: <img width="320" height="127" alt="Display settings with new toggle" src="https://github.com/user-attachments/assets/fc78f825-161d-4b47-9b85-08e39554a4b1" /> Tab title and favicon when **enabled** (current behavior): <img width="253" height="42" alt="Tab title and favicon with unread counter" src="https://github.com/user-attachments/assets/57387600-72e0-4b22-b059-04b5bfea673a" /> Tab title and favicon when **disabled** (new behavior): <img width="254" height="40" alt="Tab title and favicon without unread counter" src="https://github.com/user-attachments/assets/93ac7997-dd4e-49bc-ab4a-74e4f0d2db1b" /> ## Changes on top of #6590 - Resolved merge conflicts with current `edge` (controllers, model, view, `config.default.php`, ~25 i18n files, plus the `zh-tw` -> `zh-TW` rename). - Replaced Czech text mistakenly placed in `de/conf.php` with an English `// TODO` marker so a German speaker can translate later. - Renamed JS context key `show_unread_favicon` -> `show_title_unread` to match the backend property and avoid a confusing dual-name for one setting. - Removed an unused duplicate of `show_title_unread` from `config.default.php` (the setting is read via `userConf()`, never `systemConf()`). - Gated the dynamic title rewrite in `incUnreadsFeed` (`p/scripts/main.js`) on the setting. Without this, marking an article read while the setting was off would re-add the `(N)` prefix to the tab title. - Escaped a stray apostrophe in the Occitan translation that broke parsing. - `make fix-all` re-sorted i18n keys and added `// TODO` placeholders for `fi`, `pt-PT`, `uk` (untranslated by the original PR). ## Test plan - [x] `make test-all` passes (620/620 PHPUnit, phpstan, phpcs, eslint, stylelint, markdownlint clean; `bin/typos` failed locally with a binary arch mismatch on macOS arm64 - unrelated to this change). - [x] Manually tested on a real instance: default behavior unchanged; toggling the setting hides both the tab title `(N) ` prefix and the favicon overlay; toggling back restores both; marking articles read while the setting is off does not bring the counter back; opening and closing an article preserves the user's choice. * Make showing the number of unread items in the title configurable. * Proposed approach to passing show_unread_favicon setting down to client-side code * Fixes and refactoring * Updating default config for the user. When user's config wasn't initialised we are copying it from `config-user.default.php` - if `show_title_unread` is not there, it is assumed to be false, whereas in `config.default.php` it's true by default. This results in inconsistency until user changes the field for the first time in Config->Display. * Adding translations. * fix: gate JS title rewrite + drop dead system config entry The original PR added show_title_unread to both config-user.default.php (read by userConf, the right place) and config.default.php (read by systemConf, never used here). Drop the system-level entry. Also: incUnreadsFeed dynamically rewrites document.title when articles are marked read/unread. That code path was not gated by the setting, so toggling the setting off and then marking an article read would re-add the (N) prefix to the tab title. Skip the document.title / prevTitle write when context.show_title_unread is false. * fix: drop README pollution from local make fix-all `make fix-all` regenerated the README translation tables on macOS, where the case-insensitive filesystem and an untracked local `app/i18n/nb/` directory caused the generator to emit `zh-tw` (lowercase) and an `nb` entry. Reset both README files to upstream/edge so CI can regenerate them cleanly. * fix: restore zh-TW/conf.php from edge (case-insensitive FS damage) The macOS case-insensitive filesystem caused the merge to overwrite upstream/edge's properly-translated zh-TW/conf.php with the older zh-tw/conf.php content from the PR side, regressing translation coverage from 94% to 71%. Reset the file to edge's content and re-add the show_title_unread Traditional Chinese translation. --------- Co-authored-by: sgzmd <sigizmund@gmail.com> Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> Co-authored-by: Bjørn A. Andersen <polybjorn@users.noreply.github.com>
102 lines
5.1 KiB
PHTML
102 lines
5.1 KiB
PHTML
<?php
|
|
declare(strict_types=1);
|
|
/** @var FreshRSS_View $this */
|
|
$mark = FreshRSS_Context::userConf()->mark_when;
|
|
$s = FreshRSS_Context::userConf()->shortcuts;
|
|
$extData = Minz_ExtensionManager::callHook(Minz_HookType::JsVars, []);
|
|
$canView = FreshRSS_Auth::hasAccess() || FreshRSS_Context::systemConf()->allow_anonymous;
|
|
echo json_encode([
|
|
'context' => [
|
|
'anonymous' => !FreshRSS_Auth::hasAccess(),
|
|
'admin' => FreshRSS_Auth::hasAccess('admin'),
|
|
'suppress_csp_warning' => FreshRSS_Context::systemConf()->suppress_csp_warning,
|
|
'auto_remove_article' => !!FreshRSS_Context::isAutoRemoveAvailable(),
|
|
'hide_posts' => !(FreshRSS_Context::userConf()->display_posts || Minz_Request::actionName() === 'reader'),
|
|
'display_order' => Minz_Request::paramString('order') ?: FreshRSS_Context::userConf()->sort_order,
|
|
'sort' => FreshRSS_Context::$sort,
|
|
'display_categories' => FreshRSS_Context::userConf()->display_categories,
|
|
'show_title_unread' => FreshRSS_Context::userConf()->show_title_unread,
|
|
'auto_mark_article' => !!$mark['article'],
|
|
'auto_mark_site' => !!$mark['site'],
|
|
'auto_mark_scroll' => !!$mark['scroll'],
|
|
'auto_mark_focus' => !!$mark['focus'],
|
|
'auto_load_more' => FreshRSS_Context::userConf()->auto_load_more && FreshRSS_Context::$sort !== 'rand',
|
|
'auto_actualize_feeds' => Minz_Session::paramBoolean('actualize_feeds'),
|
|
'nb_parallel_refresh' => max(1, FreshRSS_Context::systemConf()->nb_parallel_refresh),
|
|
'does_lazyload' => FreshRSS_Context::userConf()->lazyload && !Minz_Request::is('index', 'reader'), // TODO: currently no lazy-loading is being done in reader view
|
|
'sides_close_article' => !!FreshRSS_Context::userConf()->sides_close_article,
|
|
'sidebar_hidden_by_default' => !!FreshRSS_Context::userConf()->sidebar_hidden_by_default,
|
|
'sticky_post' => !!FreshRSS_Context::isStickyPostEnabled(),
|
|
'html5_enable_notif' => FreshRSS_Context::userConf()->html5_enable_notif,
|
|
'html5_notif_timeout' => FreshRSS_Context::userConf()->html5_notif_timeout,
|
|
'closeNotification' => [
|
|
'good' => FreshRSS_Context::userConf()->good_notification_timeout * 1000,
|
|
'bad' => FreshRSS_Context::userConf()->bad_notification_timeout * 1000,
|
|
'mouseLeave' => 3000,
|
|
],
|
|
'auth_type' => FreshRSS_Context::systemConf()->auth_type,
|
|
'current_view' => Minz_Request::actionName(),
|
|
'csrf' => FreshRSS_Auth::csrfToken(),
|
|
'mtime' => [
|
|
'extra.js' => @filemtime(PUBLIC_PATH . '/scripts/extra.js'),
|
|
'feed.js' => @filemtime(PUBLIC_PATH . '/scripts/feed.js'),
|
|
],
|
|
'send_referrer_allowlist' => $canView ? FreshRSS_Context::userConf()->send_referrer_allowlist : [],
|
|
'max_favicon_upload_size' => FreshRSS_Context::systemConf()->limits['max_favicon_upload_size'],
|
|
'version' => FRESHRSS_VERSION,
|
|
],
|
|
'shortcuts' => [
|
|
'actualize' => $s['actualize'] ?? '',
|
|
'mark_read' => $s['mark_read'] ?? '',
|
|
'mark_favorite' => $s['mark_favorite'] ?? '',
|
|
'go_website' => $s['go_website'] ?? '',
|
|
'prev_entry' => $s['prev_entry'] ?? '',
|
|
'next_entry' => $s['next_entry'] ?? '',
|
|
'next_unread_entry' => $s['next_unread_entry'] ?? '',
|
|
'skip_prev_entry' => $s['skip_prev_entry'] ?? '',
|
|
'skip_next_entry' => $s['skip_next_entry'] ?? '',
|
|
'first_entry' => $s['first_entry'] ?? '',
|
|
'last_entry' => $s['last_entry'] ?? '',
|
|
'collapse_entry' => $s['collapse_entry'] ?? '',
|
|
'load_more' => $s['load_more'] ?? '',
|
|
'mylabels' => $s['mylabels'] ?? '',
|
|
'auto_share' => $s['auto_share'] ?? '',
|
|
'focus_search' => $s['focus_search'] ?? '',
|
|
'user_filter' => $s['user_filter'] ?? '',
|
|
'help' => $s['help'] ?? '',
|
|
'close_menus' => $s['close_menus'] ?? '',
|
|
'normal_view' => $s['normal_view'] ?? '',
|
|
'global_view' => $s['global_view'] ?? '',
|
|
'reading_view' => $s['reading_view'] ?? '',
|
|
'rss_view' => $s['rss_view'] ?? '',
|
|
'toggle_media' => $s['toggle_media'] ?? '',
|
|
'toggle_aside' => $s['toggle_aside'] ?? '',
|
|
],
|
|
'urls' => [
|
|
'index' => _url('index', 'index'),
|
|
'login' => Minz_Url::display(['c' => 'auth', 'a' => 'login'], 'php'),
|
|
'logout' => Minz_Url::display(['c' => 'auth', 'a' => 'logout'], 'php'),
|
|
'help' => FRESHRSS_WIKI,
|
|
'shortcuts' => Minz_Url::display(['c' => 'configure', 'a' => 'shortcut'], 'php'),
|
|
],
|
|
'i18n' => [
|
|
'confirmation_default' => _t('gen.js.confirm_action'),
|
|
'confirm_exit_slider' => _t('gen.js.confirm_exit_slider'),
|
|
'notif_title_articles' => _t('gen.js.feedback.title_new_articles'),
|
|
'notif_body_new_articles' => _t('gen.js.feedback.body_new_articles'),
|
|
'notif_body_unread_articles' => _t('gen.js.feedback.body_unread_articles'),
|
|
'notif_request_failed' => _t('gen.js.feedback.request_failed'),
|
|
'category_empty' => _t('gen.js.category_empty'),
|
|
'labels_empty' => _t('gen.js.labels_empty'),
|
|
'favicon_size_exceeded' => _t('feedback.sub.feed.favicon.too_large', format_bytes(FreshRSS_Context::systemConf()->limits['max_favicon_upload_size'])),
|
|
'language' => FreshRSS_Context::userConf()->language,
|
|
'unsafe_csp_header' => _t('gen.js.unsafe_csp_header'),
|
|
],
|
|
'icons' => [
|
|
'read' => rawurlencode(_i('read')),
|
|
'unread' => rawurlencode(_i('unread')),
|
|
'spinner' => '../themes/icons/spinner.svg',
|
|
],
|
|
'extensions' => $extData,
|
|
], JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP);
|