aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php97
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig2
3 files changed, 16 insertions, 85 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index 669e15d7..ab50ebdf 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -249,73 +249,28 @@ class EntryController extends Controller
249 } 249 }
250 250
251 /** 251 /**
252 * Shows random unread entry. 252 * Shows random entry depending on the given type.
253 * 253 *
254 * @param Entry $entry 254 * @param Entry $entry
255 * 255 *
256 * @Route("/unread/random", name="unread_random") 256 * @Route("/{type}/random", name="random_entry", requirements={"_locale": "unread|starred|archive|untagged|all"})
257 * 257 *
258 * @return \Symfony\Component\HttpFoundation\Response 258 * @return \Symfony\Component\HttpFoundation\RedirectResponse
259 */
260 public function showRandomUnreadEntryAction()
261 {
262 return $this->showRandomEntries('unread');
263 }
264
265 /**
266 * Shows random favorite entry.
267 *
268 * @param Entry $entry
269 *
270 * @Route("/starred/random", name="starred_random")
271 *
272 * @return \Symfony\Component\HttpFoundation\Response
273 */
274 public function showRandomStarredEntryAction()
275 {
276 return $this->showRandomEntries('starred');
277 }
278
279 /**
280 * Shows random archived entry.
281 *
282 * @param Entry $entry
283 *
284 * @Route("/archive/random", name="archive_random")
285 *
286 * @return \Symfony\Component\HttpFoundation\Response
287 */ 259 */
288 public function showRandomArchiveEntryAction() 260 public function redirectRandomEntryAction($type = 'all')
289 { 261 {
290 return $this->showRandomEntries('archive'); 262 try {
291 } 263 $entry = $this->get('wallabag_core.entry_repository')
264 ->getRandomEntry($this->getUser()->getId(), $type);
265 } catch (NoResultException $e) {
266 $bag = $this->get('session')->getFlashBag();
267 $bag->clear();
268 $bag->add('notice', 'flashes.entry.notice.no_random_entry');
292 269
293 /** 270 return $this->redirect($this->generateUrl('homepage'));
294 * Shows random all entry. 271 }
295 *
296 * @param Entry $entry
297 *
298 * @Route("/untagged/random", name="untagged_random")
299 *
300 * @return \Symfony\Component\HttpFoundation\Response
301 */
302 public function showRandomUntaggedEntryAction()
303 {
304 return $this->showRandomEntries('untagged');
305 }
306 272
307 /** 273 return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
308 * Shows random all entry.
309 *
310 * @param Entry $entry
311 *
312 * @Route("/all/random", name="all_random")
313 *
314 * @return \Symfony\Component\HttpFoundation\Response
315 */
316 public function showRandomAllEntryAction()
317 {
318 return $this->showRandomEntries();
319 } 274 }
320 275
321 /** 276 /**
@@ -624,30 +579,6 @@ class EntryController extends Controller
624 } 579 }
625 580
626 /** 581 /**
627 * Global method to retrieve random entries depending on the given type.
628 *
629 * @param string $type Entries type: unread, starred, archive or untagged
630 *
631 * @return \Symfony\Component\HttpFoundation\RedirectResponse
632 */
633 private function showRandomEntries($type)
634 {
635 $repository = $this->get('wallabag_core.entry_repository');
636
637 try {
638 $entry = $repository->getRandomEntry($this->getUser()->getId(), $type);
639 } catch (NoResultException $e) {
640 $bag = $this->get('session')->getFlashBag();
641 $bag->clear();
642 $bag->add('notice', 'flashes.entry.notice.no_random_entry');
643
644 return $this->redirect($this->generateUrl('homepage'));
645 }
646
647 return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
648 }
649
650 /**
651 * Fetch content and update entry. 582 * Fetch content and update entry.
652 * In case it fails, $entry->getContent will return an error message. 583 * In case it fails, $entry->getContent will return an error message.
653 * 584 *
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig
index 7108efbd..f3baae2c 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig
@@ -28,7 +28,7 @@
28 <div class="nb-results">{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}</div> 28 <div class="nb-results">{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}</div>
29 <div class="pagination"> 29 <div class="pagination">
30 <a href="{{ path('switch_view_mode') }}"><i class="listMode-btn material-icons md-24">{% if listMode == 0 %}list{% else %}view_module{% endif %}</i></a> 30 <a href="{{ path('switch_view_mode') }}"><i class="listMode-btn material-icons md-24">{% if listMode == 0 %}list{% else %}view_module{% endif %}</i></a>
31 <a href="{{ path(currentRoute ~ '_random') }}">random</a> 31 <a href="{{ path('random_entry', { 'type': currentRoute }) }}">random</a>
32 {% if app.user.config.rssToken %} 32 {% if app.user.config.rssToken %}
33 {% include "@WallabagCore/themes/common/Entry/_rss_link.html.twig" %} 33 {% include "@WallabagCore/themes/common/Entry/_rss_link.html.twig" %}
34 {% endif %} 34 {% endif %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
index 5deda0fc..31c4b5cb 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
@@ -28,7 +28,7 @@
28 <div class="nb-results"> 28 <div class="nb-results">
29 {{ 'entry.list.number_on_the_page'|transchoice(entries.count) }} 29 {{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}
30 <a href="{{ path('switch_view_mode') }}"><i class="material-icons">{% if listMode == 0 %}view_list{% else %}view_module{% endif %}</i></a> 30 <a href="{{ path('switch_view_mode') }}"><i class="material-icons">{% if listMode == 0 %}view_list{% else %}view_module{% endif %}</i></a>
31 <a href="{{ path(currentRoute ~ '_random') }}">random</a> 31 <a href="{{ path('random_entry', { 'type': currentRoute }) }}">random</a>
32 {% if app.user.config.rssToken %} 32 {% if app.user.config.rssToken %}
33 {% include "@WallabagCore/themes/common/Entry/_rss_link.html.twig" %} 33 {% include "@WallabagCore/themes/common/Entry/_rss_link.html.twig" %}
34 {% endif %} 34 {% endif %}