diff --git a/assets/css/app.css b/assets/css/app.css index e9646f8..8ae6cd6 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -449,11 +449,6 @@ nav .active a { max-width: 100%; } -.infos { - padding-bottom: 20px; - color: #ccc; -} - .item h1 a { font-size: 2.1em; text-decoration: none; @@ -495,6 +490,19 @@ nav .active a { display: block; } +.infos { + padding-bottom: 20px; + color: #ddd; +} + +.item .infos a { + color: #ddd; +} + +.item-status-read { + opacity: 0.4; +} + /* other pages */ section li { margin-left: 15px; diff --git a/assets/js/app.js b/assets/js/app.js index 3cca31c..344c86c 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -45,12 +45,25 @@ function mark_as_unread(item_id) { var request = new XMLHttpRequest(); - request.open("POST", "?action=mark-item-unread&id=" + item_id, true); request.send(); } + function bookmark_item() + { + var item = document.getElementById("current-item"); + + if (item) { + + var item_id = item.getAttribute("data-item-id"); + var redirect = item.getAttribute("data-item-page"); + + window.location = "?action=bookmark&value=1&id=" + item_id + "&redirect=" + redirect; + } + } + + function show_refresh_icon(feed_id) { var container = document.getElementById("loading-feed-" + feed_id); @@ -171,6 +184,24 @@ { var item = document.getElementById("item-" + item_id); if (item) item.parentNode.removeChild(item); + + var container = document.getElementById("page-counter"); + + if (container) { + + counter = parseInt(container.textContent.trim(), 10) - 1; + + if (counter == 0) { + + window.location = "?action=feeds¬hing_to_read=1"; + } + else { + + container.textContent = counter + " "; + document.title = "miniflux (" + counter + ")"; + document.getElementById("nav-counter").textContent = "(" + counter + ")"; + } + } } @@ -230,6 +261,10 @@ function change_item_status() { + if (is_listing() && ! document.getElementById("current-item")) { + document.querySelector("article").id = "current-item"; + } + var item = document.getElementById("current-item"); if (item) switch_status(item.getAttribute("data-item-id")); } @@ -364,6 +399,9 @@ case 109: change_item_status(); break; + case 102: + bookmark_item(); + break; } }; diff --git a/common.php b/common.php index 705e633..36f4c88 100644 --- a/common.php +++ b/common.php @@ -10,7 +10,7 @@ require 'schema.php'; require 'model.php'; -const DB_VERSION = 7; +const DB_VERSION = 8; const APP_VERSION = 'master'; const APP_USERAGENT = 'Miniflux - http://miniflux.net'; const HTTP_TIMEOUT = 5; diff --git a/index.php b/index.php index 9fef145..a54c993 100644 --- a/index.php +++ b/index.php @@ -57,7 +57,6 @@ Router\before(function($action) { Router\get_action('logout', function() { Session\close(); - Response\redirect('?action=login'); }); @@ -97,22 +96,15 @@ Router\get_action('show', function() { $id = Model\decode_item_id(Request\param('id')); - Response\html(Template\layout('read_item', array( - 'item' => Model\get_item($id) + Model\set_item_read($id); + + Response\html(Template\layout('show_item', array( + 'item' => Model\get_item($id), + 'menu' => 'show' ))); }); -Router\get_action('show_starred_item', function() { - $id = Model\decode_item_id(Request\param('id')); - - Response\html(Template\layout('starred_item', array( - 'item' => Model\get_item($id) - ))); -}); - - - Router\get_action('read', function() { $id = Model\decode_item_id(Request\param('id')); @@ -121,24 +113,10 @@ Router\get_action('read', function() { Model\set_item_read($id); - Response\html(Template\layout('read_item', array( + Response\html(Template\layout('show_item', array( 'item' => $item, - 'item_nav' => $nav - ))); -}); - - -Router\get_action('read_starred', function() { - - $id = Model\decode_item_id(Request\param('id')); - $item = Model\get_item($id); - $nav = Model\get_nav_starred_item($item); // must be placed before set_item_read() - - Model\set_item_read($id); - - Response\html(Template\layout('starred_item', array( - 'item' => $item, - 'item_nav' => $nav + 'item_nav' => $nav, + 'menu' => 'read' ))); }); @@ -147,7 +125,7 @@ Router\get_action('mark-item-read', function() { $id = Model\decode_item_id(Request\param('id')); Model\set_item_read($id); - Response\Redirect('?action='.$_SESSION['MODE']); + Response\Redirect('?action='.Request\param('redirect', 'default')); }); @@ -155,7 +133,7 @@ Router\get_action('mark-item-unread', function() { $id = Model\decode_item_id(Request\param('id')); Model\set_item_unread($id); - Response\Redirect('?action='.$_SESSION['MODE']); + Response\Redirect('?action='.Request\param('redirect', 'history')); }); @@ -163,7 +141,7 @@ Router\get_action('mark-item-removed', function() { $id = Model\decode_item_id(Request\param('id')); Model\set_item_removed($id); - Response\Redirect('?action='.$_SESSION['MODE']); + Response\Redirect('?action='.Request\param('redirect', 'history')); }); @@ -183,19 +161,32 @@ Router\post_action('mark-item-unread', function() { }); -Router\get_action('mark-item-starred', function() { +Router\post_action('bookmark-item', function() { $id = Model\decode_item_id(Request\param('id')); - Model\set_item_starred($id); - Response\Redirect('?action='.$_SESSION['MODE']); + Model\bookmark_item($id); + Response\json(array('Ok')); }); -Router\get_action('mark-item-unstarred', function() { +Router\get_action('bookmark', function() { - $id = Model\decode_item_id(Request\param('id')); - Model\set_item_unstarred($id); - Response\Redirect('?action='.$_SESSION['MODE']); + $param_id = Request\param('id'); + $id = Model\decode_item_id($param_id); + $redirect = Request\param('redirect', 'unread'); + + Model\set_bookmark_value($id, Request\int_param('value')); + + if ($redirect === 'show') { + + Response\Redirect('?action=show&id='.$param_id); + } + else if ($redirect === 'read') { + + Response\Redirect('?action=read&id='.$param_id); + } + + Response\Redirect('?action='.$redirect); }); @@ -204,38 +195,40 @@ Router\post_action('change-item-status', function() { $id = Model\decode_item_id(Request\param('id')); Response\json(array( - 'item_id' => urlencode($id), + 'item_id' => Model\encode_item_id($id), 'status' => Model\switch_item_status($id) )); }); Router\get_action('history', function() { - $_SESSION['MODE']='history'; + Response\html(Template\layout('history', array( 'items' => Model\get_read_items(), - 'menu' => 'history' + 'menu' => 'history', + 'title' => t('History') ))); }); -Router\get_action('starred', function() { - $_SESSION['MODE']='starred'; - Response\html(Template\layout('starred', array( - 'items' => Model\get_starred_items(), - 'menu' => 'starred' +Router\get_action('bookmarks', function() { + + Response\html(Template\layout('bookmarks', array( + 'items' => Model\get_bookmarks(), + 'menu' => 'bookmarks', + 'title' => t('Bookmarks') ))); }); - Router\get_action('confirm-remove', function() { $id = Request\int_param('feed_id'); Response\html(Template\layout('confirm_remove_feed', array( 'feed' => Model\get_feed($id), - 'menu' => 'feeds' + 'menu' => 'feeds', + 'title' => t('Confirmation') ))); }); @@ -293,7 +286,8 @@ Router\get_action('mark-as-read', function() { Router\get_action('confirm-flush-history', function() { Response\html(Template\layout('confirm_flush_items', array( - 'menu' => 'history' + 'menu' => 'history', + 'title' => t('Confirmation') ))); }); @@ -318,7 +312,8 @@ Router\get_action('feeds', function() { Response\html(Template\layout('feeds', array( 'feeds' => Model\get_feeds(), 'nothing_to_read' => Request\int_param('nothing_to_read'), - 'menu' => 'feeds' + 'menu' => 'feeds', + 'title' => t('Subscriptions') ))); }); @@ -328,7 +323,8 @@ Router\get_action('add', function() { Response\html(Template\layout('add', array( 'values' => array(), 'errors' => array(), - 'menu' => 'feeds' + 'menu' => 'feeds', + 'title' => t('New subscription') ))); }); @@ -347,7 +343,8 @@ Router\post_action('add', function() { Response\html(Template\layout('add', array( 'values' => array('url' => $_POST['url']), - 'menu' => 'feeds' + 'menu' => 'feeds', + 'title' => t('Subscriptions') ))); }); @@ -377,7 +374,8 @@ Router\get_action('import', function() { Response\html(Template\layout('import', array( 'errors' => array(), - 'menu' => 'feeds' + 'menu' => 'feeds', + 'title' => t('OPML Import') ))); }); @@ -405,14 +403,15 @@ Router\get_action('config', function() { 'db_size' => filesize(get_db_filename()), 'languages' => Model\get_languages(), 'autoflush_options' => Model\get_autoflush_options(), - 'menu' => 'config' + 'menu' => 'config', + 'title' => t('Preferences') ))); }); Router\post_action('config', function() { - $values = Request\values() + array('nocontent' => 0); + $values = Request\values(); list($valid, $errors) = Model\validate_config_update($values); if ($valid) { @@ -435,25 +434,28 @@ Router\post_action('config', function() { 'db_size' => filesize(get_db_filename()), 'languages' => Model\get_languages(), 'autoflush_options' => Model\get_autoflush_options(), - 'menu' => 'config' + 'menu' => 'config', + 'title' => t('Preferences') ))); }); Router\notfound(function() { - $_SESSION['MODE']='default'; Model\autoflush(); $items = Model\get_unread_items(); + $nb_items = count($items); - if (empty($items)) { + if ($nb_items === 0) { Response\redirect('?action=feeds¬hing_to_read=1'); } Response\html(Template\layout('unread_items', array( 'items' => $items, + 'nb_items' => $nb_items, + 'title' => 'miniflux ('.$nb_items.')', 'menu' => 'unread' ))); }); diff --git a/locales/fr_FR/translations.php b/locales/fr_FR/translations.php index c335df4..dc7aa29 100644 --- a/locales/fr_FR/translations.php +++ b/locales/fr_FR/translations.php @@ -9,11 +9,13 @@ return array( 'French' => 'Français', 'English' => 'Anglais', 'unread' => 'non lus', - 'mark as starred' => 'ajouter aux favoris', - 'mark as unstarred' => 'supprimer des favoris', - 'starred' => 'favoris', - 'No starred items' => 'Pas de favoris', - 'Starred' => 'Favoris', + 'bookmarks' => 'favoris', + 'bookmark' => 'ajouter aux favoris', + 'remove bookmark' => 'supprimer des favoris', + 'bookmarks' => 'favoris', + 'Bookmarks' => 'Favoris', + 'Bookmark item' => 'Ajouter l\'élément séléctionné aux favoris', + 'No bookmark' => 'Pas de favoris', 'history' => 'historique', 'subscriptions' => 'abonnements', 'Subscriptions' => 'Abonnements', @@ -24,7 +26,7 @@ return array( 'Password' => 'Mot de passe', 'Confirmation' => 'Confirmation', 'Language' => 'Langue', - 'Update' => 'Mettre à jour', + 'Save' => 'Sauvegarder', 'More informations' => 'Plus d\'informations', 'Database' => 'Base de données', 'Database size:' => 'Taille de la base de données :', @@ -41,7 +43,7 @@ return array( 'About' => 'A propos', 'Miniflux version:' => 'Version de Miniflux :', 'Nothing to read' => 'Rien à lire', - 'Unread items' => 'Éléments non lus', + 'unread items' => 'éléments non lus', 'mark all as read' => 'tout marquer comme lu', 'original link' => 'lien original', 'mark as read' => 'marquer comme lu', @@ -69,7 +71,7 @@ return array( 'New subscription' => 'Nouvel abonnement', 'Website or Feed URL' => 'URL du site ou du flux', 'Add' => 'Ajouter', - 'http://website/' => 'http://siteweb/', + 'http://website/' => 'http://site-web/', 'Yes' => 'Oui', 'cancel' => 'annuler', 'or' => 'ou', @@ -94,4 +96,4 @@ return array( 'Do you really want to remove this subscription: "%s"?' => 'Voulez-vous vraiment supprimer cet abonnement : "%s" ?', 'Nothing to read, do you want to update your subscriptions?' => 'Il n\'y a rien à lire, voulez-vous mettre à jour vos abonnements ?' -); +); \ No newline at end of file diff --git a/model.php b/model.php index bcda45e..e29b3e1 100644 --- a/model.php +++ b/model.php @@ -192,7 +192,6 @@ function get_feeds_id($limit = LIMIT_ALL) ->asc('last_checked'); if ($limit !== LIMIT_ALL) { - $table_feeds->limit((int)$limit); } @@ -254,7 +253,7 @@ function get_unread_items() { return \PicoTools\singleton('db') ->table('items') - ->columns('items.id', 'items.title', 'items.updated', 'items.url', 'feeds.site_url', 'items.content','starred') + ->columns('items.id', 'items.title', 'items.updated', 'items.url', 'items.content', 'items.bookmark', 'items.status', 'feeds.site_url') ->join('feeds', 'id', 'feed_id') ->eq('status', 'unread') ->desc('updated') @@ -266,23 +265,22 @@ function get_read_items() { return \PicoTools\singleton('db') ->table('items') - ->columns('items.id', 'items.title', 'items.updated', 'items.url', 'feeds.site_url','starred') + ->columns('items.id', 'items.title', 'items.updated', 'items.url', 'items.bookmark', 'feeds.site_url') ->join('feeds', 'id', 'feed_id') ->eq('status', 'read') ->desc('updated') ->findAll(); - - } -function get_starred_items() +function get_bookmarks() { return \PicoTools\singleton('db') ->table('items') - ->columns('items.id', 'items.title', 'items.updated', 'items.url', 'feeds.site_url') + ->columns('items.id', 'items.title', 'items.updated', 'items.url', 'items.status', 'feeds.site_url') ->join('feeds', 'id', 'feed_id') - ->eq('starred', 'starred') + ->in('status', array('read', 'unread')) + ->eq('bookmark', 1) ->desc('updated') ->findAll(); } @@ -326,41 +324,12 @@ function get_nav_item($item) } -function get_nav_starred_item($item) -{ - $starred_items = \PicoTools\singleton('db') - ->table('items') - ->columns('items.id') - ->eq('starred', 'starred') - ->desc('updated') - ->findAll(); - - $next_item = null; - $previous_item = null; - - for ($i = 0, $ilen = count($starred_items); $i < $ilen; $i++) { - - if ($starred_items[$i]['id'] == $item['id']) { - - if ($i > 0) $previous_item = $starred_items[$i - 1]; - if ($i < ($ilen - 1)) $next_item = $starred_items[$i + 1]; - break; - } - } - - return array( - 'next' => $next_item, - 'previous' => $previous_item - ); -} - - function set_item_removed($id) { \PicoTools\singleton('db') ->table('items') ->eq('id', $id) - ->save(array('status' => 'removed','starred' => 'unstarred')); + ->save(array('status' => 'removed', 'content' => '')); } @@ -382,22 +351,12 @@ function set_item_unread($id) } - -function set_item_starred($id) +function set_bookmark_value($id, $value) { \PicoTools\singleton('db') ->table('items') ->eq('id', $id) - ->save(array('starred' => 'starred')); -} - - -function set_item_unstarred($id) -{ - \PicoTools\singleton('db') - ->table('items') - ->eq('id', $id) - ->save(array('starred' => 'unstarred')); + ->save(array('bookmark' => $value)); } @@ -446,7 +405,7 @@ function mark_as_removed() \PicoTools\singleton('db') ->table('items') ->eq('status', 'read') - ->save(array('status' => 'removed')); + ->save(array('status' => 'removed', 'content' => '')); } @@ -459,9 +418,8 @@ function autoflush() \PicoTools\singleton('db') ->table('items') ->eq('status', 'read') - ->eq('starred', 'starred') ->lt('updated', strtotime('-'.$autoflush.'day')) - ->save(array('status' => 'removed')); + ->save(array('status' => 'removed', 'content' => '')); } } diff --git a/schema.php b/schema.php index 03f2768..7c3be96 100644 --- a/schema.php +++ b/schema.php @@ -2,9 +2,10 @@ namespace Schema; -function version_7($pdo) + +function version_8($pdo) { - $pdo->exec('ALTER TABLE items ADD COLUMN starred TEXT'); + $pdo->exec('ALTER TABLE items ADD COLUMN bookmark INTEGER DEFAULT 0'); } @@ -28,7 +29,7 @@ function version_5($pdo) function version_4($pdo) { - $pdo->exec("CREATE INDEX idx_status ON items(status)"); + $pdo->exec('CREATE INDEX idx_status ON items(status)'); } diff --git a/templates/app_header.php b/templates/app_header.php index da9a4bc..7e289e4 100644 --- a/templates/app_header.php +++ b/templates/app_header.php @@ -10,7 +10,7 @@ - miniflux + <?= isset($title) ? $title : 'miniflux' ?> @@ -19,12 +19,24 @@ diff --git a/templates/starred.php b/templates/bookmarks.php similarity index 69% rename from templates/starred.php rename to templates/bookmarks.php index 188a36b..d37ca31 100644 --- a/templates/starred.php +++ b/templates/bookmarks.php @@ -5,16 +5,16 @@ -
+
-
@@ -47,6 +47,7 @@
  • = m
  • = v
  • = o
  • +
  • = f
  • diff --git a/templates/history.php b/templates/history.php index 154dd79..b9a8099 100644 --- a/templates/history.php +++ b/templates/history.php @@ -13,8 +13,9 @@
    -
    +

    +

    - | - | + | + | - - - | - - | + + | - - | | -

    +

    - + + +

    | | - - - - - - + + + + +

    diff --git a/templates/starred_item.php b/templates/starred_item.php deleted file mode 100644 index 981d0af..0000000 --- a/templates/starred_item.php +++ /dev/null @@ -1,44 +0,0 @@ - - -

    - - -
    -

    - -

    - -

    - | - | - -

    - - - - - - -
    - - diff --git a/templates/unread_items.php b/templates/unread_items.php index 2396812..91a9d5a 100644 --- a/templates/unread_items.php +++ b/templates/unread_items.php @@ -5,7 +5,7 @@