From: Jeremy Benoist Date: Sun, 2 Oct 2016 09:06:03 +0000 (+0200) Subject: Merge pull request #2326 from wallabag/update-quickstart X-Git-Tag: 2.1.0~10 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=52c1fc7449554c942c945e6c740e0e11d2f60a0d;hp=24ad330be6be01af05091fe044183e95b4a0ebd8;p=github%2Fwallabag%2Fwallabag.git Merge pull request #2326 from wallabag/update-quickstart Changed quickstart layout --- diff --git a/app/config/config.yml b/app/config/config.yml index b5d82ed9..fbebfee7 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -64,6 +64,7 @@ twig: strict_variables: "%kernel.debug%" form_themes: - "LexikFormFilterBundle:Form:form_div_layout.html.twig" + exception_controller: wallabag_core.exception_controller:showAction # Doctrine Configuration doctrine: diff --git a/app/config/services.yml b/app/config/services.yml index 76bbce27..a57ef0f3 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -21,6 +21,7 @@ services: - "@wallabag_core.tag_repository" - "@security.token_storage" - "%wallabag_core.cache_lifetime%" + - "@translator" tags: - { name: twig.extension } diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index 29d27c3a..1fb1f298 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -4,9 +4,10 @@ FROM php:fpm ARG timezone='Europe/Paris' RUN apt-get update && apt-get install -y \ - libmcrypt-dev libicu-dev libpq-dev libxml2-dev \ + libmcrypt-dev libicu-dev libpq-dev libxml2-dev libpng12-dev libjpeg-dev \ + && /usr/local/bin/docker-php-ext-configure gd --with-jpeg-dir=/usr/include \ && docker-php-ext-install \ - iconv mcrypt mbstring intl pdo pdo_mysql pdo_pgsql + iconv mcrypt mbstring intl pdo pdo_mysql pdo_pgsql gd RUN echo "date.timezone="$timezone > /usr/local/etc/php/conf.d/date_timezone.ini diff --git a/docs/de/developer/docker.rst b/docs/de/developer/docker.rst index c63194aa..9948fe8c 100644 --- a/docs/de/developer/docker.rst +++ b/docs/de/developer/docker.rst @@ -44,7 +44,7 @@ wallabag laufen lassen Eigenschaften mit den kommentierten zu ersetzen (mit Werten mit ``env.`` Präfix) #. ``composer install`` die Projektabhängigkeiten -#. ``php app/console wallabag:install``, um das Schema zu erstellen +#. ``php bin/console wallabag:install``, um das Schema zu erstellen #. ``docker-compose up`` um die Container laufen zu lassen #. Schließlich öffne http://localhost:8080/, um dein frisch installiertes wallabag zu finden. diff --git a/docs/en/developer/docker.rst b/docs/en/developer/docker.rst index 8816cbcf..5e4f2ce6 100644 --- a/docs/en/developer/docker.rst +++ b/docs/en/developer/docker.rst @@ -40,7 +40,7 @@ Run wallabag #. Edit ``app/config/parameters.yml`` to replace ``database_*`` properties with commented ones (with values prefixed by ``env.``) #. ``composer install`` the project dependencies -#. ``php app/console wallabag:install`` to create the schema +#. ``php bin/console wallabag:install`` to create the schema #. ``docker-compose up`` to run the containers #. Finally, browse to http://localhost:8080/ to find your freshly installed wallabag. diff --git a/docs/fr/developer/docker.rst b/docs/fr/developer/docker.rst index 73cb56be..84724ed3 100644 --- a/docs/fr/developer/docker.rst +++ b/docs/fr/developer/docker.rst @@ -39,7 +39,7 @@ Exécuter wallabag #. Editer ``app/config/parameters.yml`` pour remplacer les propriétés ``database_*`` par les lignes commentées (celles avec des valeurs préfixées par ``env.``) #. ``composer install`` pour installer les dépendances -#. ``php app/console wallabag:install`` pour créer le schéma de la BDD +#. ``php bin/console wallabag:install`` pour créer le schéma de la BDD #. ``docker-compose up`` pour démarrer les conteneurs #. Enfin, se rendre sur http://localhost:8080/ pour accéder à une installation tout propre de wallabag. diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 3873d2d3..cc7c2c94 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -2,6 +2,8 @@ namespace Wallabag\CoreBundle\Command; +use FOS\UserBundle\Event\UserEvent; +use FOS\UserBundle\FOSUserEvents; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\ArrayInput; @@ -236,14 +238,9 @@ class InstallCommand extends ContainerAwareCommand $em->persist($user); - $config = new Config($user); - $config->setTheme($this->getContainer()->getParameter('wallabag_core.theme')); - $config->setItemsPerPage($this->getContainer()->getParameter('wallabag_core.items_on_page')); - $config->setRssLimit($this->getContainer()->getParameter('wallabag_core.rss_limit')); - $config->setReadingSpeed($this->getContainer()->getParameter('wallabag_core.reading_speed')); - $config->setLanguage($this->getContainer()->getParameter('wallabag_core.language')); - - $em->persist($config); + // dispatch a created event so the associated config will be created + $event = new UserEvent($user); + $this->getContainer()->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event); $this->defaultOutput->writeln(''); diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 4f75511b..f1e212d9 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -2,6 +2,8 @@ namespace Wallabag\CoreBundle\Controller; +use FOS\UserBundle\Event\UserEvent; +use FOS\UserBundle\FOSUserEvents; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\JsonResponse; @@ -106,7 +108,21 @@ class ConfigController extends Controller // handle tagging rule $taggingRule = new TaggingRule(); - $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $this->generateUrl('config').'#set5']); + $action = $this->generateUrl('config').'#set5'; + + if ($request->query->has('tagging-rule')) { + $taggingRule = $this->getDoctrine() + ->getRepository('WallabagCoreBundle:TaggingRule') + ->find($request->query->get('tagging-rule')); + + if ($this->getUser()->getId() !== $taggingRule->getConfig()->getUser()->getId()) { + return $this->redirect($action); + } + + $action = $this->generateUrl('config').'?tagging-rule='.$taggingRule->getId().'#set5'; + } + + $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $action]); $newTaggingRule->handleRequest($request); if ($newTaggingRule->isValid()) { @@ -133,18 +149,11 @@ class ConfigController extends Controller $newUserForm->handleRequest($request); if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) { - $userManager->updateUser($newUser, true); - - $config = new Config($newUser); - $config->setTheme($this->getParameter('wallabag_core.theme')); - $config->setItemsPerPage($this->getParameter('wallabag_core.items_on_page')); - $config->setRssLimit($this->getParameter('wallabag_core.rss_limit')); - $config->setLanguage($this->getParameter('wallabag_core.language')); - $config->setReadingSpeed($this->getParameter('wallabag_core.reading_speed')); + $userManager->updateUser($newUser); - $em->persist($config); - - $em->flush(); + // dispatch a created event so the associated config will be created + $event = new UserEvent($newUser, $request); + $this->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event); $this->get('session')->getFlashBag()->add( 'notice', @@ -210,9 +219,7 @@ class ConfigController extends Controller */ public function deleteTaggingRuleAction(TaggingRule $rule) { - if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) { - throw $this->createAccessDeniedException('You can not access this tagging rule.'); - } + $this->validateRuleAction($rule); $em = $this->getDoctrine()->getManager(); $em->remove($rule); @@ -226,6 +233,34 @@ class ConfigController extends Controller return $this->redirect($this->generateUrl('config').'#set5'); } + /** + * Edit a tagging rule. + * + * @param TaggingRule $rule + * + * @Route("/tagging-rule/edit/{id}", requirements={"id" = "\d+"}, name="edit_tagging_rule") + * + * @return RedirectResponse + */ + public function editTaggingRuleAction(TaggingRule $rule) + { + $this->validateRuleAction($rule); + + return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5'); + } + + /** + * Validate that a rule can be edited/deleted by the current user. + * + * @param TaggingRule $rule + */ + private function validateRuleAction(TaggingRule $rule) + { + if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) { + throw $this->createAccessDeniedException('You can not access this tagging rule.'); + } + } + /** * Retrieve config for the current user. * If no config were found, create a new one. @@ -238,6 +273,7 @@ class ConfigController extends Controller ->getRepository('WallabagCoreBundle:Config') ->findOneByUser($this->getUser()); + // should NEVER HAPPEN ... if (!$config) { $config = new Config($this->getUser()); } diff --git a/src/Wallabag/CoreBundle/Controller/ExceptionController.php b/src/Wallabag/CoreBundle/Controller/ExceptionController.php new file mode 100644 index 00000000..abfa9c2f --- /dev/null +++ b/src/Wallabag/CoreBundle/Controller/ExceptionController.php @@ -0,0 +1,40 @@ +templateExists($template)) { + return $template; + } + } + + // try to find a template for the given format + $template = sprintf('@Twig/Exception/%s.%s.twig', $name, $format); + if ($this->templateExists($template)) { + return $template; + } + + // default to a generic HTML exception + $request->setRequestFormat('html'); + + return sprintf('@Twig/Exception/%s.html.twig', $showException ? 'exception_full' : $name); + } +} diff --git a/src/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverter.php b/src/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverter.php index 6ea2a4f3..40b5673d 100644 --- a/src/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverter.php +++ b/src/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverter.php @@ -49,7 +49,7 @@ class UsernameRssTokenConverter implements ParamConverterInterface $em = $this->registry->getManagerForClass($configuration->getClass()); // Check, if class name is what we need - if ('Wallabag\UserBundle\Entity\User' !== $em->getClassMetadata($configuration->getClass())->getName()) { + if (null !== $em && 'Wallabag\UserBundle\Entity\User' !== $em->getClassMetadata($configuration->getClass())->getName()) { return false; } @@ -69,9 +69,8 @@ class UsernameRssTokenConverter implements ParamConverterInterface $username = $request->attributes->get('username'); $rssToken = $request->attributes->get('token'); - // Check, if route attributes exists - if (null === $username || null === $rssToken) { - throw new \InvalidArgumentException('Route attribute is missing'); + if (!$request->attributes->has('username') || !$request->attributes->has('token')) { + return false; } // Get actual entity manager for class diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index 23e6d3ca..d1139846 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml @@ -88,17 +88,6 @@ services: arguments: - WallabagCoreBundle:Tag - wallabag_core.registration_confirmed: - class: Wallabag\CoreBundle\EventListener\RegistrationConfirmedListener - arguments: - - "@doctrine.orm.entity_manager" - - "%wallabag_core.theme%" - - "%wallabag_core.items_on_page%" - - "%wallabag_core.rss_limit%" - - "%wallabag_core.language%" - tags: - - { name: kernel.event_subscriber } - wallabag_core.helper.entries_export: class: Wallabag\CoreBundle\Helper\EntriesExport arguments: @@ -133,3 +122,9 @@ services: host: '%redis_host%' port: '%redis_port%' schema: tcp + + wallabag_core.exception_controller: + class: Wallabag\CoreBundle\Controller\ExceptionController + arguments: + - '@twig' + - '%kernel.debug%' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 16e4f063..da7e2652 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -45,6 +45,7 @@ footer: # social: 'Social' # powered_by: 'powered by' about: 'Om' + # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day! config: page_title: 'Opsætning' @@ -94,6 +95,7 @@ config: # if_label: 'if' # then_tag_as_label: 'then tag as' # delete_rule_label: 'delete' + # edit_rule_label: 'edit' # rule_label: 'Rule' # tags_label: 'Tags' # faq: @@ -358,7 +360,7 @@ import: # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" # firefox: # page_title: 'Import > Firefox' - # description: "This importer will import all your Firefox bookmarks.

