From 831b02aaf2709d632453a03ab8eb2663fb947497 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 30 Dec 2015 09:41:17 +0100 Subject: [PATCH] Ability to reload an entry Could be useful when we want to update the content or when the content failed to be fetched. Fix #1503 --- .../CoreBundle/Controller/EntryController.php | 27 ++++++++++++++++ .../views/themes/baggy/Entry/entry.html.twig | 1 + .../themes/material/Entry/entry.html.twig | 8 +++++ .../Tests/Controller/EntryControllerTest.php | 32 +++++++++++++++++++ 4 files changed, 68 insertions(+) diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 2f3fd6a9..041fe71c 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -266,6 +266,33 @@ class EntryController extends Controller ); } + /** + * Reload an entry. + * Refetch content from the website and make it readable again. + * + * @param Entry $entry + * + * @Route("/reload/{id}", requirements={"id" = "\d+"}, name="reload_entry") + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + public function reloadAction(Entry $entry) + { + $this->checkUserAction($entry); + + $message = 'Entry reloaded'; + if (false === $this->updateEntry($entry)) { + $message = 'Failed to reload entry'; + } + + $this->get('session')->getFlashBag()->add( + 'notice', + $message + ); + + return $this->redirect($this->generateUrl('view', array('id' => $entry->getId()))); + } + /** * Changes read status for an entry. * diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig index b3f47098..7b7135e9 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig @@ -7,6 +7,7 @@