diff options
author | Nicolas Lœuillet <nicolas@loeuillet.org> | 2016-08-23 16:49:12 +0200 |
---|---|---|
committer | Nicolas Lœuillet <nicolas@loeuillet.org> | 2016-08-23 16:49:21 +0200 |
commit | f1be7af446052c6fed7033664c6c6350f558961b (patch) | |
tree | 41889e7ace01b1f1df05ffb412bac0427d9975a2 | |
parent | 3377c938f8e5bd6af2cd4430494f39a517a7e910 (diff) | |
download | wallabag-f1be7af446052c6fed7033664c6c6350f558961b.tar.gz wallabag-f1be7af446052c6fed7033664c6c6350f558961b.tar.zst wallabag-f1be7af446052c6fed7033664c6c6350f558961b.zip |
Change share entry behavior
17 files changed, 81 insertions, 23 deletions
diff --git a/app/DoctrineMigrations/Version20160410190541.php b/app/DoctrineMigrations/Version20160410190541.php index f35f54ce..77c78c54 100644 --- a/app/DoctrineMigrations/Version20160410190541.php +++ b/app/DoctrineMigrations/Version20160410190541.php | |||
@@ -28,18 +28,6 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI | |||
28 | $this->addSql('ALTER TABLE `wallabag_entry` ADD `uuid` LONGTEXT DEFAULT NULL'); | 28 | $this->addSql('ALTER TABLE `wallabag_entry` ADD `uuid` LONGTEXT DEFAULT NULL'); |
29 | } | 29 | } |
30 | 30 | ||
31 | public function postUp(Schema $schema) | ||
32 | { | ||
33 | $em = $this->container->get('doctrine.orm.entity_manager'); | ||
34 | $repository = $em->getRepository('WallabagCoreBundle:Entry'); | ||
35 | $entries = $repository->findAll(); | ||
36 | |||
37 | /** @var Entry $entry */ | ||
38 | foreach ($entries as $entry) { | ||
39 | $this->addSql('UPDATE `wallabag_entry` SET `uuid` = "'.uniqid('', true).'" WHERE id = '.$entry->getId()); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | /** | 31 | /** |
44 | * @param Schema $schema | 32 | * @param Schema $schema |
45 | */ | 33 | */ |
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index c94b47f0..e500ad75 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -292,8 +292,6 @@ class EntryController extends Controller | |||
292 | { | 292 | { |
293 | $this->checkUserAction($entry); | 293 | $this->checkUserAction($entry); |
294 | 294 | ||
295 | $this->generateEntryUuid($entry); | ||
296 | |||
297 | return $this->render( | 295 | return $this->render( |
298 | 'WallabagCoreBundle:Entry:entry.html.twig', | 296 | 'WallabagCoreBundle:Entry:entry.html.twig', |
299 | ['entry' => $entry] | 297 | ['entry' => $entry] |
@@ -437,7 +435,7 @@ class EntryController extends Controller | |||
437 | */ | 435 | */ |
438 | private function checkUserAction(Entry $entry) | 436 | private function checkUserAction(Entry $entry) |
439 | { | 437 | { |
440 | if ($this->getUser()->getId() != $entry->getUser()->getId()) { | 438 | if (null === $this->getUser() || $this->getUser()->getId() != $entry->getUser()->getId()) { |
441 | throw $this->createAccessDeniedException('You can not access this entry.'); | 439 | throw $this->createAccessDeniedException('You can not access this entry.'); |
442 | } | 440 | } |
443 | } | 441 | } |
@@ -455,11 +453,56 @@ class EntryController extends Controller | |||
455 | } | 453 | } |
456 | 454 | ||
457 | /** | 455 | /** |
456 | * Get public URL for entry (and generate it if necessary). | ||
457 | * | ||
458 | * @param Entry $entry | ||
459 | * | ||
460 | * @Route("/share/{id}", requirements={"id" = "\d+"}, name="share") | ||
461 | * | ||
462 | * @return \Symfony\Component\HttpFoundation\Response | ||
463 | */ | ||
464 | public function shareAction(Entry $entry) | ||
465 | { | ||
466 | $this->checkUserAction($entry); | ||
467 | |||
468 | if ('' === $entry->getUuid() || null === $entry->getUuid()) { | ||
469 | $this->generateEntryUuid($entry); | ||
470 | } | ||
471 | |||
472 | return $this->redirect($this->generateUrl('share_entry', [ | ||
473 | 'uuid' => $entry->getUuid(), | ||
474 | ])); | ||
475 | } | ||
476 | |||
477 | /** | ||
478 | * Disable public sharing for an entry. | ||
479 | * | ||
480 | * @param Entry $entry | ||
481 | * | ||
482 | * @Route("/share/delete/{id}", requirements={"id" = "\d+"}, name="delete_share") | ||
483 | * | ||
484 | * @return \Symfony\Component\HttpFoundation\Response | ||
485 | */ | ||
486 | public function deleteShareAction(Entry $entry) | ||
487 | { | ||
488 | $this->checkUserAction($entry); | ||
489 | |||
490 | $entry->cleanUuid(); | ||
491 | $em = $this->getDoctrine()->getManager(); | ||
492 | $em->persist($entry); | ||
493 | $em->flush(); | ||
494 | |||
495 | return $this->redirect($this->generateUrl('view', [ | ||
496 | 'id' => $entry->getId(), | ||
497 | ])); | ||
498 | } | ||
499 | |||
500 | /** | ||
458 | * Share entry content. | 501 | * Share entry content. |
459 | * | 502 | * |
460 | * @param Entry $entry | 503 | * @param Entry $entry |
461 | * | 504 | * |
462 | * @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share") | 505 | * @Route("/share/{uuid}", requirements={"uuid" = ".+"}, name="share_entry") |
463 | * @Cache(maxage="25200", public=true) | 506 | * @Cache(maxage="25200", public=true) |
464 | * | 507 | * |
465 | * @return \Symfony\Component\HttpFoundation\Response | 508 | * @return \Symfony\Component\HttpFoundation\Response |
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index a629efc7..8c20cde2 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -436,8 +436,6 @@ class Entry | |||
436 | } | 436 | } |
437 | 437 | ||
438 | $this->updatedAt = new \DateTime(); | 438 | $this->updatedAt = new \DateTime(); |
439 | |||
440 | $this->generateUuid(); | ||
441 | } | 439 | } |
442 | 440 | ||
443 | /** | 441 | /** |
@@ -634,4 +632,9 @@ class Entry | |||
634 | $this->uuid = uniqid('', true); | 632 | $this->uuid = uniqid('', true); |
635 | } | 633 | } |
636 | } | 634 | } |
635 | |||
636 | public function cleanUuid() | ||
637 | { | ||
638 | $this->uuid = null; | ||
639 | } | ||
637 | } | 640 | } |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 2eb0b7b0..f9b7bfac 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml | |||
@@ -188,6 +188,7 @@ entry: | |||
188 | share_content: 'Deling' | 188 | share_content: 'Deling' |
189 | # share_email_label: 'Email' | 189 | # share_email_label: 'Email' |
190 | # public_link: 'public link' | 190 | # public_link: 'public link' |
191 | # delete_public_link: 'delete public link' | ||
191 | download: 'Download' | 192 | download: 'Download' |
192 | # print: 'Print' | 193 | # print: 'Print' |
193 | problem: | 194 | problem: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index 3d4ae9b3..79d03286 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml | |||
@@ -188,6 +188,7 @@ entry: | |||
188 | share_content: 'Teilen' | 188 | share_content: 'Teilen' |
189 | share_email_label: 'E-Mail' | 189 | share_email_label: 'E-Mail' |
190 | # public_link: 'public link' | 190 | # public_link: 'public link' |
191 | # delete_public_link: 'delete public link' | ||
191 | download: 'Herunterladen' | 192 | download: 'Herunterladen' |
192 | print: 'Drucken' | 193 | print: 'Drucken' |
193 | problem: | 194 | problem: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index b7a16446..d921b39f 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml | |||
@@ -188,6 +188,7 @@ entry: | |||
188 | share_content: 'Share' | 188 | share_content: 'Share' |
189 | share_email_label: 'Email' | 189 | share_email_label: 'Email' |
190 | public_link: 'public link' | 190 | public_link: 'public link' |
191 | delete_public_link: 'delete public link' | ||
191 | download: 'Download' | 192 | download: 'Download' |
192 | print: 'Print' | 193 | print: 'Print' |
193 | problem: | 194 | problem: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 0e4c0e6e..c2ec4dbd 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml | |||
@@ -188,6 +188,7 @@ entry: | |||
188 | share_content: 'Compartir' | 188 | share_content: 'Compartir' |
189 | share_email_label: 'Dirección e-mail' | 189 | share_email_label: 'Dirección e-mail' |
190 | # public_link: 'public link' | 190 | # public_link: 'public link' |
191 | # delete_public_link: 'delete public link' | ||
191 | download: 'Descargar' | 192 | download: 'Descargar' |
192 | print: 'Imprimir' | 193 | print: 'Imprimir' |
193 | problem: | 194 | problem: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index 3b36f6f2..561ed907 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml | |||
@@ -188,6 +188,7 @@ entry: | |||
188 | share_content: 'همرسانی' | 188 | share_content: 'همرسانی' |
189 | share_email_label: 'نشانی ایمیل' | 189 | share_email_label: 'نشانی ایمیل' |
190 | # public_link: 'public link' | 190 | # public_link: 'public link' |
191 | # delete_public_link: 'delete public link' | ||
191 | download: 'بارگیری' | 192 | download: 'بارگیری' |
192 | print: 'چاپ' | 193 | print: 'چاپ' |
193 | problem: | 194 | problem: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index df7c2271..c0671883 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml | |||
@@ -188,6 +188,7 @@ entry: | |||
188 | share_content: 'Partager' | 188 | share_content: 'Partager' |
189 | share_email_label: 'Email' | 189 | share_email_label: 'Email' |
190 | public_link: 'Lien public' | 190 | public_link: 'Lien public' |
191 | delete_public_link: 'Supprimer lien public' | ||
191 | download: 'Télécharger' | 192 | download: 'Télécharger' |
192 | print: 'Imprimer' | 193 | print: 'Imprimer' |
193 | problem: | 194 | problem: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 3760c2d6..2e3dd08b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml | |||
@@ -185,6 +185,8 @@ entry: | |||
185 | add_a_tag: 'Aggiungi un tag' | 185 | add_a_tag: 'Aggiungi un tag' |
186 | share_content: 'Condividi' | 186 | share_content: 'Condividi' |
187 | share_email_label: 'E-mail' | 187 | share_email_label: 'E-mail' |
188 | # public_link: 'public link' | ||
189 | # delete_public_link: 'delete public link' | ||
188 | download: 'Download' | 190 | download: 'Download' |
189 | print: 'Stampa' | 191 | print: 'Stampa' |
190 | problem: | 192 | problem: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index f3bfbd80..7b978a60 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml | |||
@@ -188,6 +188,7 @@ entry: | |||
188 | share_content: 'Partatjar' | 188 | share_content: 'Partatjar' |
189 | share_email_label: 'Corrièl' | 189 | share_email_label: 'Corrièl' |
190 | # public_link: 'public link' | 190 | # public_link: 'public link' |
191 | # delete_public_link: 'delete public link' | ||
191 | download: 'Telecargar' | 192 | download: 'Telecargar' |
192 | print: 'Imprimir' | 193 | print: 'Imprimir' |
193 | problem: | 194 | problem: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 93d3e91f..da170e4d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml | |||
@@ -188,6 +188,7 @@ entry: | |||
188 | share_content: 'Udostępnij' | 188 | share_content: 'Udostępnij' |
189 | share_email_label: 'Adres email' | 189 | share_email_label: 'Adres email' |
190 | # public_link: 'public link' | 190 | # public_link: 'public link' |
191 | # delete_public_link: 'delete public link' | ||
191 | download: 'Pobierz' | 192 | download: 'Pobierz' |
192 | print: 'Drukuj' | 193 | print: 'Drukuj' |
193 | problem: | 194 | problem: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 3ba1e078..fa2d6468 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml | |||
@@ -188,6 +188,7 @@ entry: | |||
188 | share_content: 'Dă mai departe' | 188 | share_content: 'Dă mai departe' |
189 | share_email_label: 'E-mail' | 189 | share_email_label: 'E-mail' |
190 | # public_link: 'public link' | 190 | # public_link: 'public link' |
191 | # delete_public_link: 'delete public link' | ||
191 | download: 'Descarcă' | 192 | download: 'Descarcă' |
192 | # print: 'Print' | 193 | # print: 'Print' |
193 | problem: | 194 | problem: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index f6337caa..05c31336 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml | |||
@@ -188,6 +188,7 @@ entry: | |||
188 | share_content: 'Paylaş' | 188 | share_content: 'Paylaş' |
189 | share_email_label: 'E-posta' | 189 | share_email_label: 'E-posta' |
190 | # public_link: 'public link' | 190 | # public_link: 'public link' |
191 | # delete_public_link: 'delete public link' | ||
191 | download: 'İndir' | 192 | download: 'İndir' |
192 | # print: 'Print' | 193 | # print: 'Print' |
193 | problem: | 194 | problem: |
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 585e4dd5..05bb378d 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,10 +101,15 @@ | |||
101 | <ul> | 101 | <ul> |
102 | {% if craue_setting('share_public') %} | 102 | {% if craue_setting('share_public') %} |
103 | <li> | 103 | <li> |
104 | <a href="{{ path('share', {'uuid': entry.uuid }) }}" target="_blank" class="tool public" title="{{ 'entry.view.left_menu.public_link'|trans }}"> | 104 | <a href="{{ path('share', {'id': entry.id }) }}" target="_blank" class="tool public" title="{{ 'entry.view.left_menu.public_link'|trans }}"> |
105 | <span>{{ 'entry.view.left_menu.public_link'|trans }}</span> | 105 | <span>{{ 'entry.view.left_menu.public_link'|trans }}</span> |
106 | </a> | 106 | </a> |
107 | </li> | 107 | </li> |
108 | <li> | ||
109 | <a href="{{ path('delete_share', {'id': entry.id }) }}" class="tool public" title="{{ 'entry.view.left_menu.delete_public_link'|trans }}"> | ||
110 | <span>{{ 'entry.view.left_menu.delete_public_link'|trans }}</span> | ||
111 | </a> | ||
112 | </li> | ||
108 | {% endif %} | 113 | {% endif %} |
109 | {% if craue_setting('share_twitter') %} | 114 | {% if craue_setting('share_twitter') %} |
110 | <li> | 115 | <li> |
diff --git a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php index c0133af4..07ff2772 100644 --- a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php | |||
@@ -33,7 +33,7 @@ class InstallCommandTest extends WallabagCoreTestCase | |||
33 | } | 33 | } |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * Ensure next tests will have a clean database | 36 | * Ensure next tests will have a clean database. |
37 | */ | 37 | */ |
38 | public static function tearDownAfterClass() | 38 | public static function tearDownAfterClass() |
39 | { | 39 | { |
diff --git a/var/SymfonyRequirements.php b/var/SymfonyRequirements.php index 841338f4..0a5de546 100644 --- a/var/SymfonyRequirements.php +++ b/var/SymfonyRequirements.php | |||
@@ -681,10 +681,17 @@ class SymfonyRequirements extends RequirementCollection | |||
681 | 681 | ||
682 | if (class_exists('Symfony\Component\Intl\Intl')) { | 682 | if (class_exists('Symfony\Component\Intl\Intl')) { |
683 | $this->addRecommendation( | 683 | $this->addRecommendation( |
684 | \Symfony\Component\Intl\Intl::getIcuDataVersion() === \Symfony\Component\Intl\Intl::getIcuVersion(), | 684 | \Symfony\Component\Intl\Intl::getIcuDataVersion() <= \Symfony\Component\Intl\Intl::getIcuVersion(), |
685 | sprintf('intl ICU version installed on your system (%s) should match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()), | 685 | sprintf('intl ICU version installed on your system is outdated (%s) and does not match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()), |
686 | 'In most cases you should be fine, but please verify there is no inconsistencies between data provided by Symfony and the intl extension. See https://github.com/symfony/symfony/issues/15007 for an example of inconsistencies you might run into.' | 686 | 'To get the latest internationalization data upgrade the ICU system package and the intl PHP extension.' |
687 | ); | 687 | ); |
688 | if (\Symfony\Component\Intl\Intl::getIcuDataVersion() <= \Symfony\Component\Intl\Intl::getIcuVersion()) { | ||
689 | $this->addRecommendation( | ||
690 | \Symfony\Component\Intl\Intl::getIcuDataVersion() === \Symfony\Component\Intl\Intl::getIcuVersion(), | ||
691 | sprintf('intl ICU version installed on your system (%s) does not match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()), | ||
692 | 'To avoid internationalization data incosistencies upgrade the symfony/intl component.' | ||
693 | ); | ||
694 | } | ||
688 | } | 695 | } |
689 | 696 | ||
690 | $this->addPhpIniRecommendation( | 697 | $this->addPhpIniRecommendation( |