For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." + # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." #chrome: # page_title: 'Import > Chrome' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index 5db4b28e..eb82f13f 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -45,6 +45,7 @@ footer: social: 'Soziales' powered_by: 'angetrieben von' about: 'Über' + # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day! config: page_title: 'Einstellungen' @@ -94,6 +95,7 @@ config: if_label: 'Wenn' then_tag_as_label: 'dann tagge als' delete_rule_label: 'löschen' + # edit_rule_label: 'edit' rule_label: 'Regel' tags_label: 'Tags' faq: @@ -358,7 +360,7 @@ import: # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" firefox: page_title: 'Aus Firefox importieren' - # description: "This importer will import all your Firefox bookmarks.

For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." + # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." chrome: page_title: 'Aus Chrome importieren' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index f9f8e217..01d8053b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -45,6 +45,7 @@ footer: social: 'Social' powered_by: 'powered by' about: 'About' + stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day! config: page_title: 'Config' @@ -94,6 +95,7 @@ config: if_label: 'if' then_tag_as_label: 'then tag as' delete_rule_label: 'delete' + edit_rule_label: 'edit' rule_label: 'Rule' tags_label: 'Tags' faq: @@ -358,7 +360,7 @@ import: enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" firefox: page_title: 'Import > Firefox' - description: "This importer will import all your Firefox bookmarks.

