]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Add controller, views and translations for ignore origin instance rules
authorKevin Decherf <kevin@kdecherf.com>
Mon, 26 Aug 2019 22:03:30 +0000 (00:03 +0200)
committerKevin Decherf <kevin@kdecherf.com>
Sat, 25 Apr 2020 13:59:23 +0000 (15:59 +0200)
Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
26 files changed:
app/config/security.yml
src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php [new file with mode: 0644]
src/Wallabag/CoreBundle/Form/Type/IgnoreOriginInstanceRuleType.php [new file with mode: 0644]
src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/edit.html.twig [new file with mode: 0644]
src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/index.html.twig [new file with mode: 0644]
src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/new.html.twig [new file with mode: 0644]
src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/edit.html.twig [new file with mode: 0644]
src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/index.html.twig [new file with mode: 0644]
src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/new.html.twig [new file with mode: 0644]
src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
tests/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleControllerTest.php [new file with mode: 0644]

index 760b2550320868d185be60972455147cf6257bd4..5a73440b241eebde5dbbe5a4d6d5b391d76bb5fb 100644 (file)
@@ -79,4 +79,5 @@ security:
         - { path: ^/annotations, roles: ROLE_USER }
         - { path: ^/2fa, role: IS_AUTHENTICATED_2FA_IN_PROGRESS }
         - { path: ^/users, roles: ROLE_SUPER_ADMIN }
+        - { path: ^/ignore-origin-instance-rules, roles: ROLE_SUPER_ADMIN }
         - { path: ^/, roles: ROLE_USER }
