Display item content everywhere

This commit is contained in:
Frédéric Guillot 2013-08-22 21:38:09 -04:00
parent 405086e9b0
commit bf0de86b8a
7 changed files with 52 additions and 26 deletions

View File

@ -5,7 +5,7 @@ require '../vendor/JsonRPC/Client.php';
use JsonRPC\Client; use JsonRPC\Client;
$client = new Client('http://webapps/miniflux/jsonrpc.php'); $client = new Client('http://webapps/miniflux/jsonrpc.php');
$client->authentication('admin', 'Nwjt73kOhC0K2mF'); $client->authentication('admin', 'd4i/Tanb55426mi');
$result = $client->execute('feed.create', array('url' => 'http://bbc.co.uk/news')); $result = $client->execute('feed.create', array('url' => 'http://bbc.co.uk/news'));
var_dump($result); var_dump($result);
@ -24,8 +24,8 @@ print_r($result);
$result = $client->execute('feed.delete', array('feed_id' => $feed_id)); $result = $client->execute('feed.delete', array('feed_id' => $feed_id));
var_dump($result); var_dump($result);
//$result = $client->execute('item.list_unread'); $result = $client->execute('item.list_unread');
//print_r($result); print_r($result);
$result = $client->execute('item.list_unread', array('offset' => 5, 'limit' => 2)); $result = $client->execute('item.list_unread', array('offset' => 5, 'limit' => 2));
print_r($result); print_r($result);

View File

