aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2014-12-22 16:19:29 +0100
committerThomas Citharel <tcit@tcit.fr>2014-12-22 16:19:29 +0100
commite51487f93265521cf04d8752b0554bb1f05dd189 (patch)
treefdd4e5a6890ee09c12ac6ffffee6f53289f97965
parentf3917b1ee4bba812e82da57dd181f50d62926db4 (diff)
downloadwallabag-e51487f93265521cf04d8752b0554bb1f05dd189.tar.gz
wallabag-e51487f93265521cf04d8752b0554bb1f05dd189.tar.zst
wallabag-e51487f93265521cf04d8752b0554bb1f05dd189.zip
implemented ?random url
-rwxr-xr-xinc/poche/Poche.class.php9
-rwxr-xr-xthemes/baggy/home.twig2
2 files changed, 9 insertions, 2 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 2a8037cc..3c7a2c5a 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -303,6 +303,14 @@ class Poche
303 $this->messages->add('s', _('The tag has been successfully deleted')); 303 $this->messages->add('s', _('The tag has been successfully deleted'));
304 Tools::redirect(); 304 Tools::redirect();
305 break; 305 break;
306 /* For some unknown reason I can't get displayView() to work here (it redirects to home view afterwards). So here's a dirty fix which redirects directly to URL */
307 case 'random':
308 $count = $this->store->getEntriesByViewCount($view, $this->user->getId());
309 $id = rand(1,$count);
310 Tools::logm('get a random article');
311 Tools::redirect('?view=view&id=' . $id);
312 //$this->displayView('view', $id);
313 break;
306 default: 314 default:
307 break; 315 break;
308 } 316 }
@@ -445,7 +453,6 @@ class Poche
445 $tpl_vars['entries'] = $this->store->getEntriesByView($view, $this->user->getId(), $this->pagination->get_limit(), $id); 453 $tpl_vars['entries'] = $this->store->getEntriesByView($view, $this->user->getId(), $this->pagination->get_limit(), $id);
446 $tpl_vars['page_links'] = $page_links; 454 $tpl_vars['page_links'] = $page_links;
447 $tpl_vars['nb_results'] = $count; 455 $tpl_vars['nb_results'] = $count;
448 $tpl_vars['random'] = rand(1,$count);
449 } 456 }
450 Tools::logm('display ' . $view . ' view'); 457 Tools::logm('display ' . $view . ' view');
451 break; 458 break;
diff --git a/themes/baggy/home.twig b/themes/baggy/home.twig
index 5068f755..27eea422 100755
--- a/themes/baggy/home.twig
+++ b/themes/baggy/home.twig
@@ -25,7 +25,7 @@
25 {% block pager %} 25 {% block pager %}
26 {% if nb_results > 1 %} 26 {% if nb_results > 1 %}
27 <div class="results"> 27 <div class="results">
28 <div class="nb-results">{{ nb_results }} {% trans "results" %}{% if search_term is defined %} {% trans %}found for « {{ search_term }} »{% endtrans %}{% endif %} <span class="icon icon-random"><a href="?view=view&id={{ random }}"> {% trans "random" %}</span></div> 28 <div class="nb-results">{{ nb_results }} {% trans "results" %}{% if search_term is defined %} {% trans %}found for « {{ search_term }} »{% endtrans %}{% endif %} <span class="icon icon-random"><a href="?action=random"> {% trans "random" %}</span></div>
29 {{ page_links | raw }} 29 {{ page_links | raw }}
30 </div> 30 </div>
31 {% elseif nb_results == 1 %} 31 {% elseif nb_results == 1 %}