diff --git a/src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php b/src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php
new file mode 100644 (file)
index 0000000..ef1f0ed
--- /dev/null
@@ -0,0 +1,138 @@
+<?php
+
+namespace Wallabag\CoreBundle\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Annotation\Route;
+use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
+
+/**
+ * IgnoreOriginInstanceRuleController controller.
+ *
+ * @Route("/ignore-origin-instance-rules")
+ */
+class IgnoreOriginInstanceRuleController extends Controller
+{
+    /**
+     * Lists all IgnoreOriginInstanceRule entities.
+     *
+     * @Route("/", name="ignore_origin_instance_rules_index", methods={"GET"})
+     */
+    public function indexAction()
+    {
+        $rules = $this->get('wallabag_core.ignore_origin_instance_rule_repository')->findAll();
+
+        return $this->render('WallabagCoreBundle:IgnoreOriginInstanceRule:index.html.twig', [
+            'rules' => $rules,
+        ]);
+    }
+
+    /**
+     * Creates a new ignore origin instance rule entity.
+     *
+     * @Route("/new", name="ignore_origin_instance_rules_new", methods={"GET", "POST"})
+     *
+     * @return \Symfony\Component\HttpFoundation\Response
+     */
+    public function newAction(Request $request)
+    {
+        $ignoreOriginInstanceRule = new IgnoreOriginInstanceRule();
+
+        $form = $this->createForm('Wallabag\CoreBundle\Form\Type\IgnoreOriginInstanceRuleType', $ignoreOriginInstanceRule);
+        $form->handleRequest($request);
+
+        if ($form->isSubmitted() && $form->isValid()) {
+            $em = $this->getDoctrine()->getManager();
+            $em->persist($ignoreOriginInstanceRule);
+            $em->flush();
+
+            $this->get('session')->getFlashBag()->add(
+                'notice',
+                $this->get('translator')->trans('flashes.ignore_origin_instance_rule.notice.added')
+            );
+
+            return $this->redirectToRoute('ignore_origin_instance_rules_index');
+        }
+
+        return $this->render('WallabagCoreBundle:IgnoreOriginInstanceRule:new.html.twig', [
+            'rule' => $ignoreOriginInstanceRule,
+            'form' => $form->createView(),
+        ]);
+    }
+
+    /**
+     * Displays a form to edit an existing ignore origin instance rule entity.
+     *
+     * @Route("/{id}/edit", name="ignore_origin_instance_rules_edit", methods={"GET", "POST"})
+     *
+     * @return \Symfony\Component\HttpFoundation\Response
+     */
+    public function editAction(Request $request, IgnoreOriginInstanceRule $ignoreOriginInstanceRule)
+    {
+        $deleteForm = $this->createDeleteForm($ignoreOriginInstanceRule);
+        $editForm = $this->createForm('Wallabag\CoreBundle\Form\Type\IgnoreOriginInstanceRuleType', $ignoreOriginInstanceRule);
+        $editForm->handleRequest($request);
+
+        if ($editForm->isSubmitted() && $editForm->isValid()) {
+            $em = $this->getDoctrine()->getManager();
+            $em->persist($ignoreOriginInstanceRule);
+            $em->flush();
+
+            $this->get('session')->getFlashBag()->add(
+                'notice',
+                $this->get('translator')->trans('flashes.ignore_origin_instance_rule.notice.updated')
+            );
+
+            return $this->redirectToRoute('ignore_origin_instance_rules_index');
+        }
+
+        return $this->render('WallabagCoreBundle:IgnoreOriginInstanceRule:edit.html.twig', [
+            'rule' => $ignoreOriginInstanceRule,
+            'edit_form' => $editForm->createView(),
+            'delete_form' => $deleteForm->createView(),
+        ]);
+    }
+
+    /**
+     * Deletes a site credential entity.
+     *
+     * @Route("/{id}", name="ignore_origin_instance_rules_delete", methods={"DELETE"})
+     *
+     * @return \Symfony\Component\HttpFoundation\RedirectResponse
+     */
+    public function deleteAction(Request $request, IgnoreOriginInstanceRule $ignoreOriginInstanceRule)
+    {
+        $form = $this->createDeleteForm($ignoreOriginInstanceRule);
+        $form->handleRequest($request);
+
+        if ($form->isSubmitted() && $form->isValid()) {
+            $this->get('session')->getFlashBag()->add(
+                'notice',
+                $this->get('translator')->trans('flashes.ignore_origin_instance_rule.notice.deleted')
+            );
+
+            $em = $this->getDoctrine()->getManager();
+            $em->remove($ignoreOriginInstanceRule);
+            $em->flush();
+        }
+
+        return $this->redirectToRoute('ignore_origin_instance_rules_index');
+    }
+
+    /**
+     * Creates a form to delete a ignore origin instance rule entity.
+     *
+     * @param IgnoreOriginInstanceRule $ignoreOriginInstanceRule The ignore origin instance rule entity
+     *
+     * @return \Symfony\Component\Form\Form The form
+     */
+    private function createDeleteForm(IgnoreOriginInstanceRule $ignoreOriginInstanceRule)
+    {
+        return $this->createFormBuilder()
+            ->setAction($this->generateUrl('ignore_origin_instance_rules_delete', ['id' => $ignoreOriginInstanceRule->getId()]))
+            ->setMethod('DELETE')
+            ->getForm()
+        ;
+    }
+}
diff --git a/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginInstanceRuleType.php b/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginInstanceRuleType.php
new file mode 100644 (file)
index 0000000..d2e414f
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+namespace Wallabag\CoreBundle\Form\Type;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\Extension\Core\Type\SubmitType;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+class IgnoreOriginInstanceRuleType extends AbstractType
+{
+    public function buildForm(FormBuilderInterface $builder, array $options)
+    {
+        $builder
+            ->add('rule', TextType::class, [
+                'required' => true,
+                'label' => 'config.form_rules.rule_label',
+            ])
+            ->add('save', SubmitType::class, [
+                'label' => 'config.form.save',
+            ])
+        ;
+    }
+
+    public function configureOptions(OptionsResolver $resolver)
+    {
+        $resolver->setDefaults([
+            'data_class' => 'Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule',
+        ]);
+    }
+
+    public function getBlockPrefix()
+    {
+        return 'ignore_origin_instance_rule';
+    }
+}
index 92440c92cf07b4f49dc214de09f004cd62ac893f..05ee0b10bae68d9d4c34d6b2f19056f9c00958c4 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: 'Tilbage til de ulæste artikler'
         # users_management: 'Users management'
         # site_credentials: 'Site credentials'
+        # ignore_origin_instance_rules: 'Global ignore origin rules'
         # quickstart: "Quickstart"
     top:
         add_new_entry: 'Tilføj ny artikel'
@@ -661,3 +662,8 @@ flashes:
             # added: 'Site credential for "%host%" added'
             # updated: 'Site credential for "%host%" updated'
             # deleted: 'Site credential for "%host%" deleted'
+    ignore_origin_instance_rule:
+        notice:
+            # added: 'Global ignore origin rule added'
+            # updated: 'Global ignore origin rule updated'
+            # deleted: 'Global ignore origin rule deleted'
index 7a9382cb3aaaa2ee6a40cb2bfaca74f8f35a4891..908be26e64cb5fe4652d9099f7d1ed070f6ed719 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: 'Zurück zu ungelesenen Artikeln'
         users_management: 'Benutzerverwaltung'
         site_credentials: 'Zugangsdaten'
+        # ignore_origin_instance_rules: 'Global ignore origin rules'
         quickstart: "Schnelleinstieg"
     top:
         add_new_entry: 'Neuen Artikel hinzufügen'
