A free, self-hostable news aggregator…
Rework UI authors (#7054)
Alexandre Alapetite846420373503
diff --git a/app/views/helpers/index/article.phtml b/app/views/helpers/index/article.phtmlindex 0a9c75bcd..54a8cbf56 100644--- a/app/views/helpers/index/article.phtml+++ b/app/views/helpers/index/article.phtml@@ -77,18 +77,13 @@<img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?phpendif; ?><span><?= $feed->name() ?></span></a></span><?php }- $authors = $entry->authors();- if (!empty($authors) && is_array($authors)) { ?>- <div class="author">- <?= _t('gen.short.by_author') ?>- <?php- foreach ($authors as $author) {- $href = Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:"' . htmlspecialchars_decode($author, ENT_QUOTES) . '"']));- ?>- <a href="<?= $href ?>" title="<?= _t('gen.action.filter') ?>"><?= $author ?></a>- <?php } ?>- </div>- <?php } ?>+ if (!empty($entry->authors())) {+ $this->renderHelper('index/authors');+ if ($this->feed === null || $this->entry === null) {+ throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan+ }+ }+ ?></div><div class="item date"><time datetime="<?= $entry->machineReadableDate() ?>"><?= $entry->date() ?></time>@@ -120,20 +115,9 @@<?php if (FreshRSS_Context::userConf()->show_favicons): ?><img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?phpendif; ?><span><?= $feed->name() ?></span></a></div>- <?php } ?>- <div class="author"><?php- $authors = $entry->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>+ <?php }+ $this->renderHelper('index/authors');+ ?><div class="date"><time datetime="<?= $entry->machineReadableDate() ?>"><?= $entry->date() ?></time></div>diff --git a/app/views/helpers/index/authors.phtml b/app/views/helpers/index/authors.phtmlnew file mode 100644index 000000000..27cba9452--- /dev/null+++ b/app/views/helpers/index/authors.phtml@@ -0,0 +1,17 @@+<?php+ declare(strict_types=1);+ /** @var FreshRSS_View $this */+ if ($this->entry === null) {+ return;+ }+?>+<div class="author"><?= _t('gen.short.by_author') ?>+<?php+ $first = true;+ foreach ($this->entry->authors() as $author) {+ $href = Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:"' . htmlspecialchars_decode($author, ENT_QUOTES) . '"']));+ ?><?= $first ? '' : ' · ' ?><a href="<?= $href ?>" title="<?= _t('gen.action.filter') ?>"><?= $author ?></a><?php+ $first = false;+ }+?>+</div>diff --git a/app/views/helpers/index/normal/entry_header.phtml b/app/views/helpers/index/normal/entry_header.phtmlindex 7aa752835..459e4d180 100644--- a/app/views/helpers/index/normal/entry_header.phtml+++ b/app/views/helpers/index/normal/entry_header.phtml@@ -15,7 +15,7 @@if ($this->feed === null || $this->entry === null) {return;}-?><ul class="horizontal-list flux_header website<?= $topline_website ?>" data-website-name="<?= $this->feed->name() ?>" data-article-authors="<?= implode(', ', $this->entry->authors()) ?>"><?php+?><ul class="horizontal-list flux_header website<?= $topline_website ?>" data-website-name="<?= $this->feed->name() ?>" data-article-authors="<?= implode(' · ', $this->entry->authors()) ?>"><?phpif (FreshRSS_Auth::hasAccess()) {if ($topline_read) {?><li class="item manage"><?php@@ -59,16 +59,7 @@<li class="item titleAuthorSummaryDate"><a target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>" class="item-element title<?= (($topline_thumbnail !== 'none') || $topline_summary) ? ' multiline' : '' ?>" dir="auto"><?= $this->entry->title() ?><?phpif ($topline_display_authors):- ?><span class="author"><?php- $authors = $this->entry->authors();- if (is_array($authors)) {- $first = true;- foreach ($authors as $author) {- echo $first ? $author : ', ' . $author;- $first = false;- }- }- ?></span><?php+ ?> <span class="author"><?= implode(' · ', $this->entry->authors()) ?></span><?phpendif;?></a><?phpdiff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtmlindex 3923d774b..4ebcb28a6 100644--- a/app/views/index/normal.phtml+++ b/app/views/index/normal.phtml@@ -119,22 +119,14 @@ $today = @strtotime('today');<img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?phpendif; ?><span><?= $this->feed->name() ?></span></a></div>- <?php+ <?php }+ if (!empty($this->entry->authors())) {+ $this->renderHelper('index/authors');+ if ($this->feed === null || $this->entry === null) {+ throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan+ }}-- $authors = $this->entry->authors();- if (!empty($authors) && is_array($authors)) {?>- <div class="author">- <?= _t('gen.short.by_author') ?>- <?php- foreach ($authors as $author) {- $href = Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:"' . htmlspecialchars_decode($author, ENT_QUOTES) . '"']));- ?>- <a href="<?= $href ?>" title="<?= _t('gen.action.filter') ?>"><?= $author ?></a>- <?php } ?>- </div>- <?php } ?><div class="date"><?= $this->entry->date() ?></div></div><?php } ?>@@ -158,21 +150,14 @@ $today = @strtotime('today');<img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" /><?phpendif; ?><span><?= $this->feed->name() ?></span></a></div>- <?php- }- $authors = $this->entry->authors();- if (!empty($authors) && is_array($authors)) {+ <?php }+ if (!empty($this->entry->authors())) {+ $this->renderHelper('index/authors');+ if ($this->feed === null || $this->entry === null) {+ throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan+ }+ }?>- <div class="author">- <?= _t('gen.short.by_author') ?>- <?php- foreach ($authors as $author) {- $href = Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:"' . htmlspecialchars_decode($author, ENT_QUOTES) . '"']));- ?>- <a href="<?= $href ?>" title="<?= _t('gen.action.filter') ?>"><?= $author ?></a>- <?php } ?>- </div>- <?php } ?><div class="date"><?= $this->entry->date() ?></div></div><?php