From bf0de86b8a6dc448af93f0c4104e768d5548b066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Thu, 22 Aug 2013 21:38:09 -0400 Subject: [PATCH] Display item content everywhere --- examples/api_client.php | 6 ++--- index.php | 4 +-- jsonrpc.php | 4 +-- model.php | 55 ++++++++++++++++++++++++++-------------- templates/bookmarks.php | 3 +++ templates/feed_items.php | 3 +++ templates/history.php | 3 +++ 7 files changed, 52 insertions(+), 26 deletions(-) diff --git a/examples/api_client.php b/examples/api_client.php index 9f3e0cd..6f41c39 100644 --- a/examples/api_client.php +++ b/examples/api_client.php @@ -5,7 +5,7 @@ require '../vendor/JsonRPC/Client.php'; use JsonRPC\Client; $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')); var_dump($result); @@ -24,8 +24,8 @@ print_r($result); $result = $client->execute('feed.delete', array('feed_id' => $feed_id)); var_dump($result); -//$result = $client->execute('item.list_unread'); -//print_r($result); +$result = $client->execute('item.list_unread'); +print_r($result); $result = $client->execute('item.list_unread', array('offset' => 5, 'limit' => 2)); print_r($result); diff --git a/index.php b/index.php index 3445f4b..0d8ea33 100644 --- a/index.php +++ b/index.php @@ -232,7 +232,7 @@ Router\get_action('history', function() { $nb_items = Model\count_items('read'); 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, 'offset' => $offset, 'items_per_page' => Model\get_config_value('items_per_page'), @@ -608,7 +608,7 @@ Router\notfound(function() { Model\autoflush(); $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');; if ($nb_items === 0) Response\redirect('?action=feeds¬hing_to_read=1'); diff --git a/jsonrpc.php b/jsonrpc.php index 2495e9f..cabbb00 100644 --- a/jsonrpc.php +++ b/jsonrpc.php @@ -94,7 +94,7 @@ $server->register('item.bookmark.delete', function ($item_id) { // Get all unread items $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 @@ -106,7 +106,7 @@ $server->register('item.count_unread', function () { // Get all read items $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 diff --git a/model.php b/model.php index 03782aa..2578a05 100644 --- a/model.php +++ b/model.php @@ -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') ->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') - ->eq('status', 'unread') + ->eq('status', $status) ->desc('updated') ->offset($offset) ->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() { return \PicoTools\singleton('db') @@ -453,7 +450,17 @@ function get_bookmarks($offset = null, $limit = null) { return \PicoTools\singleton('db') ->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') ->in('status', array('read', 'unread')) ->eq('bookmark', 1) @@ -478,7 +485,17 @@ 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.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') ->in('status', array('read', 'unread')) ->eq('feed_id', $feed_id) diff --git a/templates/bookmarks.php b/templates/bookmarks.php index 803607e..e98bfa4 100644 --- a/templates/bookmarks.php +++ b/templates/bookmarks.php @@ -20,6 +20,9 @@ +

+ +

| | diff --git a/templates/feed_items.php b/templates/feed_items.php index d050e2c..05a5a43 100644 --- a/templates/feed_items.php +++ b/templates/feed_items.php @@ -21,6 +21,9 @@ +

+ +

| | diff --git a/templates/history.php b/templates/history.php index a4d160c..aee25d0 100644 --- a/templates/history.php +++ b/templates/history.php @@ -22,6 +22,9 @@ +

+ +

|