@@ -661,3 +662,8 @@ flashes:
             added: 'Zugangsdaten für "%host%" hinzugefügt'
             updated: 'Zugangsdaten für "%host%" aktualisiert'
             deleted: 'Zugangsdaten für "%host%" gelöscht'
+    ignore_origin_instance_rule:
+        notice:
+            # added: 'Global ignore origin rule added'
+            # updated: 'Global ignore origin rule updated'
+            # deleted: 'Global ignore origin rule deleted'
index b16662c31bec93033fd1c6bb8601e622b5de82f5..d831a2aaec4817883a9fcaf1ab9d5a8549736f48 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: 'Back to unread articles'
         users_management: 'Users management'
         site_credentials: 'Site credentials'
+        ignore_origin_instance_rules: 'Global ignore origin rules'
         quickstart: "Quickstart"
     top:
         add_new_entry: 'Add a new entry'
@@ -595,6 +596,24 @@ site_credential:
         delete_confirm: Are you sure?
         back_to_list: Back to list
 
+ignore_origin_instance_rule:
+    page_title: Global ignore origin rules
+    new_ignore_origin_instance_rule: Create a global ignore origin rule
+    edit_ignore_origin_instance_rule: Edit an existing ignore origin rule
+    description: "Here you can manage the global ignore origin rules used to ignore some patterns of origin url."
+    list:
+        actions: Actions
+        edit_action: Edit
+        yes: Yes
+        no: No
+        create_new_one: Create a new global ignore origin rule
+    form:
+        rule_label: Rule
+        save: Save
+        delete: Delete
+        delete_confirm: Are you sure?
+        back_to_list: Back to list
+
 error:
     page_title: An error occurred
 
@@ -661,3 +680,8 @@ flashes:
             added: 'Site credential for "%host%" added'
             updated: 'Site credential for "%host%" updated'
             deleted: 'Site credential for "%host%" deleted'
+    ignore_origin_instance_rule:
+        notice:
+            added: 'Global ignore origin rule added'
+            updated: 'Global ignore origin rule updated'
+            deleted: 'Global ignore origin rule deleted'
index 3e77afd6b87f6e3473ce91ecbf92f2b111c63183..4de4dcb59de40a1f7a614932cd8a547c1d080a25 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: 'Volver a los artículos sin leer'
         users_management: 'Configuración de usuarios'
         site_credentials: 'Credenciales del sitio'
+        # ignore_origin_instance_rules: 'Global ignore origin rules'
         quickstart: "Inicio rápido"
     top:
         add_new_entry: 'Añadir un nuevo artículo'
@@ -661,3 +662,8 @@ flashes:
              added: 'Credenciales del sitio añadidas para "%host%"'
              updated: 'Credenciales del sitio actualizadas para "%host%"'
              deleted: 'Credenciales del sitio eliminadas para "%host%"'
+    ignore_origin_instance_rule:
+        notice:
+            # added: 'Global ignore origin rule added'
+            # updated: 'Global ignore origin rule updated'
+            # deleted: 'Global ignore origin rule deleted'
index 38c252f73c3d6fe93c100dce5e08c8d8b4f9f49a..32dcdb3c3bc0e08331a110574aac5b8bdef9d8d3 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: 'بازگشت به خوانده‌نشده‌ها'
         # users_management: 'Users management'
         # site_credentials: 'Site credentials'
+        # ignore_origin_instance_rules: 'Global ignore origin rules'
         quickstart: "Quickstart"
     top:
         add_new_entry: 'افزودن مقالهٔ تازه'
@@ -661,3 +662,8 @@ flashes:
             # added: 'Site credential for "%host%" added'
             # updated: 'Site credential for "%host%" updated'
             # deleted: 'Site credential for "%host%" deleted'
+    ignore_origin_instance_rule:
+        notice:
+            # added: 'Global ignore origin rule added'
+            # updated: 'Global ignore origin rule updated'
+            # deleted: 'Global ignore origin rule deleted'
index b12dd9ca938c506b0568d1be5e5387b1711d87fa..dfdf20836e7cc4608cd1c43e5b82f3979c345c29 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: "Retour aux articles non lus"
         users_management: "Gestion des utilisateurs"
         site_credentials: 'Accès aux sites'
+        ignore_origin_instance_rules: "Règles globales d'omission d'origine"
         quickstart: "Pour bien débuter"
     top:
         add_new_entry: "Sauvegarder un nouvel article"
@@ -619,11 +620,8 @@ flashes:
             otp_disabled: "Authentification à double-facteur désactivée"
             tagging_rules_imported: Règles bien importées
             tagging_rules_not_imported: Impossible d'importer les règles
