From 7aa3d9f87309620b54dc9ff5f726dc22d1e6ea0c Mon Sep 17 00:00:00 2001 From: maTh <1645099+math-GH@users.noreply.github.com> Date: Mon, 1 Jul 2024 01:13:54 +0200 Subject: New: Sharing articles from the article title line (#6395) * enable option * Update entry_header.phtml * frss.css * fix print sharing * Light refactoring * fix --------- Co-authored-by: Alexandre Alapetite --- app/Controllers/configureController.php | 1 + app/Models/UserConfiguration.php | 1 + app/views/configure/display.phtml | 4 ++- app/views/helpers/index/normal/entry_bottom.phtml | 34 +------------------- app/views/helpers/index/normal/entry_header.phtml | 13 ++++++++ .../helpers/index/normal/entry_share_menu.phtml | 37 ++++++++++++++++++++++ config-user.default.php | 1 + p/scripts/main.js | 23 +++++++++++--- p/themes/base-theme/frss.css | 2 ++ p/themes/base-theme/frss.rtl.css | 2 ++ 10 files changed, 79 insertions(+), 39 deletions(-) create mode 100644 app/views/helpers/index/normal/entry_share_menu.phtml diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 770787021..2ccc6fe42 100644 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -52,6 +52,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController { FreshRSS_Context::userConf()->content_width = Minz_Request::paramString('content_width') ?: 'thin'; FreshRSS_Context::userConf()->topline_read = Minz_Request::paramBoolean('topline_read'); FreshRSS_Context::userConf()->topline_favorite = Minz_Request::paramBoolean('topline_favorite'); + FreshRSS_Context::userConf()->topline_sharing = Minz_Request::paramBoolean('topline_sharing'); FreshRSS_Context::userConf()->topline_date = Minz_Request::paramBoolean('topline_date'); FreshRSS_Context::userConf()->topline_link = Minz_Request::paramBoolean('topline_link'); FreshRSS_Context::userConf()->topline_website = Minz_Request::paramString('topline_website'); diff --git a/app/Models/UserConfiguration.php b/app/Models/UserConfiguration.php index 938c2ed27..b46df4d78 100644 --- a/app/Models/UserConfiguration.php +++ b/app/Models/UserConfiguration.php @@ -61,6 +61,7 @@ declare(strict_types=1); * @property bool $topline_date * @property bool $topline_display_authors * @property bool $topline_favorite + * @property bool $topline_sharing * @property bool $topline_link * @property bool $topline_read * @property bool $topline_summary diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index ce140c439..9584f37ea 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -212,7 +212,9 @@ data-leave-validation="topline_favorite ?>" /> - + topline_sharing ? ' checked="checked"' : '' ?> + data-leave-validation="topline_sharing ?>" /> topline_summary ? 'checked="checked"' : '' ?> data-leave-validation="topline_summary ?>" /> diff --git a/app/views/helpers/index/normal/entry_bottom.phtml b/app/views/helpers/index/normal/entry_bottom.phtml index 21bd1d355..f8cf0eda3 100644 --- a/app/views/helpers/index/normal/entry_bottom.phtml +++ b/app/views/helpers/index/normal/entry_bottom.phtml @@ -76,39 +76,7 @@ - - + renderHelper('index/normal/entry_share_menu'); ?> diff --git a/app/views/helpers/index/normal/entry_header.phtml b/app/views/helpers/index/normal/entry_header.phtml index e4befb346..bcd4a7c98 100644 --- a/app/views/helpers/index/normal/entry_header.phtml +++ b/app/views/helpers/index/normal/entry_header.phtml @@ -3,6 +3,7 @@ /** @var FreshRSS_View $this */ $topline_read = FreshRSS_Context::userConf()->topline_read; $topline_favorite = FreshRSS_Context::userConf()->topline_favorite; + $topline_sharing = FreshRSS_Context::userConf()->topline_sharing; $topline_website = FreshRSS_Context::userConf()->topline_website; $topline_thumbnail = FreshRSS_Context::userConf()->topline_thumbnail; $topline_summary = FreshRSS_Context::userConf()->topline_summary; @@ -72,6 +73,18 @@ endif; ?>   + +
  • + +
  • + diff --git a/app/views/helpers/index/normal/entry_share_menu.phtml b/app/views/helpers/index/normal/entry_share_menu.phtml new file mode 100644 index 000000000..62d1f5244 --- /dev/null +++ b/app/views/helpers/index/normal/entry_share_menu.phtml @@ -0,0 +1,37 @@ + + diff --git a/config-user.default.php b/config-user.default.php index b62689873..af48f61b8 100644 --- a/config-user.default.php +++ b/config-user.default.php @@ -102,6 +102,7 @@ return array ( 'topline_read' => true, 'topline_favorite' => true, + 'topline_sharing' => false, 'topline_website' => 'full', 'topline_thumbnail' => 'none', 'topline_summary' => false, diff --git a/p/scripts/main.js b/p/scripts/main.js index 2bc0f5337..5690eb532 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -402,6 +402,13 @@ function mark_favorite(div) { const freshrssOpenArticleEvent = document.createEvent('Event'); freshrssOpenArticleEvent.initEvent('freshrss:openArticle', true, true); +function loadLazyImages(rootElement) { + rootElement.querySelectorAll('img[data-original], iframe[data-original]').forEach(function (el) { + el.src = el.getAttribute('data-original'); + el.removeAttribute('data-original'); + }); +} + function toggleContent(new_active, old_active, skipping) { // If skipping, move current without activating or marking as read if (!new_active) { @@ -409,10 +416,7 @@ function toggleContent(new_active, old_active, skipping) { } if (context.does_lazyload && !skipping) { - new_active.querySelectorAll('img[data-original], iframe[data-original]').forEach(function (el) { - el.src = el.getAttribute('data-original'); - el.removeAttribute('data-original'); - }); + loadLazyImages(new_active); } if (old_active !== new_active) { @@ -1101,7 +1105,16 @@ function init_stream(stream) { for (let i = 0; i < document.styleSheets.length; i++) { tmp_window.document.writeln(''); } - tmp_window.document.writeln(el.closest('.flux_content').querySelector('.content').innerHTML); + const flux_content = el.closest('.flux_content'); + let content_el = null; + if (flux_content) { + content_el = el.closest('.flux_content').querySelector('.content'); + } + if (content_el === null) { + content_el = el.closest('.flux').querySelector('.flux_content .content'); + } + loadLazyImages(content_el); + tmp_window.document.writeln(content_el.innerHTML); tmp_window.document.close(); tmp_window.focus(); tmp_window.print(); diff --git a/p/themes/base-theme/frss.css b/p/themes/base-theme/frss.css index 77393bd42..18da5a4ce 100644 --- a/p/themes/base-theme/frss.css +++ b/p/themes/base-theme/frss.css @@ -1257,12 +1257,14 @@ input[type="search"] { .flux .flux_header .item.manage .item-element, .flux .flux_header .item.website .item-element, +.flux .flux_header .item.share .dropdown-toggle, .flux .flux_header .item.link .item-element { padding-left: var(--frss-padding-flux-items); padding-right: var(--frss-padding-flux-items); } .flux .item.manage, +.flux .flux_header > .item.share, .flux .item.link { width: calc(1rem + 2 * var(--frss-padding-flux-items)); } diff --git a/p/themes/base-theme/frss.rtl.css b/p/themes/base-theme/frss.rtl.css index b73d8c2eb..a79684f81 100644 --- a/p/themes/base-theme/frss.rtl.css +++ b/p/themes/base-theme/frss.rtl.css @@ -1257,12 +1257,14 @@ input[type="search"] { .flux .flux_header .item.manage .item-element, .flux .flux_header .item.website .item-element, +.flux .flux_header .item.share .dropdown-toggle, .flux .flux_header .item.link .item-element { padding-right: var(--frss-padding-flux-items); padding-left: var(--frss-padding-flux-items); } .flux .item.manage, +.flux .flux_header > .item.share, .flux .item.link { width: calc(1rem + 2 * var(--frss-padding-flux-items)); } -- cgit v1.2.3