aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2019-04-01 13:16:15 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2019-04-01 13:16:15 +0200
commit3620dae1e6b3fab5a4ba4001b4581ce7ed795996 (patch)
tree775d2fe5b2942d9231888ed01d0a0081a1b2347e /src/Wallabag
parentb886ee923d7e627da2ae0221271bedbcb495025a (diff)
parentbfd69c74e5b4f2ebfcb304b1983bf771c2bb11f7 (diff)
downloadwallabag-3620dae1e6b3fab5a4ba4001b4581ce7ed795996.tar.gz
wallabag-3620dae1e6b3fab5a4ba4001b4581ce7ed795996.tar.zst
wallabag-3620dae1e6b3fab5a4ba4001b4581ce7ed795996.zip
Merge remote-tracking branch 'origin/master' into 2.4
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php21
-rw-r--r--src/Wallabag/CoreBundle/Helper/ContentProxy.php13
-rw-r--r--src/Wallabag/CoreBundle/Helper/EntriesExport.php18
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_actions.html.twig12
4 files changed, 40 insertions, 24 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index 16d8a40b..5c850091 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -568,18 +568,31 @@ class EntryRestController extends WallabagRestController
568 * @ApiDoc( 568 * @ApiDoc(
569 * requirements={ 569 * requirements={
570 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"} 570 * {"name"="entry", "dataType"="integer", "requirement"="\w+", "description"="The entry ID"}
571 * },
572 * parameters={
573 * {"name"="expect", "dataType"="string", "required"=false, "format"="id or entry", "description"="Only returns the id instead of the deleted entry's full entity if 'id' is specified. Default to entry"},
571 * } 574 * }
572 * ) 575 * )
573 * 576 *
574 * @return JsonResponse 577 * @return JsonResponse
575 */ 578 */
576 public function deleteEntriesAction(Entry $entry) 579 public function deleteEntriesAction(Entry $entry, Request $request)
577 { 580 {
581 $expect = $request->query->get('expect', 'entry');
582 if (!\in_array($expect, ['id', 'entry'], true)) {
583 throw new BadRequestHttpException(sprintf("expect: 'id' or 'entry' expected, %s given", $expect));
584 }
578 $this->validateAuthentication(); 585 $this->validateAuthentication();
579 $this->validateUserAccess($entry->getUser()->getId()); 586 $this->validateUserAccess($entry->getUser()->getId());
580 587
581 // We copy $entry to keep id in returned object 588 $response = $this->sendResponse([
582 $e = $entry; 589 'id' => $entry->getId(),
590 ]);
591 // We clone $entry to keep id in returned object
592 if ('entry' === $expect) {
593 $e = clone $entry;
594 $response = $this->sendResponse($e);
595 }
583 596
584 $em = $this->getDoctrine()->getManager(); 597 $em = $this->getDoctrine()->getManager();
585 $em->remove($entry); 598 $em->remove($entry);
@@ -588,7 +601,7 @@ class EntryRestController extends WallabagRestController
588 // entry deleted, dispatch event about it! 601 // entry deleted, dispatch event about it!
589 $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry)); 602 $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
590 603
591 return $this->sendResponse($e); 604 return $response;
592 } 605 }
593 606
594 /** 607 /**
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index d38811a2..31953f12 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -256,18 +256,17 @@ class ContentProxy
256 $entry->setTitle($content['open_graph']['og_title']); 256 $entry->setTitle($content['open_graph']['og_title']);
257 } 257 }
258 258
259 $html = $content['html']; 259 if (empty($content['html'])) {
260 if (false === $html) { 260 $content['html'] = $this->fetchingErrorMessage;
261 $html = $this->fetchingErrorMessage;
262 261
263 if (!empty($content['open_graph']['og_description'])) { 262 if (!empty($content['open_graph']['og_description'])) {
264 $html .= '<p><i>But we found a short description: </i></p>'; 263 $content['html'] .= '<p><i>But we found a short description: </i></p>';
265 $html .= $content['open_graph']['og_description']; 264 $content['html'] .= $content['open_graph']['og_description'];
266 } 265 }
267 } 266 }
268 267
269 $entry->setContent($html); 268 $entry->setContent($content['html']);
270 $entry->setReadingTime(Utils::getReadingTime($html)); 269 $entry->setReadingTime(Utils::getReadingTime($content['html']));
271 270
272 if (!empty($content['status'])) { 271 if (!empty($content['status'])) {
273 $entry->setHttpStatus($content['status']); 272 $entry->setHttpStatus($content['status']);
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
index 64591687..f981ee50 100644
--- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php
+++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
@@ -165,13 +165,6 @@ class EntriesExport
165 $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, 'PHP'); 165 $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, 'PHP');
166 $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, 'wallabag'); 166 $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, 'wallabag');
167 167
168 /*
169 * Front page
170 */
171 if (file_exists($this->logoPath)) {
172 $book->setCoverImage('Cover.png', file_get_contents($this->logoPath), 'image/png');
173 }
174
175 $entryIds = []; 168 $entryIds = [];
176 $entryCount = \count($this->entries); 169 $entryCount = \count($this->entries);
177 $i = 0; 170 $i = 0;
@@ -183,10 +176,19 @@ class EntriesExport
183 // set tags as subjects 176 // set tags as subjects
184 foreach ($this->entries as $entry) { 177 foreach ($this->entries as $entry) {
185 ++$i; 178 ++$i;
179
180 /*
181 * Front page
182 * Set if there's only one entry in the given set
183 */
184 if (1 === $entryCount && null !== $entry->getPreviewPicture()) {
185 $book->setCoverImage($entry->getPreviewPicture());
186 }
187
186 foreach ($entry->getTags() as $tag) { 188 foreach ($entry->getTags() as $tag) {
187 $book->setSubject($tag->getLabel()); 189 $book->setSubject($tag->getLabel());
188 } 190 }
189 $filename = sha1($entry->getTitle()); 191 $filename = sha1(sprintf('%s:%s', $entry->getUrl(), $entry->getTitle()));
190 192
191 $publishedBy = $entry->getPublishedBy(); 193 $publishedBy = $entry->getPublishedBy();
192 $authors = $this->translator->trans('export.unknown'); 194 $authors = $this->translator->trans('export.unknown');
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_actions.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_actions.html.twig
index 827f09d9..be764e10 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_actions.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_actions.html.twig
@@ -1,9 +1,11 @@
1<div class="card-action"> 1<div class="card-action">
2 <span class="reading-time grey-text"> 2 <div class="reading-time grey-text">
3 {% include "@WallabagCore/themes/material/Entry/_reading_time.html.twig" with {'entry': entry} only %} 3 <div class="card-reading-time">{% include "@WallabagCore/themes/material/Entry/_reading_time.html.twig" with {'entry': entry} only %}</div>
4 <i class="material-icons hide-on-med-and-down" title="{{ 'entry.view.created_at'|trans }}">today</i> 4 <div class="card-created-at">
5 <span class="hide-on-med-and-down">&nbsp;{{ entry.createdAt|date('Y-m-d') }}</span> 5 <i class="material-icons" title="{{ 'entry.view.created_at'|trans }}">today</i>
6 </span> 6 <span>&nbsp;{{ entry.createdAt|date('Y-m-d') }}</span>
7 </div>
8 </div>
7 9
8 <ul class="tools right"> 10 <ul class="tools right">
9 <li> 11 <li>