-<<<<<<< HEAD
-=======
             ignore_origin_rules_deleted: "Règle d'omission d'origine supprimée"
             ignore_origin_rules_updated: "Règle d'omission d'origine mise à jour"
->>>>>>> 4c595340... fixup! Add new Ignore Origin rules tab, update ConfigController
     entry:
         notice:
             entry_already_saved: "Article déjà sauvegardé le %date%"
index eb44318b99c24f5aa283025817606c763d85c01b..42a50ca56c9fce1758d4c158187bad954ea2c89d 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: 'Torna ai contenuti non letti'
         users_management: 'Gestione utenti'
         site_credentials: 'Credenziali sito'
+        # ignore_origin_instance_rules: 'Global ignore origin rules'
         quickstart: "Introduzione"
     top:
         add_new_entry: 'Aggiungi un nuovo contenuto'
@@ -661,3 +662,8 @@ flashes:
             # added: 'Site credential for "%host%" added'
             # updated: 'Site credential for "%host%" updated'
             # deleted: 'Site credential for "%host%" deleted'
+    ignore_origin_instance_rule:
+        notice:
+            # added: 'Global ignore origin rule added'
+            # updated: 'Global ignore origin rule updated'
+            # deleted: 'Global ignore origin rule deleted'
index 165186b1d37846fe9182b1cb8ccf96c8be655d89..df3553c8e871df34f1d8c773017039bc96e2dd18 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: 'Tornar als articles pas legits'
         users_management: 'Gestion dels utilizaires'
         site_credentials: 'Identificants del site'
+        # ignore_origin_instance_rules: 'Global ignore origin rules'
         quickstart: "Per ben començar"
     top:
         add_new_entry: 'Enregistrar un novèl article'
@@ -661,3 +662,8 @@ flashes:
             added: 'Identificant per "%host%" ajustat'
             updated: 'Identificant per "%host%" mes a jorn'
             deleted: 'Identificant per "%host%" suprimit'
+    ignore_origin_instance_rule:
+        notice:
+            # added: 'Global ignore origin rule added'
+            # updated: 'Global ignore origin rule updated'
+            # deleted: 'Global ignore origin rule deleted'
index fbf64f30b26e6f2644b65995edc10be804c6add2..41977edec3cad8e0be8b42c828fd17de5fb09361 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: 'Powrót do nieprzeczytanych artykułów'
         users_management: 'Zarządzanie użytkownikami'
         site_credentials: 'Poświadczenia strony'
+        # ignore_origin_instance_rules: 'Global ignore origin rules'
         quickstart: "Szybki start"
     top:
         add_new_entry: 'Dodaj nowy wpis'
@@ -661,3 +662,8 @@ flashes:
             added: 'Poświadczenie dla "%host%" dodane'
             updated: 'Poświadczenie dla "%host%" zaktualizowane'
             deleted: 'Poświadczenie dla "%host%" usuniętę'
+    ignore_origin_instance_rule:
+        notice:
+            # added: 'Global ignore origin rule added'
+            # updated: 'Global ignore origin rule updated'
+            # deleted: 'Global ignore origin rule deleted'
index 93910d4be7e570b442d21919c1d46e7cabe4ac21..78918e15a95eba5e7c7fb0136d534faf999ac4ab 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: 'Voltar para os artigos não lidos'
         users_management: 'Gestão de Usuários'
         site_credentials: 'Credenciais do site'
+        # ignore_origin_instance_rules: 'Global ignore origin rules'
         quickstart: "Começo Rápido"
     top:
         add_new_entry: 'Adicionar um novo artigo'
@@ -658,3 +659,8 @@ flashes:
             added: 'Credencial do site para "%host%" foi adicionada'
             updated: 'Credencial do site pa "%host%" atualizada'
             deleted: 'Credencial do site pa "%host%" removida'
+    ignore_origin_instance_rule:
+        notice:
+            # added: 'Global ignore origin rule added'
+            # updated: 'Global ignore origin rule updated'
+            # deleted: 'Global ignore origin rule deleted'
index 5984d2298b778b074604da6c2a7ac90095a29ddb..5400187ab23d84e917fd94246da41b32b399fe78 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: 'Înapoi la articolele necitite'
         # users_management: 'Users management'
         # site_credentials: 'Site credentials'
+        # ignore_origin_instance_rules: 'Global ignore origin rules'
         # quickstart: "Quickstart"
     top:
         add_new_entry: 'Introdu un nou articol'
@@ -660,3 +661,8 @@ flashes:
             # added: 'Site credential for "%host%" added'
             # updated: 'Site credential for "%host%" updated'
             # deleted: 'Site credential for "%host%" deleted'