For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." + description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." chrome: page_title: 'Import > Chrome' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index db87cd96..5364e99a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -45,6 +45,7 @@ footer: social: 'Social' powered_by: 'funciona por' about: 'Acerca de' + # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day! config: page_title: 'Configuración' @@ -94,6 +95,7 @@ config: if_label: 'si' then_tag_as_label: 'Etiquete como' delete_rule_label: 'Borre' + # edit_rule_label: 'edit' rule_label: 'Regla' tags_label: 'Etiquetas' faq: @@ -358,7 +360,7 @@ import: # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" firefox: page_title: 'Importar > Firefox' - # description: "This importer will import all your Firefox bookmarks.

For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." + # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." chrome: page_title: 'Importar > Chrome' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index f6943ae5..6f42b173 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -45,6 +45,7 @@ footer: social: 'شبکه‌های اجتماعی' powered_by: 'توانمند با' about: 'درباره' + # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day! config: page_title: 'پیکربندی' @@ -94,6 +95,7 @@ config: if_label: 'اگر' then_tag_as_label: 'این برچسب را بزن' delete_rule_label: 'پاک کن' + # edit_rule_label: 'edit' rule_label: 'قانون' tags_label: 'برچسب‌ها' faq: @@ -357,7 +359,7 @@ import: # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" firefox: page_title: 'درون‌ریزی > Firefox' - # description: "This importer will import all your Firefox bookmarks.

For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." + # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." chrome: page_title: 'درون‌ریزی > Chrome' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index f2c92070..6984be83 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -45,6 +45,7 @@ footer: social: 'Social' powered_by: 'propulsé par' about: 'À propos' + stats: Depuis le %user_creation% vous avez lu %nb_archives% articles. Ce qui fait %per_day% par jour ! config: page_title: 'Configuration' @@ -94,6 +95,7 @@ config: if_label: 'si' then_tag_as_label: 'alors attribuer les tags' delete_rule_label: 'supprimer' + edit_rule_label: 'éditer' rule_label: 'Règle' tags_label: 'Tags' faq: @@ -358,7 +360,7 @@ import: enabled: "Les imports sont asynchrones. Une fois l'import commencé un worker externe traitera les messages un par un. Le service activé est :" firefox: page_title: 'Import > Firefox' - description: "Cet outil va vous permettre d'importer tous vos marques-pages de Firefox.

Pour Firefox, ouvrez le panneau des marques-pages (Ctrl+Maj+O), puis dans « Importation et sauvegarde », choisissez « Sauvegarde... ». Vous allez récupérer un fichier .json.

