Add a page to display all items by subscription

This commit is contained in:
Frederic Guillot 2013-07-12 22:16:40 -04:00
parent bb7c2f0e31
commit e2121cc72d
6 changed files with 103 additions and 1 deletions

View File

@ -231,6 +231,26 @@ Router\get_action('history', function() {
});
// Display feed items page
Router\get_action('feed-items', function() {
$feed_id = Request\int_param('feed_id', 0);
$offset = Request\int_param('offset', 0);
$nb_items = Model\count_feed_items($feed_id);
$feed = Model\get_feed($feed_id);
Response\html(Template\layout('feed_items', array(
'feed' => $feed,
'items' => Model\get_feed_items($feed_id, $offset, Model\get_config_value('items_per_page')),
'nb_items' => $nb_items,
'offset' => $offset,
'items_per_page' => Model\get_config_value('items_per_page'),
'menu' => 'feeds',
'title' => '('.$nb_items.') '.$feed['title']
)));
});
// Display bookmarks page
Router\get_action('bookmarks', function() {

View File

@ -1,6 +1,8 @@
<?php
return array(
'No item' => 'Aucun élément',
'items' => 'éléments',
'The following feeds are empty, there is maybe an error: %s' =>
'Les abonnements suivants sont vides, il y a peut-être une erreur : %s',
'Items per page' => 'Nombre d\'éléments par page',

View File

@ -362,6 +362,31 @@ function get_bookmarks($offset = null, $limit = null)
}
function count_feed_items($feed_id)
{
return \PicoTools\singleton('db')
->table('items')
->eq('feed_id', $feed_id)
->in('status', array('read', 'unread'))
->count();
}
function get_feed_items($feed_id, $offset = null, $limit = null)
{
return \PicoTools\singleton('db')
->table('items')
->columns('items.id', 'items.title', 'items.updated', 'items.url', 'items.status', 'items.bookmark', 'feeds.site_url')
->join('feeds', 'id', 'feed_id')
->in('status', array('read', 'unread'))
->eq('feed_id', $feed_id)
->desc('updated')
->offset($offset)
->limit($limit)
->findAll();
}
function get_item($id)
{
return \PicoTools\singleton('db')

View File

@ -9,7 +9,7 @@
<link rel="apple-touch-icon" sizes="72x72" href="./assets/img/touch-icon-ipad.png">
<link rel="apple-touch-icon" sizes="114x114" href="./assets/img/touch-icon-iphone-retina.png">
<link rel="apple-touch-icon" sizes="144x144" href="./assets/img/touch-icon-ipad-retina.png">
<title><?= isset($title) ? $title : 'miniflux' ?></title>
<title><?= isset($title) ? Helper\escape($title) : 'miniflux' ?></title>
<link href="./assets/css/app.css?v<?= filemtime('assets/css/app.css') ?>" rel="stylesheet" media="screen">
<script type="text/javascript" src="./assets/js/app.js?v<?= filemtime('assets/js/app.js') ?>" defer></script>
</head>

54
templates/feed_items.php Normal file
View File

@ -0,0 +1,54 @@
<?php if (empty($items)): ?>
<p class="alert alert-info"><?= t('No item') ?></p>
<?php else: ?>
<div class="page-header">
<h2><?= Helper\escape($feed['title']) ?> (<?= $nb_items ?>)</h2>
</div>
<section class="items" id="listing">
<?php foreach ($items as $item): ?>
<?php $item_id = Model\encode_item_id($item['id']) ?>
<article id="item-<?= $item_id ?>" data-item-id="<?= $item_id ?>">
<h2>
<?= $item['bookmark'] ? '★ ' : '' ?>
<a
href="?action=show&amp;id=<?= $item_id ?>"
data-item-id="<?= $item_id ?>"
id="open-<?= $item_id ?>"
>
<?= Helper\escape($item['title']) ?>
</a>
</h2>
<p>
<?= Helper\get_host_from_url($item['url']) ?> |
<?= dt('%e %B %Y %k:%M', $item['updated']) ?> |
<a
href="<?= $item['url'] ?>"
id="original-<?= $item_id ?>"
rel="noreferrer"
target="_blank"
data-item-id="<?= $item_id ?>"
>
<?= t('original link') ?>
</a>
</p>
</article>
<?php endforeach ?>
<nav id="items-paging">
<?php if ($offset > 0): ?>
<a id="previous-page" href="?action=bookmarks&amp;offset=<?= ($offset - $items_per_page) ?>"> <?= t('Previous page') ?></a>
<?php endif ?>
&nbsp;
<?php if (($nb_items - $offset) > $items_per_page): ?>
<a id="next-page" href="?action=bookmarks&amp;offset=<?= ($offset + $items_per_page) ?>"><?= t('Next page') ?> ⇾</a>
<?php endif ?>
</nav>
</section>
<?php endif ?>

View File

@ -29,6 +29,7 @@
<a href="<?= $feed['site_url'] ?>" rel="noreferrer" target="_blank"><?= Helper\get_host_from_url($feed['site_url']) ?></a> |
<a href="<?= Helper\escape($feed['feed_url']) ?>" rel="noreferrer" target="_blank"><?= t('feed link') ?></a> |
<a href="?action=confirm-remove-feed&amp;feed_id=<?= $feed['id'] ?>"><?= t('remove') ?></a> |
<a href="?action=feed-items&amp;feed_id=<?= $feed['id'] ?>"><?= t('items') ?></a> |
<a href="?action=refresh-feed&amp;feed_id=<?= $feed['id'] ?>" data-feed-id="<?= $feed['id'] ?>" data-action="refresh-feed"><?= t('refresh') ?></a>
</p>
</article>