+    ignore_origin_instance_rule:
+        notice:
+            # added: 'Global ignore origin rule added'
+            # updated: 'Global ignore origin rule updated'
+            # deleted: 'Global ignore origin rule deleted'
index a138ee5d3d4c0e3e6099030129d5bb80503a0036..ce803ecdac6533499670434370074861628328d8 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: 'Назад к непрочитанным записям'
         users_management: 'Управление пользователями'
         site_credentials: 'Site credentials'
+        # ignore_origin_instance_rules: 'Global ignore origin rules'
         quickstart: "Быстрый старт"
     top:
         add_new_entry: 'Добавить новую запись'
@@ -660,3 +661,8 @@ flashes:
             # added: 'Site credential for "%host%" added'
             # updated: 'Site credential for "%host%" updated'
             # deleted: 'Site credential for "%host%" deleted'
+    ignore_origin_instance_rule:
+        notice:
+            # added: 'Global ignore origin rule added'
+            # updated: 'Global ignore origin rule updated'
+            # deleted: 'Global ignore origin rule deleted'
index b786a73d17acc42c538d9bd4f5ba0dbf67ed6678..7c887781b7723d4e28c05de882ddfb4f55679888 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: 'กลับไปยังรายการที่ไม่ได้อ่าน'
         users_management: 'การจัดการผู้ใช้'
         site_credentials: 'การรับรองไซต์'
+        # ignore_origin_instance_rules: 'Global ignore origin rules'
         quickstart: "เริ่มแบบด่วน"
     top:
         add_new_entry: 'เพิ่มรายการใหม่'
@@ -660,3 +661,8 @@ flashes:
             added: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการเพิ่ม'
             updated: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการอัปเดต'
             deleted: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการลบ'
+    ignore_origin_instance_rule:
+        notice:
+            # added: 'Global ignore origin rule added'
+            # updated: 'Global ignore origin rule updated'
+            # deleted: 'Global ignore origin rule deleted'
index a317c2f507054c8efc41208459a39212ac238901..f2ce40d90bd63a8e6d4463e7ec0a319bfe648dcc 100644 (file)
@@ -33,6 +33,7 @@ menu:
         back_to_unread: 'Okunmayan makalelere geri dön'
         # users_management: 'Users management'
         # site_credentials: 'Site credentials'
+        # ignore_origin_instance_rules: 'Global ignore origin rules'
         quickstart: "Hızlı başlangıç"
     top:
         add_new_entry: 'Yeni bir makale ekle'
@@ -660,3 +661,8 @@ flashes:
             # added: 'Site credential for "%host%" added'
             # updated: 'Site credential for "%host%" updated'
             # deleted: 'Site credential for "%host%" deleted'