" + description: "Cet outil va vous permettre d'importer tous vos marques-pages de Firefox. Ouvrez le panneau des marques-pages (Ctrl+Maj+O), puis dans « Importation et sauvegarde », choisissez « Sauvegarde... ». Vous allez récupérer un fichier .json.

" how_to: "Choisissez le fichier de sauvegarde de vos marques-page et cliquez sur le bouton pour l'importer. Soyez avertis que le processus peut prendre un temps assez long car tous les articles doivent être récupérés en ligne." chrome: page_title: 'Import > Chrome' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 32897b32..30b3287e 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -45,6 +45,7 @@ footer: social: 'Social' powered_by: 'powered by' about: 'About' + # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day! config: page_title: 'Configurazione' @@ -94,6 +95,7 @@ config: if_label: 'se' then_tag_as_label: 'allora tagga come' delete_rule_label: 'elimina' + # edit_rule_label: 'edit' rule_label: 'Regola' tags_label: 'Tag' faq: @@ -357,7 +359,7 @@ import: # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" firefox: page_title: 'Importa da > Firefox' - # description: "This importer will import all your Firefox bookmarks.

For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." + # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." chrome: page_title: 'Importa da > Chrome' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 8caf3c0c..a077f1bf 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -19,14 +19,14 @@ menu: unread: 'Pas legits' starred: 'Favorits' archive: 'Legits' - all_articles: 'Tots los articles' + all_articles: 'Totes los articles' config: 'Configuracion' tags: 'Etiquetas' internal_settings: 'Configuracion interna' import: 'Importar' howto: 'Ajuda' developer: 'Desvolopador' - logout: 'Déconnexion' + logout: 'Desconnexion' about: 'A prepaus' search: 'Cercar' save_link: 'Enregistrar un novèl article' @@ -45,9 +45,10 @@ footer: social: 'Social' powered_by: 'propulsat per' about: 'A prepaus' - page_title: 'Configuracion' + # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day! config: + page_title: 'Configuracion' tab_menu: settings: 'Paramètres' rss: 'RSS' @@ -72,8 +73,8 @@ config: form_rss: description: "Los fluxes RSS fornits per wallabag vos permeton de legir vòstres articles salvagardats dins vòstre lector de fluxes preferit. Per los poder emplegar, vos cal, d'en primièr crear un geton." token_label: 'Geton RSS' - no_token: 'Aucun jeton généré' - token_create: 'Pas cap de geton generat' + no_token: 'Pas cap de geton generat' + token_create: 'Creatz vòstre geton' token_reset: 'Reïnicializatz vòstre geton' rss_links: 'URL de vòstres fluxes RSS' rss_link: @@ -94,6 +95,7 @@ config: if_label: 'se' then_tag_as_label: 'alara atribuir las etiquetas' delete_rule_label: 'suprimir' + # edit_rule_label: 'edit' rule_label: 'Règla' tags_label: 'Etiquetas' faq: @@ -187,7 +189,7 @@ entry: re_fetch_content: 'Tornar cargar lo contengut' delete: 'Suprimir' add_a_tag: 'Ajustar una etiqueta' - share_content: 'Partatjar' + share_content: 'Partejar' share_email_label: 'Corrièl' public_link: 'ligam public' delete_public_link: 'suprimir lo ligam public' @@ -224,7 +226,7 @@ about: developped_by: 'Desvolopat per' website: 'Site web' many_contributors: 'E un fum de contributors ♥ sur Github' - project_website: 'Site web del projète' + project_website: 'Site web del projècte' license: 'Licéncia' version: 'Version' getting_help: @@ -245,7 +247,7 @@ about: howto: page_title: 'Ajuda' - page_description: "I a mai d'un biai d'enregistrar un article :" + page_description: "I a mai d'un biais d'enregistrar un article :" top_menu: browser_addons: 'Extensions de navigator' mobile_apps: 'Aplicacions mobil' @@ -351,26 +353,26 @@ import: page_title: 'Importar > Wallabag v2' description: "Aquesta aisina importarà totas vòstras donadas d'una instància mai de wallabag v2. Anatz dins totes vòstres articles, puèi, sus la barra laterala, clicatz sus \"JSON\". Traparatz un fichièr \"All articles.json\"" readability: - page_title: 'Importer > Readability' + page_title: 'Importar > Readability' description: "Aquesta aisina importarà totas vòstres articles de Readability. Sus la pagina de l'aisina (https://www.readability.com/tools/), clicatz sus \"Export your data\" dins la seccion \"Data Export\". Recebretz un corrièl per telecargar un json (qu'acaba pas amb un .json de fach)." how_to: "Mercés de seleccionar vòstre Readability fichièr e de clicar sul boton dejós per lo telecargar e l'importar." worker: - # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" + enabled: "L'importacion se fa de manièra asincròna. Un còp l'importacion lançada, una aisina externa s'ocuparà dels messatges un per un. Lo servici actual es : " firefox: - page_title: 'Importer > Firefox' - # description: "This importer will import all your Firefox bookmarks.

