From 39cc1c11ec596176e842cc98e6a54337e3c04d7e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 26 Feb 2024 09:01:03 +0100 Subject: New feature: shareable user query (#6052) * New feature: shareable user query Share the output of a user query by RSS / HTML / OPML with other people through unique URLs. Replaces the global admin token, which was the only option (but unsafe) to share RSS outputs with other people. Also add a new HTML output for people without an RSS reader. fix https://github.com/FreshRSS/FreshRSS/issues/3066#issuecomment-648977890 fix https://github.com/FreshRSS/FreshRSS/issues/3178#issuecomment-769435504 * Remove unused method * Fix token saving * Implement HTML view * Update i18n for master token * Revert i18n get_favorite * Fix missing i18n for user queries from before this PR * Remove irrelevant tests * Add link to RSS version * Fix getGet * Fix getState * Fix getSearch * Alternative getSearch * Default getOrder * Explicit default state * Fix test * Add OPML sharing * Remove many redundant SQL queries from original implementation of user queries * Fix article tags * Use default user settings * Prepare public search * Fixes * Allow user search on article tags * Implement user search * Revert filter bug * Revert wrong SQL left outer join change * Implement checkboxes * Safe check of OPML * Fix label * Remove RSS button to favour new sharing method That sharing button was using a global admin token * First version of HTTP 304 * Disallow some recusrivity fix https://github.com/FreshRSS/FreshRSS/issues/6086 * Draft of nav * Minor httpConditional * Add support for offset for pagination * Fix offset pagination * Fix explicit order ASC * Add documentation * Help links i18n * Note about deprecated master token * Typo * Doc about format --- app/views/index/html.phtml | 32 +++++++ app/views/index/normal.phtml | 102 +++-------------------- app/views/index/reader.phtml | 194 ++----------------------------------------- app/views/index/rss.phtml | 6 +- 4 files changed, 54 insertions(+), 280 deletions(-) create mode 100644 app/views/index/html.phtml (limited to 'app/views/index') diff --git a/app/views/index/html.phtml b/app/views/index/html.phtml new file mode 100644 index 000000000..149bebee4 --- /dev/null +++ b/app/views/index/html.phtml @@ -0,0 +1,32 @@ +content_width = 'large'; + FreshRSS_Context::userConf()->show_author_date = FreshRSS_UserConfiguration::default()->show_author_date; + FreshRSS_Context::userConf()->show_favicons = FreshRSS_UserConfiguration::default()->show_favicons; + FreshRSS_Context::userConf()->show_feed_name = FreshRSS_UserConfiguration::default()->show_feed_name; + FreshRSS_Context::userConf()->show_tags = FreshRSS_UserConfiguration::default()->show_tags; + FreshRSS_Context::userConf()->show_tags_max = FreshRSS_UserConfiguration::default()->show_tags_max; +?> +renderHelper('htmlPagination'); ?> +
+

+ · + + + +

+ entries as $entry): + $this->entry = $entry; + $this->feed = $this->feeds[$entry->feedId()] ?? + FreshRSS_Category::findFeed($this->categories, $entry->feedId()) ?? + FreshRSS_Feed::default(); + ?> +
+ renderHelper('index/article'); ?> +
+ +
+renderHelper('htmlPagination'); ?> diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index 26e38dc91..9596ebc89 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -11,23 +11,18 @@ call_user_func($this->callbackBeforeEntries, $this); $display_today = true; $display_yesterday = true; $display_others = true; -$hidePosts = !FreshRSS_Context::userConf()->display_posts; -$lazyload = FreshRSS_Context::userConf()->lazyload; -$content_width = FreshRSS_Context::userConf()->content_width; -$MAX_TAGS_DISPLAYED = (int)FreshRSS_Context::userConf()->show_tags_max; $useKeepUnreadImportant = !FreshRSS_Context::isImportant() && !FreshRSS_Context::isFeed(); $today = @strtotime('today'); ?> -
+

entries as $item): $lastEntry = $item; $nbEntries++; @@ -40,8 +35,8 @@ $today = @strtotime('today'); $this->entry = $item; // We most likely already have the feed object in cache, otherwise make a request - $this->feed = FreshRSS_CategoryDAO::findFeed($this->categories, $this->entry->feedId()) ?? - $this->entry->feed() ?? FreshRSS_Feed::example(); + $this->feed = FreshRSS_Category::findFeed($this->categories, $this->entry->feedId()) ?? + $this->entry->feed() ?? FreshRSS_Feed::default(); if ($display_today && $this->entry->isDay(FreshRSS_Days::TODAY, $today)) { ?>
" data-priority="feed->priority() ?>">renderHelper('index/normal/entry_header'); - if ($this->feed === null) { - throw new FreshRSS_Context_Exception('Feed not initialised!'); - } - - $tags = null; - $firstTags = array(); - $remainingTags = array(); - - if (FreshRSS_Context::userConf()->show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b') { - $tags = $this->entry->tags(); - if (!empty($tags)) { - if ($MAX_TAGS_DISPLAYED > 0) { - $firstTags = array_slice($tags, 0, $MAX_TAGS_DISPLAYED); - $remainingTags = array_slice($tags, $MAX_TAGS_DISPLAYED); - } else { - $firstTags = $tags; - } - } - } ?>
-
+
show_feed_name === 't') { ?> - show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') { ?> -
-
  • #
  • -
  • - -
  • - -
-
- show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') { + $this->renderHelper('index/tags'); } ?>

entry->title() ?>

show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?> @@ -163,8 +111,8 @@ $today = @strtotime('today');
-
entry->content(true)) : $this->entry->content(true); +
lazyload && !FreshRSS_Context::userConf()->display_posts ? lazyimg($this->entry->content(true)) : $this->entry->content(true) ?>
show_author_date === 'f' || FreshRSS_Context::userConf()->show_author_date === 'b'; @@ -201,36 +149,10 @@ $today = @strtotime('today');
-
-
  • #
  • -
  • - -
  • - -
