aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2015-12-30 09:41:17 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2015-12-30 09:41:17 +0100
commit831b02aaf2709d632453a03ab8eb2663fb947497 (patch)
tree65ff2b6ecdb30ba8d6c5d742b0bf3e248e5c8ea6
parente6a228c43bf98f64d2d046314bae224c5b87399e (diff)
downloadwallabag-831b02aaf2709d632453a03ab8eb2663fb947497.tar.gz
wallabag-831b02aaf2709d632453a03ab8eb2663fb947497.tar.zst
wallabag-831b02aaf2709d632453a03ab8eb2663fb947497.zip
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
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php27
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig8
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php32
4 files changed, 68 insertions, 0 deletions
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
@@ -267,6 +267,33 @@ class EntryController extends Controller
267 } 267 }
268 268
269 /** 269 /**
270 * Reload an entry.
271 * Refetch content from the website and make it readable again.
272 *
273 * @param Entry $entry
274 *
275 * @Route("/reload/{id}", requirements={"id" = "\d+"}, name="reload_entry")
276 *
277 * @return \Symfony\Component\HttpFoundation\RedirectResponse
278 */
279 public function reloadAction(Entry $entry)
280 {
281 $this->checkUserAction($entry);
282
283 $message = 'Entry reloaded';
284 if (false === $this->updateEntry($entry)) {
285 $message = 'Failed to reload entry';
286 }
287
288 $this->get('session')->getFlashBag()->add(
289 'notice',
290 $message
291 );
292
293 return $this->redirect($this->generateUrl('view', array('id' => $entry->getId())));
294 }
295
296 /**
270 * Changes read status for an entry. 297 * Changes read status for an entry.
271 * 298 *
272 * @param Request $request 299 * @param Request $request
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 @@
7 <ul class="links"> 7 <ul class="links">
8 <li class="topPosF"><a href="#top" title="{% trans %}Back to top{% endtrans %}" class="tool top icon icon-arrow-up-thick"><span>{% trans %}Back to top{% endtrans %}</span></a></li> 8 <li class="topPosF"><a href="#top" title="{% trans %}Back to top{% endtrans %}" class="tool top icon icon-arrow-up-thick"><span>{% trans %}Back to top{% endtrans %}</span></a></li>
9 <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link icon icon-link"><span>{{ entry.domainName|removeWww }}</span></a></li> 9 <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link icon icon-link"><span>{{ entry.domainName|removeWww }}</span></a></li>
10 <li><a title="{% trans %}Reload content{% endtrans %}" href="{{ path('reload_entry', { 'id': entry.id }) }}"><span>{% trans %}Reload content{% endtrans %}</span></a></li>
10 <li><a title="{% trans %}Mark as read{% endtrans %}" class="tool icon icon-check {% if entry.isArchived == 0 %}archive-off{% else %}archive{% endif %}" href="{{ path('archive_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li> 11 <li><a title="{% trans %}Mark as read{% endtrans %}" class="tool icon icon-check {% if entry.isArchived == 0 %}archive-off{% else %}archive{% endif %}" href="{{ path('archive_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle mark as read{% endtrans %}</span></a></li>
11 <li><a title="{% trans %}Favorite{% endtrans %}" class="tool icon icon-star {% if entry.isStarred == 0 %}fav-off{% else %}fav{% endif %}" href="{{ path('star_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle favorite{% endtrans %}</span></a></li> 12 <li><a title="{% trans %}Favorite{% endtrans %}" class="tool icon icon-star {% if entry.isStarred == 0 %}fav-off{% else %}fav{% endif %}" href="{{ path('star_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle favorite{% endtrans %}</span></a></li>
12 <li><a title="{% trans %}Delete{% endtrans %}" class="tool delete icon icon-trash" href="{{ path('delete_entry', { 'id': entry.id }) }}"><span>{% trans %}Delete{% endtrans %}</span></a></li> 13 <li><a title="{% trans %}Delete{% endtrans %}" class="tool delete icon icon-trash" href="{{ path('delete_entry', { 'id': entry.id }) }}"><span>{% trans %}Delete{% endtrans %}</span></a></li>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
index fd84d984..8140f360 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
@@ -52,6 +52,14 @@
52 </li> 52 </li>
53 53
54 <li class="bold hide-on-med-and-down"> 54 <li class="bold hide-on-med-and-down">
55 <a class="waves-effect collapsible-header" title="{% trans %}Reload content{% endtrans %}" href="{{ path('reload_entry', { 'id': entry.id }) }}" id="reload">
56 <i class="mdi-action-autorenew small"></i>
57 <span>{% trans %}Reload content{% endtrans %}</span>
58 </a>
59 <div class="collapsible-body"></div>
60 </li>
61
62 <li class="bold hide-on-med-and-down">
55 <a class="waves-effect collapsible-header" title="{% trans %}Mark as read{% endtrans %}" href="{{ path('archive_entry', { 'id': entry.id }) }}" id="markAsRead"> 63 <a class="waves-effect collapsible-header" title="{% trans %}Mark as read{% endtrans %}" href="{{ path('archive_entry', { 'id': entry.id }) }}" id="markAsRead">
56 <i class="{% if entry.isArchived == 0 %}mdi-action-done{% else %}mdi-content-redo{% endif %} small"></i> 64 <i class="{% if entry.isArchived == 0 %}mdi-action-done{% else %}mdi-content-redo{% endif %} small"></i>
57 <span>{% trans %}Mark as read{% endtrans %}</span> 65 <span>{% trans %}Mark as read{% endtrans %}</span>
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index 9f585d85..96f402b0 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -180,6 +180,38 @@ class EntryControllerTest extends WallabagCoreTestCase
180 $this->assertContains($content->getTitle(), $client->getResponse()->getContent()); 180 $this->assertContains($content->getTitle(), $client->getResponse()->getContent());
181 } 181 }
182 182
183 /**
184 * @depends testPostNewOk
185 *
186 * This test will require an internet connection.
187 */
188 public function testReload()
189 {
190 $this->logInAs('admin');
191 $client = $this->getClient();
192
193 $content = $client->getContainer()
194 ->get('doctrine.orm.entity_manager')
195 ->getRepository('WallabagCoreBundle:Entry')
196 ->findOneByUrl($this->url);
197
198 // empty content
199 $content->setContent('');
200 $client->getContainer()->get('doctrine.orm.entity_manager')->persist($content);
201 $client->getContainer()->get('doctrine.orm.entity_manager')->flush();
202
203 $client->request('GET', '/reload/'.$content->getId());
204
205 $this->assertEquals(302, $client->getResponse()->getStatusCode());
206
207 $content = $client->getContainer()
208 ->get('doctrine.orm.entity_manager')
209 ->getRepository('WallabagCoreBundle:Entry')
210 ->findOneByUrl($this->url);
211
212 $this->assertNotEmpty($content->getContent());
213 }
214
183 public function testEdit() 215 public function testEdit()
184 { 216 {
185 $this->logInAs('admin'); 217 $this->logInAs('admin');