For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." - # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." + page_title: 'Importar > Firefox' + description: "Aquesta aisina importarà totas vòstres favorits de Firefox. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." + how_to: "Mercés de causir lo fichièr de salvagarda e de clicar sul boton dejós per l'importar. Notatz que lo tractament pòt durar un moment ja que totes los articles an d'èsser recuperats." chrome: - page_title: 'Importer > Chrome' - # description: "This importer will import all your Chrome bookmarks. The location of the file depends on your operating system :

Once you got there, copy the Bookmarks file someplace you'll find.
Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.

" - # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." + page_title: 'Importar > Chrome' + description: "Aquesta aisina importarà totas vòstres favorits de Chrome. L'emplaçament del fichièr depend de vòstre sistèma operatiu : Un còp enlà, copiatz lo fichièr de favorits dins un endrech que volètz.
Notatz que s'avètz Chromium al lòc de Chrome, vos cal cambiar lo camin segon aquesta situacion.

" + how_to: "Mercés de causir lo fichièr de salvagarda e de clicar sul boton dejós per l'importar. Notatz que lo tractament pòt durar un moment ja que totes los articles an d'èsser recuperats." instapaper: - page_title: 'Importer > Instapaper' - # description: 'This importer will import all your Instapaper articles. On the settings (https://www.instapaper.com/user) page, click on "Download .CSV file" in the "Export" section. A CSV file will be downloaded (like "instapaper-export.csv").' - # how_to: 'Please select your Instapaper export and click on the below button to upload and import it.' + page_title: 'Importar > Instapaper' + description: "Aquesta aisina importarà totas vòstres articles d'Instapaper. Sus la pagina de paramètres (https://www.instapaper.com/user), clicatz sus \"Download .CSV file\" dins la seccion \"Export\". Un fichièr CSV serà telecargat (aital \"instapaper-export.csv\")." + how_to: "Mercés de causir vòstre fichièr Instapaper e de clicar sul boton dejós per lo telecargar e l'importar" developer: - page_title: 'Desvolopador' + page_title: 'Desvolopaire' welcome_message: "Benvenguda sus l'API de wallabag" documentation: 'Documentacion' how_to_first_app: 'Cossí crear vòstra primièra aplicacion' @@ -394,16 +396,18 @@ developer: page_title: 'Desvlopador > Novèl client' page_description: "Anatz crear un novèl client. Mercés de cumplir l'url de redireccion cap a vòstra aplicacion." form: + name_label: "Nom del client" redirect_uris_label: 'URLs de redireccion' save_label: 'Crear un novèl client' action_back: 'Retorn' client_parameter: page_title: 'Desvolopador > Los paramètres de vòstre client' page_description: 'Vaquí los paramètres de vòstre client' + field_name: 'Nom del client' field_id: 'ID Client' field_secret: 'Clau secreta' back: 'Retour' - read_howto: 'Legir \"cossí crear ma primièra aplicacion\"' + read_howto: 'Legir "cossí crear ma primièra aplicacion"' howto: page_title: 'Desvolopador > Cossí crear ma primièra aplicacion' description: @@ -433,10 +437,10 @@ flashes: notice: entry_already_saved: 'Article ja salvargardat lo %date%' entry_saved: 'Article enregistrat' - # entry_saved_failed: 'Entry saved but fetching content failed' + entry_saved_failed: 'Article salvat mai fracàs de la recuperacion del contengut' entry_updated: 'Article mes a jorn' entry_reloaded: 'Article recargat' - # entry_reload_failed: 'Entry reloaded but fetching content failed' + entry_reload_failed: "L'article es estat cargat de nòu mai la recuperacion del contengut a fracassat" entry_archived: 'Article marcat coma legit' entry_unarchived: 'Article marcat coma pas legit' entry_starred: 'Article apondut dins los favorits' @@ -450,10 +454,10 @@ flashes: failed: "L'importacion a fracassat, mercés de tornar ensajar" failed_on_file: "Errorr pendent du tractament de l'import. Mercés de verificar vòstre fichièr." summary: "Rapòrt d'import: %imported% importats, %skipped% ja presents." - # summary_with_queue: 'Import summary: %queued% queued.' + summary_with_queue: "Rapòrt d'import : %queued% en espèra de tractament." error: - # redis_enabled_not_installed: Redis is enabled for handle asynchronous import but it looks like we can't connect to it. Please check Redis configuration. - # rabbit_enabled_not_installed: RabbitMQ is enabled for handle asynchronous import but it looks like we can't connect to it. Please check RabbitMQ configuration. + redis_enabled_not_installed: "Redis es capable d'importar de manièra asincròna mai sembla que podèm pas nos conectar amb el. Mercés de verificar la configuracion de Redis." + rabbit_enabled_not_installed: "RabbitMQ es capable d'importar de manièra asincròna mai sembla que podèm pas nos conectar amb el. Mercés de verificar la configuracion de RabbitMQ." developer: notice: client_created: 'Novèl client creat' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 8f0555b1..cad94dd5 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -45,6 +45,7 @@ footer: social: 'Społeczność' powered_by: 'Kontrolowany przez' about: 'O nas' + # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day! config: page_title: 'Konfiguracja' @@ -94,6 +95,7 @@ config: if_label: 'jeżeli' then_tag_as_label: 'wtedy otaguj jako' delete_rule_label: 'usuń' + # edit_rule_label: 'edit' rule_label: 'Reguła' tags_label: 'Tagi' faq: @@ -358,7 +360,7 @@ import: enabled: "Import jest wykonywany asynchronicznie. Od momentu rozpoczęcia importu, zewnętrzna usługa może zajmować się na raz tylko jednym zadaniem. Bieżącą usługą jest:" firefox: page_title: 'Import > Firefox' - description: "Ten importer zaimportuje wszystkie twoje zakładki z Firefoksa.