-
- + if ($display_tags) { + $this->renderHelper('index/tags'); + } + ?> diff --git a/app/views/index/reader.phtml b/app/views/index/reader.phtml index af51933cf..ccca9e50c 100644 --- a/app/views/index/reader.phtml +++ b/app/views/index/reader.phtml @@ -9,8 +9,6 @@ if (!Minz_Request::paramBoolean('ajax')) { call_user_func($this->callbackBeforeEntries, $this); $lazyload = FreshRSS_Context::userConf()->lazyload; -$content_width = FreshRSS_Context::userConf()->content_width; -$MAX_TAGS_DISPLAYED = (int)FreshRSS_Context::userConf()->show_tags_max; ?>

@@ -19,197 +17,21 @@ $MAX_TAGS_DISPLAYED = (int)FreshRSS_Context::userConf()->show_tags_max;
entries as $item): - $lastEntry = $item; + foreach ($this->entries as $entry): + $lastEntry = $entry; $nbEntries++; ob_flush(); /** @var FreshRSS_Entry */ - $item = Minz_ExtensionManager::callHook('entry_before_display', $item); - if ($item == null) { + $entry = Minz_ExtensionManager::callHook('entry_before_display', $entry); + if ($entry == null) { continue; } - $this->entry = $item; - - $tags = null; - $firstTags = array(); - $remainingTags = array(); - - if (FreshRSS_Context::userConf()->show_tags == 'h' || FreshRSS_Context::userConf()->show_tags == 'f' || FreshRSS_Context::userConf()->show_tags == 'b') { - $tags = $this->entry->tags(); - if (!empty($tags)) { - if ($MAX_TAGS_DISPLAYED > 0) { - $firstTags = array_slice($tags, 0, $MAX_TAGS_DISPLAYED); - $remainingTags = array_slice($tags, $MAX_TAGS_DISPLAYED); - } else { - $firstTags = $tags; - } - } - } + $this->entry = $entry; //We most likely already have the feed object in cache, otherwise make a request - $feed = FreshRSS_CategoryDAO::findFeed($this->categories, $item->feedId()) ?? $item->feed() ?? FreshRSS_Feed::example(); - ?>
-
- -
-
- 'entry', 'a' => 'bookmark', 'params' => array('id' => $item->id())); - if ($item->isFavorite()) { - $favoriteUrl['params']['is_favorite'] = 0; - } - $readUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('id' => $item->id())); - if ($item->isRead()) { - $readUrl['params']['is_read'] = 0; - } - ?> -
- - isRead() ? 'read' : 'unread') ?> - isFavorite() ? 'starred' : 'non-starred') ?> - - show_feed_name === 't') { ?> - - show_favicons): ?> - ✇name() ?> - -
- - show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') { ?> -
-
  • #
  • -
  • - -
  • - -
-
- - -

title() ?>

- show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?> -
- show_feed_name === 'a') { ?> - - -
authors(); - if (is_array($authors)) { - foreach ($authors as $author) { - ?> - - - - -
-
- -
-
- -
- -
- content(true) ?> -
- show_author_date === 'f' || FreshRSS_Context::userConf()->show_author_date === 'b'; - $display_tags = FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b'; - - if ($display_authors_date || $display_tags) { - ?> -
- -
- show_feed_name === 'a') { ?> - - -
authors(); - if (is_array($authors)) { - foreach ($authors as $author) { - ?> - - - - -
-
- -
-
- -
-
  • #
  • -
  • - -
  • - -
-
- -
- -
-
+ $this->feed = FreshRSS_Category::findFeed($this->categories, $entry->feedId()) ?? $entry->feed() ?? FreshRSS_Feed::default(); + ?>
+ renderHelper('index/article'); ?>
<?= $this->rss_title ?> - internal_rendering ? htmlspecialchars($this->rss_url, ENT_NOQUOTES, 'UTF-8') : Minz_Url::display('', 'html', true) ?> + html_url ?> rss_title) ?> GMT - + entries as $item) { if (!$this->internal_rendering) { /** @var FreshRSS_Entry */ -- cgit v1.2.3