Files
FreshRSS/app/views/index/reader.phtml
Alexandre Alapetite 1fe66ad020 Implement Web scraping "HTML + XPath" (#4220)
* More PHP type hints for Fever
Follow-up of https://github.com/FreshRSS/FreshRSS/pull/4201
Related to https://github.com/FreshRSS/FreshRSS/issues/4200

* Detail

* Draft

* Progress

* More draft

* Fix thumbnail PHP type hint
https://github.com/FreshRSS/FreshRSS/issues/4215

* More types

* A bit more

* Refactor FreshRSS_Entry::fromArray

* Progress

* Starts to work

* Categories

* Fonctional

* Layout update

* Fix relative URLs

* Cache system

* Forgotten files

* Remove a debug line

* Automatic form validation of XPath expressions

* data-leave-validation

* Fix reload action

* Simpler examples

* Fix column type for PostgreSQL

* Enforce HTTP encoding

* Readme

* Fix get full content

* target="_blank"

* gitignore

* htmlspecialchars_utf8

* Implement HTML <base>
And fix/revert `xml:base` support in SimplePie e49c578817

* SimplePie upstream PR merged
https://github.com/simplepie/simplepie/pull/723
2022-02-28 20:22:43 +01:00

96 lines
3.8 KiB
PHTML

<?php /** @var FreshRSS_View $this */ ?>
<?php
$this->partial('aside_feed');
$this->partial('nav_menu');
call_user_func($this->callbackBeforeEntries, $this);
$lazyload = FreshRSS_Context::$user_conf->lazyload;
$content_width = FreshRSS_Context::$user_conf->content_width;
?>
<main id="stream" class="reader">
<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++;
ob_flush();
/** @var FreshRSS_Entry */
$item = Minz_ExtensionManager::callHook('entry_before_display', $item);
if ($item == null) {
continue;
}
?><div class="flux<?= !$item->isRead() ? ' not_read' : '' ?><?= $item->isFavorite() ? ' favorite' : '' ?>" id="flux_<?= $item->id() ?>">
<div class="flux_content" dir="auto">
<div class="content <?= $content_width ?>">
<?php
$feed = FreshRSS_CategoryDAO::findFeed($this->categories, $item->feed()); //We most likely already have the feed object in cache
if (empty($feed)) $feed = $item->feed(true);
$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;
}
?>
<?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 } ?>
<a class="website" href="<?= _url('index', 'reader', 'get', 'f_' . $feed->id()) ?>" title="<?= _t('gen.action.filter') ?>"><?php
if (FreshRSS_Context::$user_conf->show_favicons):
?><img class="favicon" src="<?= $feed->favicon() ?>" alt="✇" loading="lazy" /><?php
endif;
?><span><?= $feed->name() ?></span>
</a>
<h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?= $item->link() ?>"><?= $item->title() ?></a></h1>
<div class="author"><?php
$authors = $item->authors();
if (is_array($authors)):
$first = true;
foreach ($authors as $author):
echo $first ? _t('gen.short.by_author') . ' ' : '· ';
$first = false;
?>
<em><a href="<?= Minz_Url::display(Minz_Request::modifiedCurrentRequest(
['search' => 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))])
) ?>"><?= $author ?></a></em>
<?php
endforeach;
echo ' — ';
endif;
?><time datetime="<?= $item->machineReadableDate() ?>"><?= $item->date() ?></time></div><div class="text">
<?= $item->content() ?>
</div></div>
</div>
</div><?php
endforeach;
if ($nbEntries > 0):
call_user_func($this->callbackBeforePagination, $this, $nbEntries, $lastEntry);
$this->renderHelper('stream-footer');
?></main><?php
else:
ob_end_clean(); //Discard the articles headers, as we have no articles
?>
<main id="stream" class="reader">
<div id="new-article">
<a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
</div>
<div class="prompt alert alert-warn">
<h2 class="alert-head"><?= _t('index.feed.empty') ?></h2>
<?php if (FreshRSS_Auth::hasAccess()) { ?>
<p><a href="<?= _url('subscription', 'add') ?>"><?= _t('index.feed.add') ?></a></p>
<?php } ?>
</div>
</main>
<?php endif; ?>