From 5e9c60752c9a40e1540de50d02e19ba1d06e5491 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 1 Feb 2014 12:23:12 +0100 Subject: Actualize : Tolère PHP lancé en CGI plutôt que CLI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige https://github.com/marienfressinaud/FreshRSS/issues/405 + Message d'erreur en cas de problème de droits dans ./data/ (par exemple si le cron utilise un mauvais utilisateur) --- app/FreshRSS.php | 4 ---- app/actualize_script.php | 23 +++++++++++++++++++---- lib/lib_rss.php | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/app/FreshRSS.php b/app/FreshRSS.php index c51f91dec..84cf3429b 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -94,10 +94,6 @@ class FreshRSS extends Minz_FrontController { $loginOk = false; break; } - if ((!$loginOk) && (PHP_SAPI === 'cli') && (Minz_Request::actionName() === 'actualize')) { //Command line - Minz_Configuration::_authType('none'); - $loginOk = true; - } } Minz_View::_param ('loginOk', $loginOk); return $loginOk; diff --git a/app/actualize_script.php b/app/actualize_script.php index 9ac80a852..bef9bd218 100755 --- a/app/actualize_script.php +++ b/app/actualize_script.php @@ -8,7 +8,10 @@ if (file_exists($lock) && ((time() - @filemtime($lock)) > 3600)) { } if (($handle = @fopen($lock, 'x')) === false) { syslog(LOG_NOTICE, 'FreshRSS actualize already running?'); - fwrite(STDERR, 'FreshRSS actualize already running?' . "\n"); + if (defined('STDERR')) { + fwrite(STDERR, 'FreshRSS actualize already running?' . "\n"); + } + echo 'FreshRSS actualize already running?', "\n"; return; } register_shutdown_function('unlink', $lock); @@ -32,7 +35,9 @@ $users = array_unique($users); foreach ($users as $myUser) { syslog(LOG_INFO, 'FreshRSS actualize ' . $myUser); - fwrite(STDOUT, 'Actualize ' . $myUser . "...\n"); //Unbuffered + if (defined('STDOUT')) { + fwrite(STDOUT, 'Actualize ' . $myUser . "...\n"); //Unbuffered + } echo $myUser, ' '; //Buffered $_GET['c'] = 'feed'; @@ -44,16 +49,26 @@ foreach ($users as $myUser) { $freshRSS = new FreshRSS(); $freshRSS->_useOb(false); + Minz_Configuration::_authType('none'); + Minz_Session::init('FreshRSS'); Minz_Session::_param('currentUser', $myUser); $freshRSS->init(); $freshRSS->run(); - invalidateHttpCache(); + if (!invalidateHttpCache()) { + syslog(LOG_NOTICE, 'FreshRSS write access problem in ' . LOG_PATH . '/*.log!'); + if (defined('STDERR')) { + fwrite(STDERR, 'Write access problem in ' . LOG_PATH . '/*.log!' . "\n"); + } + } Minz_Session::unset_session(true); Minz_ModelPdo::clean(); } syslog(LOG_INFO, 'FreshRSS actualize done.'); +if (defined('STDOUT')) { + fwrite(STDOUT, 'Done.' . "\n"); +} +echo 'End.', "\n"; ob_end_flush(); -fwrite(STDOUT, 'Done.' . "\n"); diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 1bb117ab6..a13d9e951 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -214,8 +214,8 @@ function uSecString() { } function invalidateHttpCache() { - touch(LOG_PATH . '/' . Minz_Session::param('currentUser', '_') . '.log'); Minz_Session::_param('touch', uTimeString()); + return touch(LOG_PATH . '/' . Minz_Session::param('currentUser', '_') . '.log'); } function usernameFromPath($userPath) { -- cgit v1.2.3 From cf8ee6bd48221e73b515922e75945e9aa763f907 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 1 Feb 2014 14:04:37 +0100 Subject: Rafraîchissement des flux en cache super rapide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contribue à https://github.com/marienfressinaud/FreshRSS/issues/351#issuecomment-31755012 Les flux non-modifiés et en cache ne coûtent maintenant presque plus rien (304, ou délai de cache SimplePie non expiré), alors qu'avant toutes les entrées étaient rechargées --- app/Controllers/feedController.php | 57 +++++++++++++++++++++++--------------- app/Models/Feed.php | 14 ++++++---- app/Models/FeedDAO.php | 24 ++++++++++------ lib/SimplePie/SimplePie.php | 21 ++++++++------ 4 files changed, 70 insertions(+), 46 deletions(-) diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index c40b3c400..cf9c993d5 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -191,36 +191,45 @@ class FreshRSS_feed_Controller extends Minz_ActionController { foreach ($feeds as $feed) { try { $url = $feed->url(); + $feedHistory = $feed->keepHistory(); + $feed->load(false); $entries = array_reverse($feed->entries()); //We want chronological order and SimplePie uses reverse order + $hasTransaction = false; - //For this feed, check last n entry GUIDs already in database - $existingGuids = array_fill_keys ($entryDAO->listLastGuidsByFeed ($feed->id (), count($entries) + 10), 1); - $useDeclaredDate = empty($existingGuids); + if (count($entries) > 0) { + //For this feed, check last n entry GUIDs already in database + $existingGuids = array_fill_keys ($entryDAO->listLastGuidsByFeed ($feed->id (), count($entries) + 10), 1); + $useDeclaredDate = empty($existingGuids); - $feedHistory = $feed->keepHistory(); - if ($feedHistory == -2) { //default - $feedHistory = $this->view->conf->keep_history_default; - } + if ($feedHistory == -2) { //default + $feedHistory = $this->view->conf->keep_history_default; + } + + $hasTransaction = true; + $feedDAO->beginTransaction(); - // On ne vérifie pas strictement que l'article n'est pas déjà en BDD - // La BDD refusera l'ajout car (id_feed, guid) doit être unique - $feedDAO->beginTransaction (); - foreach ($entries as $entry) { - $eDate = $entry->date (true); - if ((!isset ($existingGuids[$entry->guid ()])) && - (($feedHistory != 0) || ($eDate >= $date_min))) { - $values = $entry->toArray (); - //Use declared date at first import, otherwise use discovery date - $values['id'] = ($useDeclaredDate || $eDate < $date_min) ? - min(time(), $eDate) . uSecString() : - uTimeString(); - $values['is_read'] = $is_read; - $entryDAO->addEntry ($values); + // On ne vérifie pas strictement que l'article n'est pas déjà en BDD + // La BDD refusera l'ajout car (id_feed, guid) doit être unique + foreach ($entries as $entry) { + $eDate = $entry->date (true); + if ((!isset ($existingGuids[$entry->guid ()])) && + (($feedHistory != 0) || ($eDate >= $date_min))) { + $values = $entry->toArray (); + //Use declared date at first import, otherwise use discovery date + $values['id'] = ($useDeclaredDate || $eDate < $date_min) ? + min(time(), $eDate) . uSecString() : + uTimeString(); + $values['is_read'] = $is_read; + $entryDAO->addEntry ($values); + } } } if (($feedHistory >= 0) && (rand(0, 30) === 1)) { + if (!$hasTransaction) { + $feedDAO->beginTransaction(); + } $nb = $feedDAO->cleanOldEntries ($feed->id (), $date_min, max($feedHistory, count($entries) + 10)); if ($nb > 0) { Minz_Log::record ($nb . ' old entries cleaned in feed [' . $feed->url() . ']', Minz_Log::DEBUG); @@ -228,8 +237,10 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } // on indique que le flux vient d'être mis à jour en BDD - $feedDAO->updateLastUpdate ($feed->id ()); - $feedDAO->commit (); + $feedDAO->updateLastUpdate ($feed->id (), 0, $hasTransaction); + if ($hasTransaction) { + $feedDAO->commit(); + } $flux_update++; if ($feed->url() !== $url) { //URL has changed (auto-discovery) $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 22c019080..662476b7e 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -193,10 +193,10 @@ class FreshRSS_Feed extends Minz_Model { } $feed = customSimplePie(); $feed->set_feed_url ($url); - $feed->init (); + $initResult = $feed->init (); - if ($feed->error ()) { - throw new FreshRSS_Feed_Exception ($feed->error . ' [' . $url . ']'); + if ((!$initResult) || $feed->error()) { + throw new FreshRSS_Feed_Exception ($feed->error() . ' [' . $url . ']'); } // si on a utilisé l'auto-discover, notre url va avoir changé @@ -217,11 +217,15 @@ class FreshRSS_Feed extends Minz_Model { $this->_description(html_only_entity_decode($feed->get_description())); } - // et on charge les articles du flux - $this->loadEntries ($feed); + if (($initResult == SIMPLEPIE_INIT_SUCCESS) || $loadDetails) { + $this->loadEntries($feed); // et on charge les articles du flux + } else { + $this->entries = array(); + } } } } + private function loadEntries ($feed) { $entries = array (); diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index e102da4ec..a17ff0718 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -52,21 +52,27 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { } } - public function updateLastUpdate ($id, $inError = 0) { - $sql = 'UPDATE `' . $this->prefix . 'feed` f ' //2 sub-requests with FOREIGN KEY(e.id_feed), INDEX(e.is_read) faster than 1 request with GROUP BY or CASE - . 'SET f.cache_nbEntries=(SELECT COUNT(e1.id) FROM `' . $this->prefix . 'entry` e1 WHERE e1.id_feed=f.id),' - . 'f.cache_nbUnreads=(SELECT COUNT(e2.id) FROM `' . $this->prefix . 'entry` e2 WHERE e2.id_feed=f.id AND e2.is_read=0),' - . 'lastUpdate=?, error=? ' - . 'WHERE f.id=?'; - - $stm = $this->bd->prepare ($sql); + public function updateLastUpdate ($id, $inError = 0, $updateCache = true) { + if ($updateCache) { + $sql = 'UPDATE `' . $this->prefix . 'feed` f ' //2 sub-requests with FOREIGN KEY(e.id_feed), INDEX(e.is_read) faster than 1 request with GROUP BY or CASE + . 'SET f.cache_nbEntries=(SELECT COUNT(e1.id) FROM `' . $this->prefix . 'entry` e1 WHERE e1.id_feed=f.id),' + . 'f.cache_nbUnreads=(SELECT COUNT(e2.id) FROM `' . $this->prefix . 'entry` e2 WHERE e2.id_feed=f.id AND e2.is_read=0),' + . 'lastUpdate=?, error=? ' + . 'WHERE f.id=?'; + } else { + $sql = 'UPDATE `' . $this->prefix . 'feed` f ' + . 'SET lastUpdate=?, error=? ' + . 'WHERE f.id=?'; + } $values = array ( - time (), + time(), $inError, $id, ); + $stm = $this->bd->prepare ($sql); + if ($stm && $stm->execute ($values)) { return $stm->rowCount(); } else { diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php index f02037c10..97b9310db 100644 --- a/lib/SimplePie/SimplePie.php +++ b/lib/SimplePie/SimplePie.php @@ -402,6 +402,9 @@ define('SIMPLEPIE_FILE_SOURCE_CURL', 8); */ define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16); +define('SIMPLEPIE_INIT_FAIL', 0); //FreshRSS +define('SIMPLEPIE_INIT_SUCCESS', 1); //FreshRSS +define('SIMPLEPIE_INIT_CACHE', 2); //FreshRSS /** @@ -1226,7 +1229,7 @@ class SimplePie // Check absolute bare minimum requirements. if (!extension_loaded('xml') || !extension_loaded('pcre')) { - return false; + return SIMPLEPIE_INIT_FAIL; } // Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader. elseif (!extension_loaded('xmlreader')) @@ -1241,7 +1244,7 @@ class SimplePie } if (!$xml_is_sane) { - return false; + return SIMPLEPIE_INIT_FAIL; } } @@ -1273,11 +1276,11 @@ class SimplePie } $i++; } - return (bool) $success; + return inval($success); } elseif ($this->feed_url === null && $this->raw_data === null) { - return false; + return SIMPLEPIE_INIT_FAIL; } $this->error = null; @@ -1298,10 +1301,10 @@ class SimplePie // Fetch the data via SimplePie_File into $this->raw_data if (($fetched = $this->fetch_data($cache)) === true) { - return true; + return SIMPLEPIE_INIT_CACHE; } elseif ($fetched === false) { - return false; + return SIMPLEPIE_INIT_FAIL; } list($headers, $sniffed) = $fetched; @@ -1378,7 +1381,7 @@ class SimplePie { $this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed."; $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); - return false; + return SIMPLEPIE_INIT_FAIL; } if (isset($headers)) @@ -1392,7 +1395,7 @@ class SimplePie { trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); } - return true; + return SIMPLEPIE_INIT_SUCCESS; } } } @@ -1409,7 +1412,7 @@ class SimplePie $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); - return false; + return SIMPLEPIE_INIT_FAIL; } /** -- cgit v1.2.3 From a76e5bd1c65354dbdc9793179369ef0903d03762 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 1 Feb 2014 14:07:23 +0100 Subject: C'est parti pour la 0.8-dev --- CHANGELOG | 5 +++++ README.md | 4 ++-- constants.php | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4db9381d5..f7e15c185 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ # Journal des modifications +## 2014-0x-xx FreshRSS 0.8 + +* Mise à jour des flux plus rapide grâce à une meilleure utilisation du cache + + ## 2014-01-29 FreshRSS 0.7 * Nouveau mode multi-utilisateur diff --git a/README.md b/README.md index 75346f98e..4de5c51e0 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Il permet de gérer plusieurs utilisateurs, et dispose d’un mode de lecture an * Site officiel : http://freshrss.org * Démo : http://demo.freshrss.org/ * Développeur : Marien Fressinaud -* Version actuelle : 0.7 -* Date de publication 2014-01-29 +* Version actuelle : 0.8-dev +* Date de publication 2014-0x-xx * License [GNU AGPL 3](http://www.gnu.org/licenses/agpl-3.0.html) ![Logo de FreshRSS](http://marienfressinaud.fr/data/images/freshrss/freshrss_title.png) diff --git a/constants.php b/constants.php index 2eba868b2..a7c96f47b 100644 --- a/constants.php +++ b/constants.php @@ -1,5 +1,5 @@ Date: Sat, 1 Feb 2014 20:13:42 +0100 Subject: Rafraîchissement des flux en cache compatible multi-utilisateurs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compatibilité multi-utilisateurs pour la mise à jour rapide des flux avec cache Correction de https://github.com/marienfressinaud/FreshRSS/commit/cf8ee6bd48221e73b515922e75945e9aa763f907#commitcomment-5247478 Contribue à https://github.com/marienfressinaud/FreshRSS/issues/351#issuecomment-31755012 --- app/Models/Feed.php | 8 +++++--- app/Models/FeedDAO.php | 2 +- lib/SimplePie/SimplePie.php | 25 ++++++++++++------------- lib/SimplePie/SimplePie/Misc.php | 30 +++--------------------------- 4 files changed, 21 insertions(+), 44 deletions(-) diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 662476b7e..366c04c67 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -193,9 +193,9 @@ class FreshRSS_Feed extends Minz_Model { } $feed = customSimplePie(); $feed->set_feed_url ($url); - $initResult = $feed->init (); + $mtime = $feed->init(); - if ((!$initResult) || $feed->error()) { + if ((!$mtime) || $feed->error()) { throw new FreshRSS_Feed_Exception ($feed->error() . ' [' . $url . ']'); } @@ -217,9 +217,11 @@ class FreshRSS_Feed extends Minz_Model { $this->_description(html_only_entity_decode($feed->get_description())); } - if (($initResult == SIMPLEPIE_INIT_SUCCESS) || $loadDetails) { + if (($mtime === true) || ($mtime > $this->lastUpdate)) { + syslog(LOG_DEBUG, 'FreshRSS no cache ' . $mtime . ' > ' . $this->lastUpdate); $this->loadEntries($feed); // et on charge les articles du flux } else { + syslog(LOG_DEBUG, 'FreshRSS use cache for ' . $subscribe_url); $this->entries = array(); } } diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index a17ff0718..a2ce0e46f 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -199,7 +199,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { } public function listFeedsOrderUpdate () { - $sql = 'SELECT id, name, url, pathEntries, httpAuth, keep_history FROM `' . $this->prefix . 'feed` ORDER BY lastUpdate'; + $sql = 'SELECT id, name, url, lastUpdate, pathEntries, httpAuth, keep_history FROM `' . $this->prefix . 'feed` ORDER BY lastUpdate'; $stm = $this->bd->prepare ($sql); $stm->execute (); diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php index 97b9310db..fe01d382e 100644 --- a/lib/SimplePie/SimplePie.php +++ b/lib/SimplePie/SimplePie.php @@ -402,9 +402,6 @@ define('SIMPLEPIE_FILE_SOURCE_CURL', 8); */ define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16); -define('SIMPLEPIE_INIT_FAIL', 0); //FreshRSS -define('SIMPLEPIE_INIT_SUCCESS', 1); //FreshRSS -define('SIMPLEPIE_INIT_CACHE', 2); //FreshRSS /** @@ -1222,14 +1219,14 @@ class SimplePie * configuration options get processed, feeds are fetched, cached, and * parsed, and all of that other good stuff. * - * @return boolean True if successful, false otherwise + * @return positive integer with modification time if using cache, boolean true if otherwise successful, false otherwise */ public function init() { // Check absolute bare minimum requirements. if (!extension_loaded('xml') || !extension_loaded('pcre')) { - return SIMPLEPIE_INIT_FAIL; + return false; } // Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader. elseif (!extension_loaded('xmlreader')) @@ -1244,7 +1241,7 @@ class SimplePie } if (!$xml_is_sane) { - return SIMPLEPIE_INIT_FAIL; + return false; } } @@ -1276,11 +1273,11 @@ class SimplePie } $i++; } - return inval($success); + return (bool) $success; } elseif ($this->feed_url === null && $this->raw_data === null) { - return SIMPLEPIE_INIT_FAIL; + return false; } $this->error = null; @@ -1301,10 +1298,10 @@ class SimplePie // Fetch the data via SimplePie_File into $this->raw_data if (($fetched = $this->fetch_data($cache)) === true) { - return SIMPLEPIE_INIT_CACHE; + return $this->data['mtime']; //FreshRSS } elseif ($fetched === false) { - return SIMPLEPIE_INIT_FAIL; + return false; } list($headers, $sniffed) = $fetched; @@ -1381,7 +1378,7 @@ class SimplePie { $this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed."; $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); - return SIMPLEPIE_INIT_FAIL; + return false; } if (isset($headers)) @@ -1389,13 +1386,14 @@ class SimplePie $this->data['headers'] = $headers; } $this->data['build'] = SIMPLEPIE_BUILD; + $this->data['mtime'] = time(); //FreshRSS // Cache the file if caching is enabled if ($cache && !$cache->save($this)) { trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); } - return SIMPLEPIE_INIT_SUCCESS; + return true; } } } @@ -1412,7 +1410,7 @@ class SimplePie $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); - return SIMPLEPIE_INIT_FAIL; + return false; } /** @@ -1558,6 +1556,7 @@ class SimplePie if ($cache) { $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD); + $this->data['mtime'] = time(); //FreshRSS if (!$cache->save($this)) { trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); diff --git a/lib/SimplePie/SimplePie/Misc.php b/lib/SimplePie/SimplePie/Misc.php index 347520303..b5812473b 100644 --- a/lib/SimplePie/SimplePie/Misc.php +++ b/lib/SimplePie/SimplePie/Misc.php @@ -2161,36 +2161,12 @@ function embed_wmedia(width, height, link) { /** * Get the SimplePie build timestamp * - * Uses the git index if it exists, otherwise uses the modification time - * of the newest file. + * Return SimplePie.php modification time. */ public static function get_build() { - $root = dirname(dirname(__FILE__)); - if (file_exists($root . '/.git/index')) - { - return filemtime($root . '/.git/index'); - } - elseif (file_exists($root . '/SimplePie')) - { - $time = 0; - foreach (glob($root . '/SimplePie/*.php') as $file) - { - if (($mtime = filemtime($file)) > $time) - { - $time = $mtime; - } - } - return $time; - } - elseif (file_exists(dirname(__FILE__) . '/Core.php')) - { - return filemtime(dirname(__FILE__) . '/Core.php'); - } - else - { - return filemtime(__FILE__); - } + $mtime = @filemtime(dirname(dirname(__FILE__)) . '/SimplePie.php'); //FreshRSS + return $mtime ? $mtime : filemtime(__FILE__); } /** -- cgit v1.2.3 From 6eb7828b628faecc314c7acfee0860fb24635737 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 1 Feb 2014 11:40:20 -0500 Subject: Modification du partage au clavier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le raccourci de partage a été modifié pour partager automatiquement un article s'il n'existe qu'un mode de partage. Les modes de partage sont rendus accessibles au clavier en utilisant les chiffres de 1 à 9. Quand un article est partagé, la liste des modes est cachée automatiquement. --- p/scripts/main.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/p/scripts/main.js b/p/scripts/main.js index f0d2bbf7b..ee729b9e5 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -252,10 +252,27 @@ function collapse_entry() { $(".flux.current").toggleClass("active"); } -function auto_share() { +function auto_share(key) { var share = $(".flux.current.active").find('.dropdown-target[id^="dropdown-share"]'); - if (share.length) { + var shares = share.siblings('.dropdown-menu').find('.item a'); + if (typeof key === "undefined") { + if (!share.length) { + return; + } + // Display the share div window.location.hash = share.attr('id'); + // Force the key value if there is only one action, so we can trigger it automatically + if (shares.length === 1) { + key = 1; + } else { + return; + } + } + // Trigger selected share action and hide the share div + key = parseInt(key); + if (key <= shares.length) { + shares[key - 1].click(); + share.siblings('.dropdown-menu').find('.dropdown-close a')[0].click(); } } @@ -390,6 +407,13 @@ function init_shortcuts() { }, { 'disable_in_input': true }); + for(var i = 1; i < 10; i++){ + shortcut.add(i.toString(), function (e) { + auto_share(String.fromCharCode(e.keyCode)); + }, { + 'disable_in_input': true + }); + } // Touches de navigation shortcut.add(shortcuts.prev_entry, prev_entry, { -- cgit v1.2.3 From f8be8eb41b50d0bea6f6c362abc33fb4ac546f3d Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 1 Feb 2014 16:23:43 -0500 Subject: Modification de l'affichage des modes de partage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajout de la numérotation des modes de partage pour rendre l'utilisation des raccourcis plus aisée. --- app/views/helpers/view/normal_view.phtml | 16 ++++++++-------- p/themes/Dark/global.css | 5 +++++ p/themes/Flat/global.css | 5 +++++ p/themes/Origine/global.css | 5 +++++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/views/helpers/view/normal_view.phtml b/app/views/helpers/view/normal_view.phtml index 7b7faccee..ae93b627c 100644 --- a/app/views/helpers/view/normal_view.phtml +++ b/app/views/helpers/view/normal_view.phtml @@ -147,49 +147,49 @@ if (!empty($this->entries)) {