aboutsummaryrefslogtreecommitdiff
path: root/app/views/index
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-02-26 09:01:03 +0100
committerGravatar GitHub <noreply@github.com> 2024-02-26 09:01:03 +0100
commit39cc1c11ec596176e842cc98e6a54337e3c04d7e (patch)
treedab89beb80268acb5e4bd58dfc55297bd30a8486 /app/views/index
parent25166c218be4e1ce1cb098de274a231b623d527e (diff)
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
Diffstat (limited to 'app/views/index')
-rw-r--r--app/views/index/html.phtml32
-rw-r--r--app/views/index/normal.phtml102
-rw-r--r--app/views/index/reader.phtml194
-rw-r--r--app/views/index/rss.phtml6
4 files changed, 54 insertions, 280 deletions
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 @@
+<?php
+ declare(strict_types=1);
+ /** @var FreshRSS_View $this */
+ // Override some layout preferences for the public API output
+ FreshRSS_Context::userConf()->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;
+?>
+<?php $this->renderHelper('htmlPagination'); ?>
+<main id="stream" class="reader api">
+ <h2>
+ <a href="<?= $this->html_url ?>"><?= FreshRSS_View::title() ?></a> ·
+ <a class="view-rss" href="<?= $this->rss_url ?>" title="<?= _t('index.menu.rss_view') ?>">
+ <?= _i('rss') ?>
+ </a>
+ </h2>
+ <?php
+ foreach ($this->entries as $entry):
+ $this->entry = $entry;
+ $this->feed = $this->feeds[$entry->feedId()] ??
+ FreshRSS_Category::findFeed($this->categories, $entry->feedId()) ??
+ FreshRSS_Feed::default();
+ ?>
+ <div class="flux">
+ <?php $this->renderHelper('index/article'); ?>
+ </div>
+ <?php endforeach; ?>
+</main>
+<?php $this->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');
?>
-<main id="stream" class="normal<?= $hidePosts ? ' hide_posts' : '' ?>">
+<main id="stream" class="normal<?= FreshRSS_Context::userConf()->display_posts ? '' : ' hide_posts' ?>">
<h1 class="title_hidden"><?= _t('conf.reading.view.normal') ?></h1>
<div id="new-article">
<a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
</div><?php
$lastEntry = null;
$nbEntries = 0;
- /** @var FreshRSS_Entry */
foreach ($this->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)) {
?><div class="day" id="day_today"><?php
@@ -74,27 +69,8 @@ $today = @strtotime('today');
?>" data-priority="<?= $this->feed->priority()
?>"><?php
$this->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;
- }
- }
- }
?><article class="flux_content" dir="auto">
- <div class="content <?= $content_width ?>">
+ <div class="content <?= FreshRSS_Context::userConf()->content_width ?>">
<header>
<?php if (FreshRSS_Context::userConf()->show_feed_name === 't') { ?>
<div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
@@ -103,36 +79,8 @@ $today = @strtotime('today');
endif; ?><span><?= $this->feed->name() ?></span></a>
</div>
<?php } ?>
- <?php if (FreshRSS_Context::userConf()->show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') { ?>
- <div class="tags">
- <?php
- if (!empty($tags)) {
- ?><?= _i('tag') ?><ul class="list-tags"><?php
- foreach ($firstTags as $tag) {
- ?><li class="item tag"><a class="link-tag" href="<?= _url('index', 'index', 'search', '#' . str_replace(' ', '+', htmlspecialchars_decode($tag, ENT_QUOTES))) ?>" title="<?= _t('gen.action.filter') ?>">#<?= $tag ?></a></li><?php
- }
-
- if (!empty($remainingTags)) { // more than 7 tags: show dropdown menu ?>
- <li class="item tag">
- <div class="dropdown">
- <div id="dropdown-tags2-<?= $this->entry->id() ?>" class="dropdown-target"></div>
- <a class="dropdown-toggle" href="#dropdown-tags2-<?= $this->entry->id() ?>"><?= _i('down') ?></a>
- <ul class="dropdown-menu">
- <li class="dropdown-header"><?= _t('index.tag.related') ?></li>
- <?php
- foreach ($remainingTags as $tag) {
- ?><li class="item"><a href="<?= _url('index', 'index', 'search', '#' . str_replace(' ', '+', htmlspecialchars_decode($tag, ENT_QUOTES))) ?>" title="<?= _t('gen.action.filter') ?>"><?= $tag ?></a></li><?php
- } ?>
- </ul>
- <a class="dropdown-close" href="#close">❌</a>
- </div>
- </li>
- <?php
- } ?>
- </ul><?php
- } ?>
- </div>
- <?php
+ <?php if (FreshRSS_Context::userConf()->show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') {
+ $this->renderHelper('index/tags');
} ?>
<h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?= $this->entry->link() ?>" title="<?= _t('conf.shortcut.see_on_website')?>"><?= $this->entry->title() ?></a></h1>
<?php if (FreshRSS_Context::userConf()->show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?>
@@ -163,8 +111,8 @@ $today = @strtotime('today');
</div>
<?php } ?>
</header>
- <div class="text"><?php
- echo $lazyload && $hidePosts ? lazyimg($this->entry->content(true)) : $this->entry->content(true);
+ <div class="text"><?=
+ FreshRSS_Context::userConf()->lazyload && !FreshRSS_Context::userConf()->display_posts ? lazyimg($this->entry->content(true)) : $this->entry->content(true)
?></div>
<?php
$display_authors_date = FreshRSS_Context::userConf()->show_author_date === 'f' || FreshRSS_Context::userConf()->show_author_date === 'b';
@@ -201,36 +149,10 @@ $today = @strtotime('today');
</div>
<?php
}
- if ($display_tags) { ?>
- <div class="tags">
- <?php
- if (!empty($tags)) {
- ?><?= _i('tag') ?><ul class="list-tags"><?php
- foreach ($firstTags as $tag) {
- ?><li class="item tag"><a class="link-tag" href="<?= _url('index', 'index', 'search', '#' . str_replace(' ', '+', htmlspecialchars_decode($tag, ENT_QUOTES))) ?>" title="<?= _t('gen.action.filter') ?>">#<?= $tag ?></a></li><?php
- }
- if (!empty($remainingTags)) { ?>
- <li class="item tag">
- <div class="dropdown">
- <div id="dropdown-tags3-<?= $this->entry->id() ?>" class="dropdown-target"></div>
- <a class="dropdown-toggle" href="#dropdown-tags3-<?= $this->entry->id() ?>"><?= _i('down') ?></a>
- <ul class="dropdown-menu">
- <li class="dropdown-header"><?= _t('index.tag.related') ?></li>
- <?php
- foreach ($remainingTags as $tag) {
- ?><li class="item"><a href="<?= _url('index', 'index', 'search', '#' . str_replace(' ', '+', htmlspecialchars_decode($tag, ENT_QUOTES))) ?>" title="<?= _t('gen.action.filter') ?>"><?= $tag ?></a></li><?php
- } ?>
- </ul>
- <a class="dropdown-close" href="#close">❌</a>
- </div>
- </li>
- <?php
- } ?>
- </ul><?php
- } ?>
- </div>
- <?php
- } ?>
+ if ($display_tags) {
+ $this->renderHelper('index/tags');
+ }
+ ?>
</footer>
<?php
} ?>
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;
?>
<main id="stream" class="reader">
<h1 class="title_hidden"><?= _t('conf.reading.view.reader') ?></h1>
@@ -19,197 +17,21 @@ $MAX_TAGS_DISPLAYED = (int)FreshRSS_Context::userConf()->show_tags_max;
</div><?php
$lastEntry = null;
$nbEntries = 0;
- /** @var FreshRSS_Entry */
- foreach ($this->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();
- ?><div class="flux<?= !$item->isRead() ? ' not_read' : '' ?><?= $item->isFavorite() ? ' favorite' : '' ?>" id="flux_<?= $item->id() ?>" data-priority="<?= $feed->priority() ?>">
- <article class="flux_content" dir="auto">
-
- <div class="content <?= $content_width ?>">
- <header>
- <?php
- $favoriteUrl = array('c' => '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;
- }
- ?>
- <div class="article-header-topline">
- <?php if (FreshRSS_Auth::hasAccess()) { ?>
- <a class="read" href="<?= Minz_Url::display($readUrl) ?>" title="<?= _t('conf.shortcut.mark_read') ?>"><?= _i($item->isRead() ? 'read' : 'unread') ?></a>
- <a class="bookmark" href="<?= Minz_Url::display($favoriteUrl) ?>" title="<?= _t('conf.shortcut.mark_favorite') ?>"><?= _i($item->isFavorite() ? 'starred' : 'non-starred') ?></a>
- <?php } ?>
- <?php if (FreshRSS_Context::userConf()->show_feed_name === 't') { ?>
- <a class="website" href="<?= _url('index', 'reader', 'get', 'f_' . $feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
- <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
- <img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?php
- endif; ?><span><?= $feed->name() ?></span></a>
- <?php } ?>
- </div>
-
- <?php if (FreshRSS_Context::userConf()->show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') { ?>
- <div class="tags">
- <?php
- if (!empty($tags)) {
- ?><?= _i('tag') ?><ul class="list-tags"><?php
- foreach ($firstTags as $tag) {
- ?><li class="item tag"><a class="link-tag" href="<?= _url('index', 'index', 'search', '#' . str_replace(' ', '+', htmlspecialchars_decode($tag, ENT_QUOTES))) ?>" title="<?= _t('gen.action.filter') ?>">#<?= $tag ?></a></li><?php
- }
-
- if (!empty($remainingTags)) { // more than 7 tags: show dropdown menu ?>
- <li class="item tag">
- <div class="dropdown">
- <div id="dropdown-tags-<?= $this->entry->id() ?>" class="dropdown-target"></div>
- <a class="dropdown-toggle" href="#dropdown-tags-<?= $this->entry->id() ?>"><?= _i('down') ?></a>
- <ul class="dropdown-menu">
- <li class="dropdown-header"><?= _t('index.tag.related') ?></li>
- <?php
- foreach ($remainingTags as $tag) {
- ?><li class="item"><a href="<?= _url('index', 'index', 'search', '#' . str_replace(' ', '+', htmlspecialchars_decode($tag, ENT_QUOTES))) ?>" title="<?= _t('gen.action.filter') ?>"><?= $tag ?></a></li><?php
- } ?>
- </ul>
- <a class="dropdown-close" href="#close">❌</a>
- </div>
- </li>
- <?php
- } ?>
- </ul><?php
- } ?>
- </div>
- <?php } ?>
-
- <h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?= $item->link() ?>"><?= $item->title() ?></a></h1>
- <?php if (FreshRSS_Context::userConf()->show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?>
- <div class="subtitle">
- <?php if (FreshRSS_Context::userConf()->show_feed_name === 'a') { ?>
- <div class="website"><a href="<?= _url('index', 'reader', 'get', 'f_' . $feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
- <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
- <img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?php
- endif; ?><span><?= $feed->name() ?></span></a></div>
- <?php } ?>
- <div class="author"><?php
- $authors = $item->authors();
- if (is_array($authors)) {
- foreach ($authors as $author) {
- ?>
- <a href="<?= Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))])) ?>">
- <?= $author ?>
- </a>
- <?php
- }
- }
- ?>
- </div>
- <div class="date">
- <time datetime="<?= $item->machineReadableDate() ?>"><?= $item->date() ?></time>
- </div>
- </div>
- <?php } ?>
- </header>
-
- <div class="text">
- <?= $item->content(true) ?>
- </div>
- <?php
- $display_authors_date = FreshRSS_Context::userConf()->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) {
- ?>
- <footer>
- <?php if ($display_authors_date) { ?>
- <div class="subtitle">
- <?php if (FreshRSS_Context::userConf()->show_feed_name === 'a') { ?>
- <div class="website"><a href="<?= _url('index', 'reader', 'get', 'f_' . $feed->id()) ?>" title="<?= _t('gen.action.filter') ?>">
- <?php if (FreshRSS_Context::userConf()->show_favicons): ?>
- <img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?php
- endif; ?><span><?= $feed->name() ?></span></a></div>
- <?php } ?>
- <div class="author"><?php
- $authors = $item->authors();
- if (is_array($authors)) {
- foreach ($authors as $author) {
- ?>
- <a href="<?= Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))])) ?>">
- <?= $author ?>
- </a>
- <?php
- }
- }
- ?>
- </div>
- <div class="date">
- <time datetime="<?= $item->machineReadableDate() ?>"><?= $item->date() ?></time>
- </div>
- </div>
- <?php
- }
-
- if ($display_tags) { ?>
- <div class="tags">
- <?php
- if (!empty($tags)) {
- ?><?= _i('tag') ?><ul class="list-tags"><?php
- foreach ($firstTags as $tag) {
- ?><li class="item tag"><a class="link-tag" href="<?= _url('index', 'index', 'search', '#' . str_replace(' ', '+', htmlspecialchars_decode($tag, ENT_QUOTES))) ?>" title="<?= _t('gen.action.filter') ?>">#<?= $tag ?></a></li><?php
- }
-
- if (!empty($remainingTags)) { // more than 7 tags: show dropdown menu ?>
- <li class="item tag">
- <div class="dropdown">
- <div id="dropdown-tags2-<?= $this->entry->id() ?>" class="dropdown-target"></div>
- <a class="dropdown-toggle" href="#dropdown-tags2-<?= $this->entry->id() ?>"><?= _i('down') ?></a>
- <ul class="dropdown-menu">
- <li class="dropdown-header"><?= _t('index.tag.related') ?></li>
- <?php
- foreach ($remainingTags as $tag) {
- ?><li class="item"><a href="<?= _url('index', 'index', 'search', '#' . str_replace(' ', '+', htmlspecialchars_decode($tag, ENT_QUOTES))) ?>" title="<?= _t('gen.action.filter') ?>"><?= $tag ?></a></li><?php
- } ?>
- </ul>
- <a class="dropdown-close" href="#close">❌</a>
- </div>
- </li>
- <?php
- } ?>
- </ul><?php
- } ?>
- </div>
- <?php } ?>
- </footer>
- <?php
- } ?>
- </div>
- </article>
+ $this->feed = FreshRSS_Category::findFeed($this->categories, $entry->feedId()) ?? $entry->feed() ?? FreshRSS_Feed::default();
+ ?><div class="flux<?= !$entry->isRead() ? ' not_read' : '' ?><?= $entry->isFavorite() ? ' favorite' : '' ?>" id="flux_<?= $entry->id() ?>" data-priority="<?= $this->feed->priority() ?>">
+ <?php $this->renderHelper('index/article'); ?>
</div><?php
endforeach;
diff --git a/app/views/index/rss.phtml b/app/views/index/rss.phtml
index 1c036abd2..80768c5b7 100644
--- a/app/views/index/rss.phtml
+++ b/app/views/index/rss.phtml
@@ -8,14 +8,12 @@
>
<channel>
<title><?= $this->rss_title ?></title>
- <link><?= $this->internal_rendering ? htmlspecialchars($this->rss_url, ENT_NOQUOTES, 'UTF-8') : Minz_Url::display('', 'html', true) ?></link>
+ <link><?= $this->html_url ?></link>
<description><?= _t('index.feed.rss_of', $this->rss_title) ?></description>
<pubDate><?= date('D, d M Y H:i:s O') ?></pubDate>
<lastBuildDate><?= gmdate('D, d M Y H:i:s') ?> GMT</lastBuildDate>
- <atom:link href="<?= $this->internal_rendering ? htmlspecialchars($this->rss_url, ENT_COMPAT, 'UTF-8') :
- Minz_Url::display($this->rss_url, 'html', true) ?>" rel="self" type="application/rss+xml" />
+ <atom:link href="<?= $this->rss_url ?>" rel="self" type="application/rss+xml" />
<?php
-/** @var FreshRSS_Entry */
foreach ($this->entries as $item) {
if (!$this->internal_rendering) {
/** @var FreshRSS_Entry */