A free, self-hostable news aggregator…
mise en place du routage
Marien Fressinaudb5916b6c04cd
diff --git a/app/configuration/application.ini b/app/configuration/application.iniindex 93895ad0e..c98622c5d 100644--- a/app/configuration/application.ini+++ b/app/configuration/application.ini@@ -1,6 +1,6 @@[general]environment = "development"-use_url_rewriting = false+use_url_rewriting = truesel_application = "flux rss lalala ~~~"base_url = "/~marien/rss/public"diff --git a/app/configuration/routes.php b/app/configuration/routes.phpindex 0efec7ba7..d9bb5ca99 100644--- a/app/configuration/routes.php+++ b/app/configuration/routes.php@@ -1,5 +1,124 @@<?phpreturn array (-+ // Index+ array (+ 'route' => '/\?q=([\w\d\-_]+)&p=([\d+])',+ 'controller' => 'index',+ 'action' => 'index',+ 'params' => array ('get', 'page')+ ),+ array (+ 'route' => '/\?q=([\w\d\-_]+)',+ 'controller' => 'index',+ 'action' => 'index',+ 'params' => array ('get')+ ),+ array (+ 'route' => '/\?p=([\d]+)',+ 'controller' => 'index',+ 'action' => 'index',+ 'params' => array ('page')+ ),+ array (+ 'route' => '/login.php',+ 'controller' => 'index',+ 'action' => 'login'+ ),+ array (+ 'route' => '/logout.php',+ 'controller' => 'index',+ 'action' => 'logout'+ ),+ array (+ 'route' => '/mode.php\?m=([\w_]+)',+ 'controller' => 'index',+ 'action' => 'changeMode',+ 'params' => array ('mode')+ ),++ // Scripts+ array (+ 'route' => '/scripts/main.js',+ 'controller' => 'javascript',+ 'action' => 'main'+ ),++ // Entry+ array (+ 'route' => '/articles/marquer.php\?lu=([\d]{1})',+ 'controller' => 'entry',+ 'action' => 'read',+ 'params' => array ('is_read')+ ),+ array (+ 'route' => '/articles/marquer.php\?id=([\w\d\-_]{6})&favori=([\d]{1})',+ 'controller' => 'entry',+ 'action' => 'bookmark',+ 'params' => array ('id', 'is_favorite')+ ),+ array (+ 'route' => '/articles/marquer.php\?id=([\w\d\-_]{6})&lu=([\d]{1})',+ 'controller' => 'entry',+ 'action' => 'read',+ 'params' => array ('id', 'is_read')+ ),+++ // Feed+ array (+ 'route' => '/flux/ajouter.php',+ 'controller' => 'feed',+ 'action' => 'add'+ ),+ array (+ 'route' => '/flux/actualiser.php',+ 'controller' => 'feed',+ 'action' => 'actualize'+ ),+ array (+ 'route' => '/flux/supprimer.php\?id=([\w\d\-_]{6})',+ 'controller' => 'feed',+ 'action' => 'delete',+ 'params' => array ('id')+ ),++ // Configure+ array (+ 'route' => '/configuration/flux.php',+ 'controller' => 'configure',+ 'action' => 'feed'+ ),+ array (+ 'route' => '/configuration/flux.php\?id=([\w\d\-_]{6})',+ 'controller' => 'configure',+ 'action' => 'feed',+ 'params' => array ('id')+ ),+ array (+ 'route' => '/configuration/categories.php',+ 'controller' => 'configure',+ 'action' => 'categorize'+ ),+ array (+ 'route' => '/configuration/global.php',+ 'controller' => 'configure',+ 'action' => 'display'+ ),+ array (+ 'route' => '/configuration/import_export.php',+ 'controller' => 'configure',+ 'action' => 'importExport'+ ),+ array (+ 'route' => '/configuration/import_export.php\?q=([\w]{6})',+ 'controller' => 'configure',+ 'action' => 'importExport',+ 'params' => array ('q')+ ),+ array (+ 'route' => '/configuration/raccourcis.php',+ 'controller' => 'configure',+ 'action' => 'shortcut'+ ),);diff --git a/app/controllers/configureController.php b/app/controllers/configureController.phpindex 68fa0404a..a380e87c4 100755--- a/app/controllers/configureController.php+++ b/app/controllers/configureController.php@@ -46,7 +46,7 @@ class configureController extends ActionController {$this->view->categories = $catDAO->listCategories ();}- public function fluxAction () {+ public function feedAction () {$feedDAO = new FeedDAO ();$this->view->feeds = $feedDAO->listFeeds ();diff --git a/app/controllers/feedController.php b/app/controllers/feedController.phpindex 0c0528202..1450ce69e 100755--- a/app/controllers/feedController.php+++ b/app/controllers/feedController.php@@ -156,7 +156,7 @@ class feedController extends ActionController {$feedDAO = new FeedDAO ();$feedDAO->deleteFeed ($id);- Request::forward (array ('c' => 'configure', 'a' => 'flux'));+ Request::forward (array ('c' => 'configure', 'a' => 'feed'), true);}}}diff --git a/app/layout/aside.phtml b/app/layout/aside.phtmlindex 50af6c3b2..36e1bede2 100644--- a/app/layout/aside.phtml+++ b/app/layout/aside.phtml@@ -21,7 +21,7 @@</li><?php if (!login_is_conf ($this->conf) || is_logged ()) { ?><li <?php echo Request::controllerName () == 'configure' ? 'class="active"' : ''; ?>>- <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'flux')); ?>">Configurer</a>+ <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'feed')); ?>">Configurer</a></li><?php } ?><li>@@ -44,8 +44,8 @@<div class="aside"><ul id="menu"><li><h2>Configuration</h2></li>- <li <?php echo Request::actionName () == 'flux' ? 'class="active"' : ''; ?>>- <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'flux')); ?>">Flux RSS</a>+ <li <?php echo Request::actionName () == 'feed' ? 'class="active"' : ''; ?>>+ <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'feed')); ?>">Flux RSS</a></li><li <?php echo Request::actionName () == 'categorize' ? 'class="active"' : ''; ?>><a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'categorize')); ?>">Catégories</a>diff --git a/app/views/configure/flux.phtml b/app/views/configure/feed.phtmlsimilarity index 96%rename from app/views/configure/flux.phtmlrename to app/views/configure/feed.phtmlindex 1aa26c634..582457b63 100644--- a/app/views/configure/flux.phtml+++ b/app/views/configure/feed.phtml@@ -5,7 +5,7 @@<?php if (!empty ($this->feeds)) { ?><?php foreach ($this->feeds as $feed) { ?><li <?php echo ($this->flux && $this->flux->id () == $feed->id ()) ? 'class="active"' : ''; ?>>- <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'flux', 'params' => array ('id' => $feed->id ()))); ?>"><?php echo $feed->name (); ?></a>+ <a href="<?php echo Url::display (array ('c' => 'configure', 'a' => 'feed', 'params' => array ('id' => $feed->id ()))); ?>"><?php echo $feed->name (); ?></a></li><?php } ?><?php } else { ?>diff --git a/app/views/configure/shortcut.phtml b/app/views/configure/shortcut.phtmlindex 6fc253dd5..56718d566 100644--- a/app/views/configure/shortcut.phtml+++ b/app/views/configure/shortcut.phtml@@ -9,8 +9,9 @@<form method="post" action=""><h1>Gérer les raccourcis</h1>- <label for="mark_read">Marquer l'article comme lu</label>+ <label for="mark_read">Marquer l'article comme lu / non lu</label><input type="text" id="mark_read" name="shortcuts[mark_read]" list="keys" value="<?php echo $s['mark_read']; ?>" />+ <p>+ <code>shift</code> pour marquer tous les articles</p><label for="mark_favorite">Mettre l'article en favori</label><input type="text" id="mark_favorite" name="shortcuts[mark_favorite]" list="keys" value="<?php echo $s['mark_favorite']; ?>" />@@ -20,15 +21,19 @@<label for="next_entry">Passer à l'article suivant</label><input type="text" id="next_entry" name="shortcuts[next_entry]" list="keys" value="<?php echo $s['next_entry']; ?>" />+ <p>+ <code>shift</code> pour passer au dernier article de la page</p><label for="prev_entry">Passer à l'article précédent</label><input type="text" id="prev_entry" name="shortcuts[prev_entry]" list="keys" value="<?php echo $s['prev_entry']; ?>" />+ <p>+ <code>shift</code> pour passer au premier article de la page</p><label for="next_page">Passer à la page suivant</label><input type="text" id="next_page" name="shortcuts[next_page]" list="keys" value="<?php echo $s['next_page']; ?>" />+ <p>+ <code>shift</code> pour passer à la dernière page</p><label for="prev_page">Passer à la page précédente</label><input type="text" id="prev_page" name="shortcuts[prev_page]" list="keys" value="<?php echo $s['prev_page']; ?>" />+ <p>+ <code>shift</code> pour passer à la première page</p><input type="submit" value="Valider" /></form>diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtmlindex 641bfa00c..7d077d93f 100644--- a/app/views/javascript/main.phtml+++ b/app/views/javascript/main.phtml@@ -146,6 +146,14 @@ $(document).ready (function () {slide (last_active, old_active);}});+ shortcut.add("shift+<?php echo $s['prev_entry']; ?>", function () {+ old_active = $(".post.flux.active");+ first = $(".post.flux:first");++ if (first[0] instanceof HTMLDivElement) {+ slide (first, old_active);+ }+ });shortcut.add("<?php echo $s['next_entry']; ?>", function () {old_active = $(".post.flux.active");first_active = $(".post.flux:first");@@ -157,20 +165,28 @@ $(document).ready (function () {slide (first_active, old_active);}});+ shortcut.add("shift+<?php echo $s['next_entry']; ?>", function () {+ old_active = $(".post.flux.active");+ last = $(".post.flux:last");++ if (last[0] instanceof HTMLDivElement) {+ slide (last, old_active);+ }+ });shortcut.add("<?php echo $s['next_page']; ?>", function () {url = $(".pager-next a").attr ("href");- if (url === undefined) {- url = $(".pager-first a").attr ("href");- }-+ redirect (url);+ });+ shortcut.add("shift+<?php echo $s['next_page']; ?>", function () {+ url = $(".pager-last a").attr ("href");redirect (url);});shortcut.add("<?php echo $s['prev_page']; ?>", function () {url = $(".pager-previous a").attr ("href");- if (url === undefined) {- url = $(".pager-last a").attr ("href");- }-+ redirect (url);+ });+ shortcut.add("shift+<?php echo $s['prev_page']; ?>", function () {+ url = $(".pager-first a").attr ("href");redirect (url);});shortcut.add("<?php echo $s['go_website']; ?>", function () {diff --git a/lib/Router.php b/lib/Router.phpindex 9048b947a..acd366a98 100755--- a/lib/Router.php+++ b/lib/Router.php@@ -239,6 +239,6 @@ class Router {}}- return $uri;+ return str_replace ('&', '&', $uri);}}