@ -232,7 +232,7 @@ Router\get_action('history', function() {
$nb_items = Model\count_items('read'); $nb_items = Model\count_items('read');
Response\html(Template\layout('history', array( Response\html(Template\layout('history', array(
'items' => Model\get_read_items($offset, Model\get_config_value('items_per_page')), 'items' => Model\get_items('read', $offset, Model\get_config_value('items_per_page')),
'nb_items' => $nb_items, 'nb_items' => $nb_items,
'offset' => $offset, 'offset' => $offset,
'items_per_page' => Model\get_config_value('items_per_page'), 'items_per_page' => Model\get_config_value('items_per_page'),
@ -608,7 +608,7 @@ Router\notfound(function() {
Model\autoflush(); Model\autoflush();
$offset = Request\int_param('offset', 0); $offset = Request\int_param('offset', 0);
$items = Model\get_unread_items($offset, Model\get_config_value('items_per_page')); $items = Model\get_items('unread', $offset, Model\get_config_value('items_per_page'));
$nb_items = Model\count_items('unread');; $nb_items = Model\count_items('unread');;
if ($nb_items === 0) Response\redirect('?action=feeds&nothing_to_read=1'); if ($nb_items === 0) Response\redirect('?action=feeds&nothing_to_read=1');

View File

@ -94,7 +94,7 @@ $server->register('item.bookmark.delete', function ($item_id) {
// Get all unread items // Get all unread items
$server->register('item.list_unread', function ($offset = null, $limit = null) { $server->register('item.list_unread', function ($offset = null, $limit = null) {
return Model\get_unread_items($offset, $limit); return Model\get_items('unread', $offset, $limit);
}); });
// Count all unread items // Count all unread items
@ -106,7 +106,7 @@ $server->register('item.count_unread', function () {
// Get all read items // Get all read items
$server->register('item.list_read', function ($offset = null, $limit = null) { $server->register('item.list_read', function ($offset = null, $limit = null) {
return Model\get_read_items($offset, $limit); return Model\get_items('read', $offset, $limit);
}); });
// Count all read items // Count all read items

View File

@ -402,13 +402,24 @@ function disable_feed($feed_id)
} }
function get_unread_items($offset = null, $limit = null) function get_items($status, $offset = null, $limit = null)
{ {
return \PicoTools\singleton('db') return \PicoTools\singleton('db')
->table('items') ->table('items')
->columns('items.id', 'items.title', 'items.updated', 'items.url', 'items.content', 'items.bookmark', 'items.status', 'items.feed_id', 'feeds.site_url', 'feeds.title AS feed_title') ->columns(
'items.id',
'items.title',
'items.updated',
'items.url',
'items.bookmark',
'items.feed_id',
'items.status',
'items.content',
'feeds.site_url',
'feeds.title AS feed_title'
)
->join('feeds', 'id', 'feed_id') ->join('feeds', 'id', 'feed_id')
->eq('status', 'unread') ->eq('status', $status)
->desc('updated') ->desc('updated')
->offset($offset) ->offset($offset)
->limit($limit) ->limit($limit)
@ -425,20 +436,6 @@ function count_items($status)
} }
function get_read_items($offset = null, $limit = null)
{
return \PicoTools\singleton('db')
->table('items')
->columns('items.id', 'items.title', 'items.updated', 'items.url', 'items.bookmark', 'items.feed_id', 'feeds.site_url', 'feeds.title AS feed_title')
->join('feeds', 'id', 'feed_id')
->eq('status', 'read')
->desc('updated')
->offset($offset)
->limit($limit)
->findAll();
}
function count_bookmarks() function count_bookmarks()
{ {
return \PicoTools\singleton('db') return \PicoTools\singleton('db')
@ -453,7 +450,17 @@ function get_bookmarks($offset = null, $limit = null)
{ {
return \PicoTools\singleton('db') return \PicoTools\singleton('db')
->table('items') ->table('items')
->columns('items.id', 'items.title', 'items.updated', 'items.url', 'items.status', 'items.feed_id', 'feeds.site_url', 'feeds.title AS feed_title') ->columns(
'items.id',
'items.title',
'items.updated',
'items.url',
'items.status',
'items.content',
'items.feed_id',
'feeds.site_url',
'feeds.title AS feed_title'
)
->join('feeds', 'id', 'feed_id') ->join('feeds', 'id', 'feed_id')
->in('status', array('read', 'unread')) ->in('status', array('read', 'unread'))
->eq('bookmark', 1) ->eq('bookmark', 1)
@ -478,7 +485,17 @@ function get_feed_items($feed_id, $offset = null, $limit = null)
{ {
return \PicoTools\singleton('db') return \PicoTools\singleton('db')
->table('items') ->table('items')
->columns('items.id', 'items.title', 'items.updated', 'items.url', 'items.feed_id', 'items.status', 'items.bookmark', 'feeds.site_url') ->columns(
'items.id',
'items.title',
'items.updated',
'items.url',
'items.feed_id',
'items.status',
'items.content',
'items.bookmark',
'feeds.site_url'
)
->join('feeds', 'id', 'feed_id') ->join('feeds', 'id', 'feed_id')
->in('status', array('read', 'unread')) ->in('status', array('read', 'unread'))
->eq('feed_id', $feed_id) ->eq('feed_id', $feed_id)

View File

@ -20,6 +20,9 @@
<?= Helper\escape($item['title']) ?> <?= Helper\escape($item['title']) ?>
</a> </a>
</h2> </h2>
<p class="preview">
<?= Helper\escape(Helper\summary(strip_tags($item['content']), 50, 300)) ?>
</p>
<p> <p>
<a href="?action=feed-items&amp;feed_id=<?= $item['feed_id'] ?>"><?= Helper\escape($item['feed_title']) ?></a> | <a href="?action=feed-items&amp;feed_id=<?= $item['feed_id'] ?>"><?= Helper\escape($item['feed_title']) ?></a> |
<?= dt('%e %B %Y %k:%M', $item['updated']) ?> | <?= dt('%e %B %Y %k:%M', $item['updated']) ?> |

View File

@ -21,6 +21,9 @@
<?= Helper\escape($item['title']) ?> <?= Helper\escape($item['title']) ?>
</a> </a>
</h2> </h2>
<p class="preview">
<?= Helper\escape(Helper\summary(strip_tags($item['content']), 50, 300)) ?>
</p>
<p> <p>
<?= Helper\get_host_from_url($item['url']) ?> | <?= Helper\get_host_from_url($item['url']) ?> |
<?= dt('%e %B %Y %k:%M', $item['updated']) ?> | <?= dt('%e %B %Y %k:%M', $item['updated']) ?> |

View File

@ -22,6 +22,9 @@
<?= Helper\escape($item['title']) ?> <?= Helper\escape($item['title']) ?>
</a> </a>
</h2> </h2>
<p class="preview">
<?= Helper\escape(Helper\summary(strip_tags($item['content']), 50, 300)) ?>
</p>
<p> <p>
<a href="?action=feed-items&amp;feed_id=<?= $item['feed_id'] ?>"><?= Helper\escape($item['feed_title']) ?></a> | <a href="?action=feed-items&amp;feed_id=<?= $item['feed_id'] ?>"><?= Helper\escape($item['feed_title']) ?></a> |