Response\Redirect('?action=show&menu=' . $menu . '&id=' . $id); } Response\Redirect('?action=' . $menu . '&offset=' . $offset . '&feed_id=' . $feed_id . '#item-' . $id); }); // Display bookmarks page Router\get_action('bookmarks', function () { $offset = Request\int_param('offset', 0); $nb_items = Model\Item\count_bookmarks(); $items = Model\Item\get_bookmarks($offset, Model\Config\get('items_per_page')); Response\html(Template\layout('bookmarks', array('favicons' => Model\Feed\get_item_favicons($items), 'original_marks_read' => Model\Config\get('original_marks_read'), 'order' => '', 'direction' => '', 'display_mode' => Model\Config\get('items_display_mode'), 'items' => $items, 'nb_items' => $nb_items, 'offset' => $offset, 'items_per_page' => Model\Config\get('items_per_page'), 'nothing_to_read' => Request\int_param('nothing_to_read'), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'bookmarks', 'title' => t('Bookmarks') . ' (' . $nb_items . ')'))); }); // Display bookmark feeds Router\get_action('bookmark-feed', function () { // Check token $feed_token = Model\Config\get('feed_token'); $request_token = Request\param('token'); if ($feed_token !== $request_token) { Response\text('Access Forbidden', 403); } // Build Feed $writer = new Atom(); $writer->title = t('Bookmarks') . ' - Miniflux'; $writer->site_url = Helper\get_current_base_url(); $writer->feed_url = $writer->site_url . '?action=bookmark-feed&token=' . urlencode($feed_token); $bookmarks = Model\Item\get_bookmarks(); foreach ($bookmarks as $bookmark) { $article = Model\Item\get($bookmark['id']); $writer->items[] = array('id' => $article['id'], 'title' => $article['title'], 'updated' => $article['updated'], 'url' => $article['url'], 'content' => $article['content']); } Response\xml($writer->execute()); });
}); // 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\Item\count_by_feed($feed_id); $feed = Model\Feed\get($feed_id); $order = Request\param('order', 'updated'); $direction = Request\param('direction', Model\Config\get('items_sorting_direction')); $items = Model\Item\get_all_by_feed($feed_id, $offset, Model\Config\get('items_per_page'), $order, $direction); Response\html(Template\layout('feed_items', array('favicons' => Model\Feed\get_favicons(array($feed['id'])), 'original_marks_read' => Model\Config\get('original_marks_read'), 'order' => $order, 'direction' => $direction, 'display_mode' => Model\Config\get('items_display_mode'), 'feed' => $feed, 'items' => $items, 'nb_items' => $nb_items, 'nb_unread_items' => Model\Item\count_by_status('unread'), 'offset' => $offset, 'items_per_page' => Model\Config\get('items_per_page'), 'menu' => 'feed-items', 'title' => '(' . $nb_items . ') ' . $feed['title']))); }); // Ajax call to download an item (fetch the full content from the original website) Router\post_action('download-item', function () { $id = Request\param('id'); $item = Model\Item\get($id); $feed = Model\Feed\get($item['feed_id']); $download = Model\Item\download_content_id($id); $download['content'] = Model\Proxy\addProxyToTags($download['content'], $item['url'], Model\Config\get('image_proxy'), $feed['cloak_referrer']); Response\json($download); }); // Ajax call change item status Router\post_action('change-item-status', function () { $id = Request\param('id'); Response\json(array('item_id' => $id, 'status' => Model\Item\switch_status($id))); }); // Ajax call to mark item read Router\post_action('mark-item-read', function () { Model\Item\set_read(Request\param('id')); Response\json(array('Ok')); });
}); // Count all unread items $server->register('item.count_unread', function () { return Model\Item\count_by_status('unread'); }); // Get all read items $server->register('item.list_read', function ($offset = null, $limit = null) { return Model\Item\get_all_by_status('read', array(), $offset, $limit); }); // Count all read items $server->register('item.count_read', function () { return Model\Item\count_by_status('read'); }); // Get one item $server->register('item.info', function ($item_id) { return Model\Item\get($item_id); }); // Delete an item $server->register('item.delete', function ($item_id) { return Model\Item\set_removed($item_id); }); // Mark item as read $server->register('item.mark_as_read', function ($item_id) { return Model\Item\set_read($item_id); }); // Mark item as unread $server->register('item.mark_as_unread', function ($item_id) { return Model\Item\set_unread($item_id); }); // Change the status of list of items $server->register('item.set_list_status', function ($status, array $items) {