Dla Firefoksa, idź do twoich zakładek (Ctrl+Shift+O), następnie w \"Import i kopie zapasowe\", wybierz \"Utwórz kopię zapasową...\". Uzyskasz plik .json." + description: "Ten importer zaimportuje wszystkie twoje zakładki z Firefoksa. Idź do twoich zakładek (Ctrl+Shift+O), następnie w \"Import i kopie zapasowe\", wybierz \"Utwórz kopię zapasową...\". Uzyskasz plik .json." how_to: "Wybierz swój plik z zakładkami i naciśnij poniższy przycisk, aby je zaimportować. Może to zająć dłuższą chwilę, zanim wszystkie artykuły zostaną przeniesione." chrome: page_title: 'Import > Chrome' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index ee56dd15..a271d6f3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -45,6 +45,7 @@ footer: # social: 'Social' # powered_by: 'powered by' about: 'Despre' + # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day! config: page_title: 'Configurație' @@ -94,6 +95,7 @@ config: # if_label: 'if' # then_tag_as_label: 'then tag as' # delete_rule_label: 'delete' + # edit_rule_label: 'edit' # rule_label: 'Rule' # tags_label: 'Tags' # faq: @@ -358,7 +360,7 @@ import: # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" # firefox: # page_title: 'Import > Firefox' - # description: "This importer will import all your Firefox bookmarks.

For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." + # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." # chrome: # page_title: 'Import > Chrome' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index befd39ed..f2307e65 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -45,6 +45,7 @@ footer: social: 'Sosyal' powered_by: 'powered by' about: 'Hakkımızda' + # stats: Since %user_creation% you read %nb_archives% articles. That is about %per_day% a day! config: page_title: 'Yapılandırma' @@ -358,7 +359,7 @@ import: # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" firefox: page_title: 'İçe Aktar > Firefox' - # description: "This importer will import all your Firefox bookmarks.

