示例#1
0
use PicoFarad\Session;
use PicoFarad\Template;
// Display unread items
Router\get_action('unread', function () {
    Model\Item\autoflush_read();
    Model\Item\autoflush_unread();
    $order = Request\param('order', 'updated');
    $direction = Request\param('direction', Model\Config\get('items_sorting_direction'));
    $offset = Request\int_param('offset', 0);
    $items = Model\Item\get_all('unread', $offset, Model\Config\get('items_per_page'), $order, $direction);
    $nb_items = Model\Item\count_by_status('unread');
    if ($nb_items === 0) {
        $action = Model\Config\get('redirect_nothing_to_read');
        Response\redirect('?action=' . $action . '&nothing_to_read=1');
    }
    Response\html(Template\layout('unread_items', array('favicons' => Model\Feed\get_item_favicons($items), 'original_marks_read' => Model\Config\get('original_marks_read'), 'order' => $order, 'direction' => $direction, 'display_mode' => Model\Config\get('items_display_mode'), 'items' => $items, 'nb_items' => $nb_items, 'nb_unread_items' => $nb_items, 'offset' => $offset, 'items_per_page' => Model\Config\get('items_per_page'), 'title' => 'Miniflux (' . $nb_items . ')', 'menu' => 'unread')));
});
// Show item
Router\get_action('show', function () {
    $id = Request\param('id');
    $menu = Request\param('menu');
    $item = Model\Item\get($id);
    $feed = Model\Feed\get($item['feed_id']);
    Model\Item\set_read($id);
    $item['status'] = 'read';
    switch ($menu) {
        case 'unread':
            $nav = Model\Item\get_nav($item);
            break;
        case 'history':
            $nav = Model\Item\get_nav($item, array('read'));
示例#2
0
    $menu = Request\param('menu', 'unread');
    $source = Request\param('source', 'unread');
    $offset = Request\int_param('offset', 0);
    $feed_id = Request\int_param('feed_id', 0);
    Model\Item\set_bookmark_value($id, Request\int_param('value'));
    if ($source === 'show') {
        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();