Add items paging
This commit is contained in:
parent
e4c6f27767
commit
667f3f0773
@ -505,6 +505,12 @@ nav .active a {
|
|||||||
opacity: 0.4;
|
opacity: 0.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#items-paging {
|
||||||
|
margin-top: 50px;
|
||||||
|
font-size: 75%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
/* other pages */
|
/* other pages */
|
||||||
section li {
|
section li {
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
|
@ -176,6 +176,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function open_next_page()
|
||||||
|
{
|
||||||
|
var link = document.getElementById("next-page");
|
||||||
|
if (link) link.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function open_previous_page()
|
||||||
|
{
|
||||||
|
var link = document.getElementById("previous-page");
|
||||||
|
if (link) link.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function remove_item(item_id)
|
function remove_item(item_id)
|
||||||
{
|
{
|
||||||
var item = document.getElementById("item-" + item_id);
|
var item = document.getElementById("item-" + item_id);
|
||||||
@ -396,6 +410,12 @@
|
|||||||
case 102: // f
|
case 102: // f
|
||||||
bookmark_item();
|
bookmark_item();
|
||||||
break;
|
break;
|
||||||
|
case 104: // h
|
||||||
|
open_previous_page();
|
||||||
|
break
|
||||||
|
case 108: // l
|
||||||
|
open_next_page();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
11
common.php
11
common.php
@ -10,11 +10,12 @@ require 'schema.php';
|
|||||||
require 'model.php';
|
require 'model.php';
|
||||||
|
|
||||||
|
|
||||||
const DB_VERSION = 8;
|
const DB_VERSION = 8;
|
||||||
const APP_VERSION = 'master';
|
const APP_VERSION = 'master';
|
||||||
const APP_USERAGENT = 'Miniflux - http://miniflux.net';
|
const APP_USERAGENT = 'Miniflux - http://miniflux.net';
|
||||||
const HTTP_TIMEOUT = 10;
|
const HTTP_TIMEOUT = 10;
|
||||||
const LIMIT_ALL = -1;
|
const LIMIT_ALL = -1;
|
||||||
|
const ITEMS_PER_PAGE = 80;
|
||||||
|
|
||||||
|
|
||||||
function get_db_filename()
|
function get_db_filename()
|
||||||
|
27
index.php
27
index.php
@ -203,20 +203,30 @@ Router\post_action('change-item-status', function() {
|
|||||||
|
|
||||||
Router\get_action('history', function() {
|
Router\get_action('history', function() {
|
||||||
|
|
||||||
|
$offset = Request\int_param('offset', 0);
|
||||||
|
$nb_items = Model\count_items('read');
|
||||||
|
|
||||||
Response\html(Template\layout('history', array(
|
Response\html(Template\layout('history', array(
|
||||||
'items' => Model\get_read_items(),
|
'items' => Model\get_read_items($offset, ITEMS_PER_PAGE),
|
||||||
|
'nb_items' => $nb_items,
|
||||||
|
'offset' => $offset,
|
||||||
'menu' => 'history',
|
'menu' => 'history',
|
||||||
'title' => t('History')
|
'title' => t('History').' ('.$nb_items.')'
|
||||||
)));
|
)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Router\get_action('bookmarks', function() {
|
Router\get_action('bookmarks', function() {
|
||||||
|
|
||||||
|
$offset = Request\int_param('offset', 0);
|
||||||
|
$nb_items = Model\count_bookmarks();
|
||||||
|
|
||||||
Response\html(Template\layout('bookmarks', array(
|
Response\html(Template\layout('bookmarks', array(
|
||||||
'items' => Model\get_bookmarks(),
|
'items' => Model\get_bookmarks($offset, ITEMS_PER_PAGE),
|
||||||
|
'nb_items' => $nb_items,
|
||||||
|
'offset' => $offset,
|
||||||
'menu' => 'bookmarks',
|
'menu' => 'bookmarks',
|
||||||
'title' => t('Bookmarks')
|
'title' => t('Bookmarks').' ('.$nb_items.')'
|
||||||
)));
|
)));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -411,7 +421,7 @@ Router\get_action('config', function() {
|
|||||||
|
|
||||||
Router\post_action('config', function() {
|
Router\post_action('config', function() {
|
||||||
|
|
||||||
$values = Request\values();
|
$values = Request\values() + array('nocontent' => 0);
|
||||||
list($valid, $errors) = Model\validate_config_update($values);
|
list($valid, $errors) = Model\validate_config_update($values);
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
@ -444,8 +454,9 @@ Router\notfound(function() {
|
|||||||
|
|
||||||
Model\autoflush();
|
Model\autoflush();
|
||||||
|
|
||||||
$items = Model\get_unread_items();
|
$offset = Request\int_param('offset', 0);
|
||||||
$nb_items = count($items);
|
$items = Model\get_unread_items($offset, ITEMS_PER_PAGE);
|
||||||
|
$nb_items = Model\count_items('unread');;
|
||||||
|
|
||||||
if ($nb_items === 0) {
|
if ($nb_items === 0) {
|
||||||
|
|
||||||
@ -455,6 +466,8 @@ Router\notfound(function() {
|
|||||||
Response\html(Template\layout('unread_items', array(
|
Response\html(Template\layout('unread_items', array(
|
||||||
'items' => $items,
|
'items' => $items,
|
||||||
'nb_items' => $nb_items,
|
'nb_items' => $nb_items,
|
||||||
|
'nb_unread_items' => $nb_items,
|
||||||
|
'offset' => $offset,
|
||||||
'title' => 'miniflux ('.$nb_items.')',
|
'title' => 'miniflux ('.$nb_items.')',
|
||||||
'menu' => 'unread'
|
'menu' => 'unread'
|
||||||
)));
|
)));
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
'Previous page' => 'Vorheriger Seite',
|
||||||
|
'Next page' => 'Nächster Seite',
|
||||||
'Do not fetch the content of articles' => 'Lade die Inhalte der Feeds nicht',
|
'Do not fetch the content of articles' => 'Lade die Inhalte der Feeds nicht',
|
||||||
'Remove automatically read items' => 'Lösche gelesene Artikel automatisch',
|
'Remove automatically read items' => 'Lösche gelesene Artikel automatisch',
|
||||||
'Never' => 'Nie',
|
'Never' => 'Nie',
|
||||||
@ -51,7 +53,7 @@ return array(
|
|||||||
'No history' => 'Kein Verlauf',
|
'No history' => 'Kein Verlauf',
|
||||||
'mark as unread' => 'als ungelesen markieren',
|
'mark as unread' => 'als ungelesen markieren',
|
||||||
'History' => 'Verlauf',
|
'History' => 'Verlauf',
|
||||||
'flush these items' => 'diese Einträge löschen',
|
'flush all items' => 'diese Einträge löschen',
|
||||||
'Item not found' => 'Eintrag nicht gefunden',
|
'Item not found' => 'Eintrag nicht gefunden',
|
||||||
'Unread items' => 'Ungelesene Einträge',
|
'Unread items' => 'Ungelesene Einträge',
|
||||||
'Next' => 'Weiter',
|
'Next' => 'Weiter',
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
'Previous page' => 'Page précédente',
|
||||||
|
'Next page' => 'Page suivante',
|
||||||
'Do not fetch the content of articles' => 'Ne pas récupérer le contenu des articles',
|
'Do not fetch the content of articles' => 'Ne pas récupérer le contenu des articles',
|
||||||
'Remove automatically read items' => 'Supprimer automatiquement les éléments lus',
|
'Remove automatically read items' => 'Supprimer automatiquement les éléments lus',
|
||||||
'Never' => 'Jamais',
|
'Never' => 'Jamais',
|
||||||
@ -51,7 +53,7 @@ return array(
|
|||||||
'No history' => 'Aucun historique',
|
'No history' => 'Aucun historique',
|
||||||
'mark as unread' => 'marquer comme non lu',
|
'mark as unread' => 'marquer comme non lu',
|
||||||
'History' => 'Historique',
|
'History' => 'Historique',
|
||||||
'flush these items' => 'supprimer ces éléments',
|
'flush all items' => 'supprimer tous les éléments',
|
||||||
'Item not found' => 'Élément introuvable',
|
'Item not found' => 'Élément introuvable',
|
||||||
'Unread items' => 'Éléments non lus',
|
'Unread items' => 'Éléments non lus',
|
||||||
'Next' => 'Suivant',
|
'Next' => 'Suivant',
|
||||||
|
30
model.php
30
model.php
@ -249,7 +249,7 @@ function remove_feed($feed_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_unread_items()
|
function get_unread_items($offset = null, $limit = null)
|
||||||
{
|
{
|
||||||
return \PicoTools\singleton('db')
|
return \PicoTools\singleton('db')
|
||||||
->table('items')
|
->table('items')
|
||||||
@ -257,11 +257,22 @@ function get_unread_items()
|
|||||||
->join('feeds', 'id', 'feed_id')
|
->join('feeds', 'id', 'feed_id')
|
||||||
->eq('status', 'unread')
|
->eq('status', 'unread')
|
||||||
->desc('updated')
|
->desc('updated')
|
||||||
|
->offset($offset)
|
||||||
|
->limit($limit)
|
||||||
->findAll();
|
->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_read_items()
|
function count_items($status)
|
||||||
|
{
|
||||||
|
return \PicoTools\singleton('db')
|
||||||
|
->table('items')
|
||||||
|
->eq('status', $status)
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_read_items($offset = null, $limit = null)
|
||||||
{
|
{
|
||||||
return \PicoTools\singleton('db')
|
return \PicoTools\singleton('db')
|
||||||
->table('items')
|
->table('items')
|
||||||
@ -269,11 +280,22 @@ function get_read_items()
|
|||||||
->join('feeds', 'id', 'feed_id')
|
->join('feeds', 'id', 'feed_id')
|
||||||
->eq('status', 'read')
|
->eq('status', 'read')
|
||||||
->desc('updated')
|
->desc('updated')
|
||||||
|
->offset($offset)
|
||||||
|
->limit($limit)
|
||||||
->findAll();
|
->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_bookmarks()
|
function count_bookmarks()
|
||||||
|
{
|
||||||
|
return \PicoTools\singleton('db')
|
||||||
|
->table('items')
|
||||||
|
->eq('bookmark', 1)
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_bookmarks($offset = null, $limit = null)
|
||||||
{
|
{
|
||||||
return \PicoTools\singleton('db')
|
return \PicoTools\singleton('db')
|
||||||
->table('items')
|
->table('items')
|
||||||
@ -282,6 +304,8 @@ function get_bookmarks()
|
|||||||
->in('status', array('read', 'unread'))
|
->in('status', array('read', 'unread'))
|
||||||
->eq('bookmark', 1)
|
->eq('bookmark', 1)
|
||||||
->desc('updated')
|
->desc('updated')
|
||||||
|
->offset($offset)
|
||||||
|
->limit($limit)
|
||||||
->findAll();
|
->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<a class="logo" href="?">mini<span>flux</span></a>
|
<a class="logo" href="?">mini<span>flux</span></a>
|
||||||
<ul>
|
<ul>
|
||||||
<li <?= isset($menu) && $menu === 'unread' ? 'class="active"' : '' ?>>
|
<li <?= isset($menu) && $menu === 'unread' ? 'class="active"' : '' ?>>
|
||||||
<a href="?action=default"><?= t('unread') ?> <span id="nav-counter"><?= isset($nb_items) ? '('.$nb_items.')' : '' ?></span></a>
|
<a href="?action=default"><?= t('unread') ?> <span id="nav-counter"><?= isset($nb_unread_items) ? '('.$nb_unread_items.')' : '' ?></span></a>
|
||||||
</li>
|
</li>
|
||||||
<li <?= isset($menu) && $menu === 'bookmarks' ? 'class="active"' : '' ?>>
|
<li <?= isset($menu) && $menu === 'bookmarks' ? 'class="active"' : '' ?>>
|
||||||
<a href="?action=bookmarks"><?= t('bookmarks') ?></a>
|
<a href="?action=bookmarks"><?= t('bookmarks') ?></a>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2><?= t('Bookmarks') ?></h2>
|
<h2><?= t('Bookmarks') ?> (<?= $nb_items ?>)</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section class="items">
|
<section class="items">
|
||||||
@ -36,6 +36,17 @@
|
|||||||
</p>
|
</p>
|
||||||
</article>
|
</article>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
||||||
|
<nav id="items-paging">
|
||||||
|
<?php if ($offset > 0): ?>
|
||||||
|
<a id="previous-page" href="?action=bookmarks&offset=<?= ($offset - ITEMS_PER_PAGE) ?>">⇽ <?= t('Previous page') ?></a>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php if (($nb_items - $offset) > ITEMS_PER_PAGE): ?>
|
||||||
|
<a id="next-page" href="?action=bookmarks&offset=<?= ($offset + ITEMS_PER_PAGE) ?>"><?= t('Next page') ?> ⇾</a>
|
||||||
|
<?php endif ?>
|
||||||
|
</nav>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
@ -48,6 +48,8 @@
|
|||||||
<li><?= t('Open original link') ?> = <strong>v</strong></li>
|
<li><?= t('Open original link') ?> = <strong>v</strong></li>
|
||||||
<li><?= t('Open item') ?> = <strong>o</strong></li>
|
<li><?= t('Open item') ?> = <strong>o</strong></li>
|
||||||
<li><?= t('Bookmark item') ?> = <strong>f</strong></li>
|
<li><?= t('Bookmark item') ?> = <strong>f</strong></li>
|
||||||
|
<li><?= t('Previous page') ?> = <strong>h</strong></li>
|
||||||
|
<li><?= t('Next page') ?> = <strong>l</strong></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="alert alert-normal">
|
<div class="alert alert-normal">
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
<?php if (empty($items)): ?>
|
<?php if (empty($items)): ?>
|
||||||
<p class="alert alert-info"><?= t('No history') ?></p>
|
<p class="alert alert-info"><?= t('No history') ?></p>
|
||||||
|
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2><?= t('History') ?></h2>
|
<h2><?= t('History') ?> (<?= $nb_items ?>)</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="?action=confirm-flush-history"><?= t('flush these items') ?></a></li>
|
<li><a href="?action=confirm-flush-history"><?= t('flush all items') ?></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -45,6 +44,17 @@
|
|||||||
</p>
|
</p>
|
||||||
</article>
|
</article>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
||||||
|
<nav id="items-paging">
|
||||||
|
<?php if ($offset > 0): ?>
|
||||||
|
<a id="previous-page" href="?action=history&offset=<?= ($offset - ITEMS_PER_PAGE) ?>">⇽ <?= t('Previous page') ?></a>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php if (($nb_items - $offset) > ITEMS_PER_PAGE): ?>
|
||||||
|
<a id="next-page" href="?action=history&offset=<?= ($offset + ITEMS_PER_PAGE) ?>"><?= t('Next page') ?> ⇾</a>
|
||||||
|
<?php endif ?>
|
||||||
|
</nav>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
@ -51,6 +51,17 @@
|
|||||||
</p>
|
</p>
|
||||||
</article>
|
</article>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
||||||
|
<nav id="items-paging">
|
||||||
|
<?php if ($offset > 0): ?>
|
||||||
|
<a id="previous-page" href="?action=unread&offset=<?= ($offset - ITEMS_PER_PAGE) ?>">⇽ <?= t('Previous page') ?></a>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php if (($nb_items - $offset) > ITEMS_PER_PAGE): ?>
|
||||||
|
<a id="next-page" href="?action=unread&offset=<?= ($offset + ITEMS_PER_PAGE) ?>"><?= t('Next page') ?> ⇾</a>
|
||||||
|
<?php endif ?>
|
||||||
|
</nav>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
20
vendor/PicoDb/Table.php
vendored
20
vendor/PicoDb/Table.php
vendored
@ -248,28 +248,40 @@ class Table
|
|||||||
|
|
||||||
public function asc($column)
|
public function asc($column)
|
||||||
{
|
{
|
||||||
$this->sql_order = ' ORDER BY '.$this->db->escapeIdentifier($column).' ASC';
|
if ($this->sql_order === '') {
|
||||||
|
$this->sql_order = ' ORDER BY '.$this->db->escapeIdentifier($column).' ASC';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->sql_order .= ', '.$this->db->escapeIdentifier($column).' ASC';
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function desc($column)
|
public function desc($column)
|
||||||
{
|
{
|
||||||
$this->sql_order = ' ORDER BY '.$this->db->escapeIdentifier($column).' DESC';
|
if ($this->sql_order === '') {
|
||||||
|
$this->sql_order = ' ORDER BY '.$this->db->escapeIdentifier($column).' DESC';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->sql_order .= ', '.$this->db->escapeIdentifier($column).' DESC';
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function limit($value)
|
public function limit($value)
|
||||||
{
|
{
|
||||||
$this->sql_limit = ' LIMIT '.(int) $value;
|
if (! is_null($value)) $this->sql_limit = ' LIMIT '.(int) $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function offset($value)
|
public function offset($value)
|
||||||
{
|
{
|
||||||
$this->sql_offset = ' OFFSET '.(int) $value;
|
if (! is_null($value)) $this->sql_offset = ' OFFSET '.(int) $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user