For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." + # description: "This importer will import all your Firefox bookmarks. Just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file." # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." chrome: page_title: 'İçe Aktar > Chrome' diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig index 6446cf2c..dd4f7b00 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig @@ -191,6 +191,7 @@ « {{ tagging_rule.rule }} » {{ 'config.form_rules.then_tag_as_label'|trans }} « {{ tagging_rule.tags|join(', ') }} » + ✎ {% endfor %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Exception/error.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Exception/error.html.twig new file mode 100644 index 00000000..b52634fd --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Exception/error.html.twig @@ -0,0 +1,24 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{{ 'error.page_title'|trans }}{% endblock %} + +{% block body_class %}login{% endblock %} + +{% block menu %}{% endblock %} +{% block messages %}{% endblock %} +{% block header %}{% endblock %} + +{% block content %} +

+
+
+
wallabag logo
+

{{ status_code }}: {{ status_text }}

+

{{ exception.message }}

+
+
+
+{% endblock %} + +{% block footer %} +{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig index 5330c353..650a3ae2 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig @@ -218,6 +218,9 @@ « {{ tagging_rule.rule }} » {{ 'config.form_rules.then_tag_as_label'|trans }} « {{ tagging_rule.tags|join(', ') }} » + + mode_edit + delete diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Exception/error.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Exception/error.html.twig new file mode 100644 index 00000000..6be78edb --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Exception/error.html.twig @@ -0,0 +1,30 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{{ 'error.page_title'|trans }}{% endblock %} + +{% block body_class %}login{% endblock %} + +{% block menu %}{% endblock %} +{% block messages %}{% endblock %} + +{% block content %} +
+
+
+
wallabag logo
+
+
+
{{ status_code }}: {{ status_text }}
+

{{ exception.message }}

+ {# {% for trace in exception.trace %} +

{{ trace.class }} - {{ trace.type }} - {{ trace.file }} - {{ trace.line }}

+ {% endfor %} #} +
+
+
+
+
+{% endblock %} + +{% block footer %} +{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig index df05e2a4..b2d77c2e 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig @@ -122,8 +122,19 @@ diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php index fb4c7412..783cde3e 100644 --- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php +++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php @@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Twig; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Wallabag\CoreBundle\Repository\EntryRepository; use Wallabag\CoreBundle\Repository\TagRepository; +use Symfony\Component\Translation\TranslatorInterface; class WallabagExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface { @@ -12,13 +13,15 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa private $entryRepository; private $tagRepository; private $lifeTime; + private $translator; - public function __construct(EntryRepository $entryRepository = null, TagRepository $tagRepository = null, TokenStorageInterface $tokenStorage = null, $lifeTime = 0) + public function __construct(EntryRepository $entryRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator) { $this->entryRepository = $entryRepository; $this->tagRepository = $tagRepository; $this->tokenStorage = $tokenStorage; $this->lifeTime = $lifeTime; + $this->translator = $translator; } public function getFilters() @@ -33,6 +36,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa return array( new \Twig_SimpleFunction('count_entries', [$this, 'countEntries']), new \Twig_SimpleFunction('count_tags', [$this, 'countTags']), + new \Twig_SimpleFunction('display_stats', [$this, 'displayStats']), ); } @@ -107,6 +111,40 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa return $this->tagRepository->countAllTags($user->getId()); } + /** + * Display a single line about reading stats. + * + * @return string + */ + public function displayStats() + { + $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; + + if (null === $user || !is_object($user)) { + return 0; + } + + $query = $this->entryRepository->getBuilderForArchiveByUser($user->getId()) + ->select('e.id') + ->groupBy('e.id') + ->getQuery(); + + $query->useQueryCache(true); + $query->useResultCache(true); + $query->setResultCacheLifetime($this->lifeTime); + + $nbArchives = count($query->getArrayResult()); + + $interval = $user->getCreatedAt()->diff(new \DateTime('now')); + $nbDays = (int) $interval->format('%a') ?: 1; + + return $this->translator->trans('footer.stats', [ + '%user_creation%' => $user->getCreatedAt()->format('F jS, Y'), + '%nb_archives%' => $nbArchives, + '%per_day%' => round($nbArchives / $nbDays, 2), + ]); + } + public function getName() { return 'wallabag_extension'; diff --git a/src/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListener.php b/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php similarity index 53% rename from src/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListener.php rename to src/Wallabag/UserBundle/EventListener/CreateConfigListener.php index 10586126..15f4ac3d 100644 --- a/src/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListener.php +++ b/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php @@ -1,39 +1,49 @@ em = $em; $this->theme = $theme; $this->itemsOnPage = $itemsOnPage; $this->rssLimit = $rssLimit; $this->language = $language; + $this->readingSpeed = $readingSpeed; } public static function getSubscribedEvents() { return [ - FOSUserEvents::REGISTRATION_CONFIRMED => 'authenticate', + // when a user register using the normal form + FOSUserEvents::REGISTRATION_COMPLETED => 'createConfig', + // when we manually create a user using the command line + // OR when we create it from the config UI + FOSUserEvents::USER_CREATED => 'createConfig', ]; } - public function authenticate(FilterUserResponseEvent $event, $eventName = null, EventDispatcherInterface $eventDispatcher = null) + public function createConfig(UserEvent $event, $eventName = null, EventDispatcherInterface $eventDispatcher = null) { if (!$event->getUser()->isEnabled()) { return; @@ -44,6 +54,8 @@ class RegistrationConfirmedListener implements EventSubscriberInterface $config->setItemsPerPage($this->itemsOnPage); $config->setRssLimit($this->rssLimit); $config->setLanguage($this->language); + $config->setReadingSpeed($this->readingSpeed); + $this->em->persist($config); $this->em->flush(); } diff --git a/src/Wallabag/UserBundle/Resources/config/services.yml b/src/Wallabag/UserBundle/Resources/config/services.yml index 05830555..eb9c8e67 100644 --- a/src/Wallabag/UserBundle/Resources/config/services.yml +++ b/src/Wallabag/UserBundle/Resources/config/services.yml @@ -20,3 +20,15 @@ services: factory: [ "@doctrine.orm.default_entity_manager", getRepository ] arguments: - WallabagUserBundle:User + + wallabag_user.create_config: + class: Wallabag\UserBundle\EventListener\CreateConfigListener + arguments: + - "@doctrine.orm.entity_manager" + - "%wallabag_core.theme%" + - "%wallabag_core.items_on_page%" + - "%wallabag_core.rss_limit%" + - "%wallabag_core.language%" + - "%wallabag_core.reading_speed%" + tags: + - { name: kernel.event_subscriber } diff --git a/src/Wallabag/UserBundle/Resources/views/Registration/checkEmail.html.twig b/src/Wallabag/UserBundle/Resources/views/Registration/check_email.html.twig similarity index 100% rename from src/Wallabag/UserBundle/Resources/views/Registration/checkEmail.html.twig rename to src/Wallabag/UserBundle/Resources/views/Registration/check_email.html.twig diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index 7193f9b0..bb3ea9e2 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php @@ -56,8 +56,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $crawler = $client->followRedirect(); - $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text'])); - $this->assertContains('flashes.config.notice.config_saved', $alert[0]); + $this->assertContains('flashes.config.notice.config_saved', $crawler->filter('body')->extract(['_text'])[0]); } public function testChangeReadingSpeed() @@ -213,8 +212,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $crawler = $client->followRedirect(); - $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text'])); - $this->assertContains('flashes.config.notice.password_updated', $alert[0]); + $this->assertContains('flashes.config.notice.password_updated', $crawler->filter('body')->extract(['_text'])[0]); } public function dataForUserFailed() @@ -382,8 +380,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $crawler = $client->followRedirect(); - $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text'])); - $this->assertContains('flashes.config.notice.user_added', $alert[0]); + $this->assertContains('flashes.config.notice.user_added', $crawler->filter('body')->extract(['_text'])[0]); $em = $client->getContainer()->get('doctrine.orm.entity_manager'); $user = $em @@ -474,8 +471,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $crawler = $client->followRedirect(); - $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text'])); - $this->assertContains('flashes.config.notice.rss_updated', $alert[0]); + $this->assertContains('flashes.config.notice.rss_updated', $crawler->filter('body')->extract(['_text'])[0]); } public function dataForRssFailed() @@ -540,8 +536,32 @@ class ConfigControllerTest extends WallabagCoreTestCase $crawler = $client->followRedirect(); - $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text'])); - $this->assertContains('flashes.config.notice.tagging_rules_updated', $alert[0]); + $this->assertContains('flashes.config.notice.tagging_rules_updated', $crawler->filter('body')->extract(['_text'])[0]); + + $editLink = $crawler->filter('.mode_edit')->last()->link(); + + $crawler = $client->click($editLink); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $this->assertContains('?tagging-rule=', $client->getResponse()->headers->get('location')); + + $crawler = $client->followRedirect(); + + $form = $crawler->filter('button[id=tagging_rule_save]')->form(); + + $data = [ + 'tagging_rule[rule]' => 'readingTime <= 30', + 'tagging_rule[tags]' => 'short reading', + ]; + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertContains('flashes.config.notice.tagging_rules_updated', $crawler->filter('body')->extract(['_text'])[0]); + + $this->assertContains('readingTime <= 30', $crawler->filter('body')->extract(['_text'])[0]); $deleteLink = $crawler->filter('.delete')->last()->link(); @@ -549,8 +569,7 @@ class ConfigControllerTest extends WallabagCoreTestCase $this->assertEquals(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); - $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text'])); - $this->assertContains('flashes.config.notice.tagging_rules_deleted', $alert[0]); + $this->assertContains('flashes.config.notice.tagging_rules_deleted', $crawler->filter('body')->extract(['_text'])[0]); } public function dataForTaggingRuleFailed() @@ -613,7 +632,23 @@ class ConfigControllerTest extends WallabagCoreTestCase ->getRepository('WallabagCoreBundle:TaggingRule') ->findAll()[0]; - $crawler = $client->request('GET', '/tagging-rule/delete/'.$rule->getId()); + $crawler = $client->request('GET', '/tagging-rule/edit/'.$rule->getId()); + + $this->assertEquals(403, $client->getResponse()->getStatusCode()); + $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); + $this->assertContains('You can not access this tagging rule', $body[0]); + } + + public function testEditingTaggingRuleFromAnOtherUser() + { + $this->logInAs('bob'); + $client = $this->getClient(); + + $rule = $client->getContainer()->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:TaggingRule') + ->findAll()[0]; + + $crawler = $client->request('GET', '/tagging-rule/edit/'.$rule->getId()); $this->assertEquals(403, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); diff --git a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php b/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php index e29b58b5..2e6fccfb 100644 --- a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php +++ b/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php @@ -125,16 +125,14 @@ class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase $this->assertTrue($converter->supports($params)); } - /** - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Route attribute is missing - */ public function testApplyEmptyRequest() { $params = new ParamConverter([]); $converter = new UsernameRssTokenConverter(); - $converter->apply(new Request(), $params); + $res = $converter->apply(new Request(), $params); + + $this->assertFalse($res); } /** diff --git a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php index 8ec2a75a..b1c8c946 100644 --- a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php +++ b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php @@ -8,7 +8,23 @@ class WallabagExtensionTest extends \PHPUnit_Framework_TestCase { public function testRemoveWww() { - $extension = new WallabagExtension(); + $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') + ->disableOriginalConstructor() + ->getMock(); + + $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository') + ->disableOriginalConstructor() + ->getMock(); + + $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface') + ->disableOriginalConstructor() + ->getMock(); + + $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface') + ->disableOriginalConstructor() + ->getMock(); + + $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator); $this->assertEquals('lemonde.fr', $extension->removeWww('www.lemonde.fr')); $this->assertEquals('lemonde.fr', $extension->removeWww('lemonde.fr')); diff --git a/tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php similarity index 83% rename from tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php rename to tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php index e45722fa..0cebd3e4 100644 --- a/tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php +++ b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php @@ -1,6 +1,6 @@ disableOriginalConstructor() ->getMock(); - $this->listener = new RegistrationConfirmedListener( + $this->listener = new CreateConfigListener( $this->em, 'baggy', 20, 50, - 'fr' + 'fr', + 1 ); $this->dispatcher = new EventDispatcher(); @@ -55,7 +56,7 @@ class RegistrationConfirmedListenerTest extends \PHPUnit_Framework_TestCase $this->em->expects($this->never())->method('flush'); $this->dispatcher->dispatch( - FOSUserEvents::REGISTRATION_CONFIRMED, + FOSUserEvents::REGISTRATION_COMPLETED, $event ); } @@ -76,6 +77,7 @@ class RegistrationConfirmedListenerTest extends \PHPUnit_Framework_TestCase $config->setItemsPerPage(20); $config->setRssLimit(50); $config->setLanguage('fr'); + $config->setReadingSpeed(1); $this->em->expects($this->once()) ->method('persist') @@ -84,7 +86,7 @@ class RegistrationConfirmedListenerTest extends \PHPUnit_Framework_TestCase ->method('flush'); $this->dispatcher->dispatch( - FOSUserEvents::REGISTRATION_CONFIRMED, + FOSUserEvents::REGISTRATION_COMPLETED, $event ); }