diff options
| author | 2024-12-05 16:19:27 +0100 | |
|---|---|---|
| committer | 2024-12-05 16:19:27 +0100 | |
| commit | 84642037350393625f0a4866ed74f564ef37973b (patch) | |
| tree | bdb64ece059a70cfc61d14abedede3d1d1f88062 /app | |
| parent | 8e41190746c8e51d0c0dd9b52f1d8c5f44f93dde (diff) | |
Rework UI authors (#7054)
Add separators, and mutualise code
fix https://github.com/FreshRSS/FreshRSS/issues/7032
Diffstat (limited to 'app')
| -rw-r--r-- | app/views/helpers/index/article.phtml | 36 | ||||
| -rw-r--r-- | app/views/helpers/index/authors.phtml | 17 | ||||
| -rw-r--r-- | app/views/helpers/index/normal/entry_header.phtml | 13 | ||||
| -rw-r--r-- | app/views/index/normal.phtml | 41 |
4 files changed, 42 insertions, 65 deletions
diff --git a/app/views/helpers/index/article.phtml b/app/views/helpers/index/article.phtml index 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" /><?php endif; ?><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" /><?php endif; ?><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.phtml new file mode 100644 index 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.phtml index 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()) ?>"><?php if (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() ?><?php if ($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><?php endif; ?></a> <?php diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index 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" /><?php endif; ?><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" /><?php endif; ?><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 |
