diff options
Diffstat (limited to 'src/Wallabag')
4 files changed, 115 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 93db0d6c..a78dd00c 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -291,6 +291,8 @@ class EntryController extends Controller | |||
291 | { | 291 | { |
292 | $this->checkUserAction($entry); | 292 | $this->checkUserAction($entry); |
293 | 293 | ||
294 | $this->generateEntryUuid($entry); | ||
295 | |||
294 | return $this->render( | 296 | return $this->render( |
295 | 'WallabagCoreBundle:Entry:entry.html.twig', | 297 | 'WallabagCoreBundle:Entry:entry.html.twig', |
296 | ['entry' => $entry] | 298 | ['entry' => $entry] |
@@ -449,5 +451,34 @@ class EntryController extends Controller | |||
449 | private function checkIfEntryAlreadyExists(Entry $entry) | 451 | private function checkIfEntryAlreadyExists(Entry $entry) |
450 | { | 452 | { |
451 | return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId()); | 453 | return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId()); |
454 | |||
455 | } | ||
456 | |||
457 | /* | ||
458 | * Share entry content. | ||
459 | * | ||
460 | * @param Entry $entry | ||
461 | * | ||
462 | * @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share") | ||
463 | * | ||
464 | * @return \Symfony\Component\HttpFoundation\Response | ||
465 | */ | ||
466 | public function shareEntry(Entry $entry) | ||
467 | { | ||
468 | return $this->render( | ||
469 | '@WallabagCore/themes/share.html.twig', | ||
470 | array('entry' => $entry) | ||
471 | ); | ||
472 | } | ||
473 | |||
474 | /** | ||
475 | * @param Entry $entry | ||
476 | */ | ||
477 | private function generateEntryUuid(Entry $entry) | ||
478 | { | ||
479 | $entry->generateUuid(); | ||
480 | $em = $this->getDoctrine()->getManager(); | ||
481 | $em->persist($entry); | ||
482 | $em->flush(); | ||
452 | } | 483 | } |
453 | } | 484 | } |
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index ceae78b0..3c742828 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -38,6 +38,15 @@ class Entry | |||
38 | private $id; | 38 | private $id; |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * @var int | ||
42 | * | ||
43 | * @ORM\Column(name="uuid", type="text", nullable=true) | ||
44 | * | ||
45 | * @Groups({"entries_for_user", "export_all"}) | ||
46 | */ | ||
47 | private $uuid; | ||
48 | |||
49 | /** | ||
41 | * @var string | 50 | * @var string |
42 | * | 51 | * |
43 | * @ORM\Column(name="title", type="text", nullable=true) | 52 | * @ORM\Column(name="title", type="text", nullable=true) |
@@ -427,6 +436,8 @@ class Entry | |||
427 | } | 436 | } |
428 | 437 | ||
429 | $this->updatedAt = new \DateTime(); | 438 | $this->updatedAt = new \DateTime(); |
439 | |||
440 | $this->generateUuid(); | ||
430 | } | 441 | } |
431 | 442 | ||
432 | /** | 443 | /** |
@@ -595,4 +606,31 @@ class Entry | |||
595 | { | 606 | { |
596 | return $this->language; | 607 | return $this->language; |
597 | } | 608 | } |
609 | |||
610 | /** | ||
611 | * @return int | ||
612 | */ | ||
613 | public function getUuid() | ||
614 | { | ||
615 | return $this->uuid; | ||
616 | } | ||
617 | |||
618 | /** | ||
619 | * @param int $uuid | ||
620 | * | ||
621 | * @return Entry | ||
622 | */ | ||
623 | public function setUuid($uuid) | ||
624 | { | ||
625 | $this->uuid = $uuid; | ||
626 | |||
627 | return $this; | ||
628 | } | ||
629 | |||
630 | public function generateUuid() | ||
631 | { | ||
632 | if (empty($this->uuid) || is_null($this->uuid)) { | ||
633 | $this->uuid = uniqid(); | ||
634 | } | ||
635 | } | ||
598 | } | 636 | } |
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 5dd2afb3..b634dd40 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 | |||
@@ -101,6 +101,13 @@ | |||
101 | <ul> | 101 | <ul> |
102 | {% if craue_setting('share_twitter') %} | 102 | {% if craue_setting('share_twitter') %} |
103 | <li> | 103 | <li> |
104 | <a href="{{ path('share', {'uuid': entry.uuid }) }}" target="_blank" class="tool public" title="public"> | ||
105 | <span>public</span> | ||
106 | </a> | ||
107 | </li> | ||
108 | {% endif %} | ||
109 | {% if craue_setting('share_twitter') %} | ||
110 | <li> | ||
104 | <a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@wallabagapp" target="_blank" class="tool twitter icon icon-twitter" title="twitter"> | 111 | <a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@wallabagapp" target="_blank" class="tool twitter icon icon-twitter" title="twitter"> |
105 | <span>twitter</span> | 112 | <span>twitter</span> |
106 | </a> | 113 | </a> |
@@ -149,7 +156,6 @@ | |||
149 | </li> | 156 | </li> |
150 | {% endif %} | 157 | {% endif %} |
151 | 158 | ||
152 | |||
153 | <li class="bold"> | 159 | <li class="bold"> |
154 | <a class="waves-effect collapsible-header"> | 160 | <a class="waves-effect collapsible-header"> |
155 | <i class="material-icons small">file_download</i> | 161 | <i class="material-icons small">file_download</i> |
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/share.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/share.html.twig new file mode 100644 index 00000000..37ca14f1 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/share.html.twig | |||
@@ -0,0 +1,39 @@ | |||
1 | <html> | ||
2 | <head> | ||
3 | <title>{{ entry.title | raw }}</title> | ||
4 | <style> | ||
5 | body { | ||
6 | margin: 10px; | ||
7 | font-family: 'Roboto',Verdana,Geneva,sans-serif; | ||
8 | font-size: 16px; | ||
9 | color: #000; | ||
10 | } | ||
11 | header { | ||
12 | text-align: center; | ||
13 | } | ||
14 | |||
15 | header h1 { | ||
16 | font-size: 1.3em; | ||
17 | } | ||
18 | |||
19 | a, | ||
20 | a:hover, | ||
21 | a:visited { | ||
22 | color: #000; | ||
23 | } | ||
24 | |||
25 | article { | ||
26 | margin: 0 auto; | ||
27 | width: 600px; | ||
28 | } | ||
29 | </style> | ||
30 | </head> | ||
31 | <body> | ||
32 | <header> | ||
33 | <h1>{{ entry.title | raw }}</h1> | ||
34 | </header> | ||
35 | <article> | ||
36 | {{ entry.content | raw }} | ||
37 | </article> | ||
38 | </body> | ||
39 | </html> | ||