+    ignore_origin_instance_rule:
+        notice:
+            # added: 'Global ignore origin rule added'
+            # updated: 'Global ignore origin rule updated'
+            # deleted: 'Global ignore origin rule deleted'
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/edit.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/edit.html.twig
new file mode 100644 (file)
index 0000000..ebb07d0
--- /dev/null
@@ -0,0 +1,44 @@
+{% extends "WallabagCoreBundle::layout.html.twig" %}
+
+{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
+
+{% block content %}
+
+    <div class="row">
+        <div class="col s12">
+            <div class="card-panel">
+                <div class="row">
+                    <div class="input-field col s12">
+                        <h4>{{ 'ignore_origin_instance_rule.edit_ignore_origin_instance_rule'|trans }}</h4>
+
+                        <div id="set6" class="col s12">
+                            {{ form_start(edit_form) }}
+                                {{ form_errors(edit_form) }}
+
+                                <div class="row">
+                                    <div class="input-field col s12">
+                                        {{ form_label(edit_form.rule) }}
+                                        {{ form_errors(edit_form.rule) }}
+                                        {{ form_widget(edit_form.rule) }}
+                                    </div>
+                                </div>
+
+                                <br/>
+
+                                {{ form_widget(edit_form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
+                                {{ form_widget(edit_form._token) }}
+                            </form>
+                            <p>
+                                {{ form_start(delete_form) }}
+                                    <button onclick="return confirm('{{ 'ignore_origin_instance_rule.form.delete_confirm'|trans|escape('js') }}')" type="submit" class="btn waves-effect waves-light red">{{ 'ignore_origin_instance_rule.form.delete'|trans }}</button>
+                                {{ form_end(delete_form) }}
+                            </p>
+                            <p><a class="waves-effect waves-light btn blue-grey" href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'ignore_origin_instance_rule.form.back_to_list'|trans }}</a></p>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/index.html.twig
new file mode 100644 (file)
index 0000000..2de7cf0
--- /dev/null
@@ -0,0 +1,42 @@
+{% extends "WallabagCoreBundle::layout.html.twig" %}
+
+{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
+
+{% block content %}
+
+    <div class="row">
+        <div class="col s12">
+            <div class="card-panel">
+                <div class="row">
+                    <div class="input-field col s12">
+                        <p class="help">{{ 'ignore_origin_instance_rule.description'|trans|raw }}</p>
+
+                        <table class="bordered">
+                            <thead>
+                                <tr>
+                                    <th>{{ 'ignore_origin_instance_rule.form.rule_label'|trans }}</th>
+                                    <th>{{ 'ignore_origin_instance_rule.list.actions'|trans }}</th>
+                                </tr>
+                            </thead>
+                            <tbody>
+                            {% for rule in rules %}
+                                <tr>
+                                    <td>{{ rule.rule }}</td>
+                                    <td>
+                                        <a href="{{ path('ignore_origin_instance_rules_edit', { 'id': rule.id }) }}">{{ 'ignore_origin_instance_rule.list.edit_action'|trans }}</a>
+                                    </td>
+                                </tr>
+                            {% endfor %}
+                            </tbody>
+                        </table>
+                        <br />
+                        <p>
+                            <a href="{{ path('ignore_origin_instance_rules_new') }}" class="waves-effect waves-light btn">{{ 'ignore_origin_instance_rule.list.create_new_one'|trans }}</a>
+                        </p>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/new.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/new.html.twig
new file mode 100644 (file)
index 0000000..fbe1f79
--- /dev/null
@@ -0,0 +1,37 @@
+{% extends "WallabagCoreBundle::layout.html.twig" %}
+
+{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
+
+{% block content %}
+
+    <div class="row">
+        <div class="col s12">
+            <div class="card-panel">
+                <div class="row">
+                    <div class="input-field col s12">
+                        <h4>{{ 'ignore_origin_instance_rule.new_ignore_origin_instance_rule'|trans }}</h4>
+
+                        <div id="set6" class="col s12">
+                            {{ form_start(form) }}
+                                {{ form_errors(form) }}
+
+                                <div class="row">
+                                    <div class="input-field col s12">
+                                        {{ form_label(form.rule) }}
+                                        {{ form_errors(form.rule) }}
+                                        {{ form_widget(form.rule) }}
+                                    </div>
+                                </div>
+
+                                {{ form_widget(form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
+                                {{ form_rest(form) }}
+                            </form>
+                            <p><a class="waves-effect waves-light btn blue-grey" href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'ignore_origin_instance_rule.form.back_to_list'|trans }}</a></p>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+{% endblock %}
index 6b1e2bd794679d2162b06d906562cdf601fa289d..e1446ff7c5ded75dea28b51ed199c7e74263384f 100644 (file)
@@ -45,6 +45,7 @@
         {% if is_granted('ROLE_SUPER_ADMIN') %}
             <li class="menu users"><a href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a></li>
             <li class="menu internal"><a href="{{ path('craue_config_settings_modify') }}">{{ 'menu.left.internal_settings'|trans }}</a></li>
+            <li class="menu ignore"><a href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'menu.left.ignore_origin_instance_rules'|trans }}</a></li>
         {% endif %}
         <li class="menu import"><a href="{{ path('import') }}">{{ 'menu.left.import'|trans }}</a></li>
         <li class="menu howto"><a href="{{ path('howto') }}">{{ 'menu.left.howto'|trans }}</a></li>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/edit.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/edit.html.twig
new file mode 100644 (file)
index 0000000..ebb07d0
--- /dev/null
@@ -0,0 +1,44 @@
+{% extends "WallabagCoreBundle::layout.html.twig" %}
+
+{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
+
+{% block content %}
+
+    <div class="row">
+        <div class="col s12">
+            <div class="card-panel">
+                <div class="row">
+                    <div class="input-field col s12">
+                        <h4>{{ 'ignore_origin_instance_rule.edit_ignore_origin_instance_rule'|trans }}</h4>
+
+                        <div id="set6" class="col s12">
+                            {{ form_start(edit_form) }}
+                                {{ form_errors(edit_form) }}
+
+                                <div class="row">
+                                    <div class="input-field col s12">
+                                        {{ form_label(edit_form.rule) }}
+                                        {{ form_errors(edit_form.rule) }}
+                                        {{ form_widget(edit_form.rule) }}
+                                    </div>
+                                </div>
+
+                                <br/>
+
+                                {{ form_widget(edit_form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
+                                {{ form_widget(edit_form._token) }}
+                            </form>
+                            <p>
+                                {{ form_start(delete_form) }}
+                                    <button onclick="return confirm('{{ 'ignore_origin_instance_rule.form.delete_confirm'|trans|escape('js') }}')" type="submit" class="btn waves-effect waves-light red">{{ 'ignore_origin_instance_rule.form.delete'|trans }}</button>
+                                {{ form_end(delete_form) }}
+                            </p>
+                            <p><a class="waves-effect waves-light btn blue-grey" href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'ignore_origin_instance_rule.form.back_to_list'|trans }}</a></p>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/index.html.twig
new file mode 100644 (file)
index 0000000..2de7cf0
--- /dev/null
@@ -0,0 +1,42 @@
+{% extends "WallabagCoreBundle::layout.html.twig" %}
+
+{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
+
+{% block content %}
+
+    <div class="row">
+        <div class="col s12">
+            <div class="card-panel">
+                <div class="row">
+                    <div class="input-field col s12">
+                        <p class="help">{{ 'ignore_origin_instance_rule.description'|trans|raw }}</p>
+
+                        <table class="bordered">
+                            <thead>
+                                <tr>
+                                    <th>{{ 'ignore_origin_instance_rule.form.rule_label'|trans }}</th>
+                                    <th>{{ 'ignore_origin_instance_rule.list.actions'|trans }}</th>
+                                </tr>
+                            </thead>
+                            <tbody>
+                            {% for rule in rules %}
+                                <tr>
+                                    <td>{{ rule.rule }}</td>
+                                    <td>
+                                        <a href="{{ path('ignore_origin_instance_rules_edit', { 'id': rule.id }) }}">{{ 'ignore_origin_instance_rule.list.edit_action'|trans }}</a>
+                                    </td>
+                                </tr>
+                            {% endfor %}
+                            </tbody>
+                        </table>
+                        <br />
+                        <p>
+                            <a href="{{ path('ignore_origin_instance_rules_new') }}" class="waves-effect waves-light btn">{{ 'ignore_origin_instance_rule.list.create_new_one'|trans }}</a>
+                        </p>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/new.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/new.html.twig
new file mode 100644 (file)
index 0000000..fbe1f79
--- /dev/null
@@ -0,0 +1,37 @@
+{% extends "WallabagCoreBundle::layout.html.twig" %}
+
+{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
+
+{% block content %}
+
+    <div class="row">
+        <div class="col s12">
+            <div class="card-panel">
+                <div class="row">
+                    <div class="input-field col s12">
+                        <h4>{{ 'ignore_origin_instance_rule.new_ignore_origin_instance_rule'|trans }}</h4>
+
+                        <div id="set6" class="col s12">
+                            {{ form_start(form) }}
+                                {{ form_errors(form) }}
+
+                                <div class="row">
+                                    <div class="input-field col s12">
+                                        {{ form_label(form.rule) }}
+                                        {{ form_errors(form.rule) }}
+                                        {{ form_widget(form.rule) }}
+                                    </div>
+                                </div>
+
+                                {{ form_widget(form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
+                                {{ form_rest(form) }}
+                            </form>
+                            <p><a class="waves-effect waves-light btn blue-grey" href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'ignore_origin_instance_rule.form.back_to_list'|trans }}</a></p>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+{% endblock %}
index c51d07fc2a64f8e121f34a0b05f743eb9b5f54a3..d9b6d190a188e4a3c0b790788fe36ab25ba9ea50 100644 (file)
                     <a class="waves-effect" href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a>
                 </li>
 
-                <li class="bold border-bottom {% if currentRoute == 'craue_config_settings_modify' %}active{% endif %}">
+                <li class="bold {% if currentRoute == 'craue_config_settings_modify' %}active{% endif %}">
                     <a class="waves-effect" href="{{ path('craue_config_settings_modify') }}">{{ 'menu.left.internal_settings'|trans }}</a>
                 </li>
+
+                <li class="bold border-bottom {% if currentRoute == 'ignore_origin_instance_rules_index' %}active{% endif %}">
+                    <a class="waves-effect" href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'menu.left.ignore_origin_instance_rules'|trans }}</a>
+                </li>
             {% endif %}
             <li class="bold {% if currentRoute == 'import' %}active{% endif %}">
                 <a class="waves-effect" href="{{ path('import') }}">{{ 'menu.left.import'|trans }}</a>
diff --git a/tests/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleControllerTest.php b/tests/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleControllerTest.php
new file mode 100644 (file)
index 0000000..9783cd2
--- /dev/null
@@ -0,0 +1,148 @@
+<?php
+
+namespace Tests\Wallabag\CoreBundle\Controller;
+
+use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
+
+class IgnoreOriginInstanceRuleControllerTest extends WallabagCoreTestCase
+{
+    public function testListIgnoreOriginInstanceRule()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/ignore-origin-instance-rules/');
+
+        $this->assertSame(200, $client->getResponse()->getStatusCode());
+
+        $body = $crawler->filter('body')->extract(['_text'])[0];
+
+        $this->assertContains('ignore_origin_instance_rule.description', $body);
+        $this->assertContains('ignore_origin_instance_rule.list.create_new_one', $body);
+    }
+
+    public function testIgnoreOriginInstanceRuleCreationEditionDeletion()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        // Creation
+        $crawler = $client->request('GET', '/ignore-origin-instance-rules/new');
+
+        $this->assertSame(200, $client->getResponse()->getStatusCode());
+
+        $body = $crawler->filter('body')->extract(['_text'])[0];
+
+        $this->assertContains('ignore_origin_instance_rule.new_ignore_origin_instance_rule', $body);
+        $this->assertContains('ignore_origin_instance_rule.form.back_to_list', $body);
+
+        $form = $crawler->filter('button[id=ignore_origin_instance_rule_save]')->form();
+
+        $data = [
+            'ignore_origin_instance_rule[rule]' => 'host = "foo.example.com"',
+        ];
+
+        $client->submit($form, $data);
+
+        $this->assertSame(302, $client->getResponse()->getStatusCode());
+
+        $crawler = $client->followRedirect();
+
+        $this->assertContains('flashes.ignore_origin_instance_rule.notice.added', $crawler->filter('body')->extract(['_text'])[0]);
+
+        // Edition
+        $editLink = $crawler->filter('div[id=content] table a')->last()->link();
+
+        $crawler = $client->click($editLink);
+
+        $this->assertSame(200, $client->getResponse()->getStatusCode());
+
+        $this->assertContains('foo.example.com', $crawler->filter('form[name=ignore_origin_instance_rule] input[type=text]')->extract(['value'])[0]);
+
+        $body = $crawler->filter('body')->extract(['_text'])[0];
+
+        $this->assertContains('ignore_origin_instance_rule.edit_ignore_origin_instance_rule', $body);
+        $this->assertContains('ignore_origin_instance_rule.form.back_to_list', $body);
+
+        $form = $crawler->filter('button[id=ignore_origin_instance_rule_save]')->form();
+
+        $data = [
+            'ignore_origin_instance_rule[rule]' => 'host = "bar.example.com"',
+        ];
+
+        $client->submit($form, $data);
+
+        $this->assertSame(302, $client->getResponse()->getStatusCode());
+
+        $crawler = $client->followRedirect();
+
+        $this->assertContains('flashes.ignore_origin_instance_rule.notice.updated', $crawler->filter('body')->extract(['_text'])[0]);
+
+        $editLink = $crawler->filter('div[id=content] table a')->last()->link();
+
+        $crawler = $client->click($editLink);
+
+        $this->assertSame(200, $client->getResponse()->getStatusCode());
+
+        $this->assertContains('bar.example.com', $crawler->filter('form[name=ignore_origin_instance_rule] input[type=text]')->extract(['value'])[0]);
+
+        $deleteForm = $crawler->filter('body')->selectButton('ignore_origin_instance_rule.form.delete')->form();
+
+        $client->submit($deleteForm, []);
+
+        $this->assertSame(302, $client->getResponse()->getStatusCode());
+
+        $crawler = $client->followRedirect();
+
+        $this->assertContains('flashes.ignore_origin_instance_rule.notice.deleted', $crawler->filter('body')->extract(['_text'])[0]);
+    }
+
+    public function dataForIgnoreOriginInstanceRuleCreationFail()
+    {
+        return [
+            [
+                [
+                    'ignore_origin_instance_rule[rule]' => 'foo = "bar"',
+                ],
+                [
+                    'The variable',
+                    'does not exist.',
+                ],
+            ],
+            [
+                [
+                    'ignore_origin_instance_rule[rule]' => '_all != "none"',
+                ],
+                [
+                    'The operator',
+                    'does not exist.',
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * @dataProvider dataForIgnoreOriginInstanceRuleCreationFail
+     */
+    public function testIgnoreOriginInstanceRuleCreationFail($data, $messages)
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/ignore-origin-instance-rules/new');
+
+        $this->assertSame(200, $client->getResponse()->getStatusCode());
+
+        $form = $crawler->filter('button[id=ignore_origin_instance_rule_save]')->form();
+
+        $crawler = $client->submit($form, $data);
+
+        $this->assertSame(200, $client->getResponse()->getStatusCode());
+
+        $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
+
+        foreach ($messages as $message) {
+            $this->assertContains($message, $body[0]);
+        }
+    }
+}