aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKevin Decherf <kevin@kdecherf.com>2020-04-26 15:39:57 +0200
committerGitHub <noreply@github.com>2020-04-26 15:39:57 +0200
commit0e8a0f77d0b643a884e6687bd9c463267852a970 (patch)
tree88c6761b4215637bba34b263015e87750c92a187
parent8a8a78a64c116caf81aaa4339906298bdc0e32e0 (diff)
parent71f7e58fbd84e1d15c7a405a3c5872adb937dc37 (diff)
downloadwallabag-0e8a0f77d0b643a884e6687bd9c463267852a970.tar.gz
wallabag-0e8a0f77d0b643a884e6687bd9c463267852a970.tar.zst
wallabag-0e8a0f77d0b643a884e6687bd9c463267852a970.zip
Merge pull request #4026 from wallabag/3760-ignorelist-db
Move Ignore Origin rules to database
-rw-r--r--app/DoctrineMigrations/Version20190826204730.php64
-rw-r--r--app/config/security.yml1
-rw-r--r--app/config/wallabag.yml8
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php8
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php79
-rw-r--r--src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php138
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginInstanceRuleFixtures.php36
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php36
-rw-r--r--src/Wallabag/CoreBundle/DependencyInjection/Configuration.php7
-rw-r--r--src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php1
-rw-r--r--src/Wallabag/CoreBundle/Entity/Config.php25
-rw-r--r--src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php70
-rw-r--r--src/Wallabag/CoreBundle/Entity/IgnoreOriginRuleInterface.php12
-rw-r--r--src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php97
-rw-r--r--src/Wallabag/CoreBundle/Entity/RuleInterface.php7
-rw-r--r--src/Wallabag/CoreBundle/Entity/TaggingRule.php2
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/IgnoreOriginInstanceRuleType.php37
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/IgnoreOriginUserRuleType.php37
-rw-r--r--src/Wallabag/CoreBundle/Helper/ContentProxy.php41
-rw-r--r--src/Wallabag/CoreBundle/Helper/RuleBasedIgnoreOriginProcessor.php50
-rw-r--r--src/Wallabag/CoreBundle/Operator/PHP/PatternMatches.php23
-rw-r--r--src/Wallabag/CoreBundle/Repository/IgnoreOriginInstanceRuleRepository.php9
-rw-r--r--src/Wallabag/CoreBundle/Repository/IgnoreOriginUserRuleRepository.php9
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml19
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.da.yml27
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.de.yml27
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.en.yml45
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.es.yml27
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml27
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml22
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.it.yml27
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml27
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml27
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml25
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml27
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml27
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.th.yml27
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml27
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig70
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/edit.html.twig87
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/index.html.twig42
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/new.html.twig80
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig94
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/edit.html.twig87
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/index.html.twig42
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/new.html.twig80
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig6
-rw-r--r--tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php6
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php151
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php26
-rw-r--r--tests/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleControllerTest.php148
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php127
-rw-r--r--tests/Wallabag/CoreBundle/Helper/RuleBasedIgnoreOriginProcessorTest.php212
54 files changed, 2384 insertions, 80 deletions
diff --git a/app/DoctrineMigrations/Version20190826204730.php b/app/DoctrineMigrations/Version20190826204730.php
new file mode 100644
index 00000000..ee1ba6bf
--- /dev/null
+++ b/app/DoctrineMigrations/Version20190826204730.php
@@ -0,0 +1,64 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Application\Migrations;
6
7use Doctrine\DBAL\Schema\Schema;
8use Wallabag\CoreBundle\Doctrine\WallabagMigration;
9
10/**
11 * Add tables for the ignore origin rules.
12 */
13final class Version20190826204730 extends WallabagMigration
14{
15 public function up(Schema $schema): void
16 {
17 if (false === $schema->hasTable($this->getTable('ignore_origin_user_rule'))) {
18 $userTable = $schema->createTable($this->getTable('ignore_origin_user_rule', true));
19 $userTable->addColumn('id', 'integer', ['autoincrement' => true]);
20 $userTable->addColumn('config_id', 'integer');
21 $userTable->addColumn('rule', 'string', ['length' => 255]);
22 $userTable->addIndex(['config_id'], 'idx_config');
23 $userTable->setPrimaryKey(['id']);
24 $userTable->addForeignKeyConstraint($this->getTable('config'), ['config_id'], ['id'], [], 'fk_config');
25
26 if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
27 $schema->dropSequence('ignore_origin_user_rule_id_seq');
28 $schema->createSequence('ignore_origin_user_rule_id_seq');
29 }
30 }
31
32 if (false === $schema->hasTable($this->getTable('ignore_origin_instance_rule'))) {
33 $instanceTable = $schema->createTable($this->getTable('ignore_origin_instance_rule', true));
34 $instanceTable->addColumn('id', 'integer', ['autoincrement' => true]);
35 $instanceTable->addColumn('rule', 'string', ['length' => 255]);
36 $instanceTable->setPrimaryKey(['id']);
37
38 if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
39 $schema->dropSequence('ignore_origin_instance_rule_id_seq');
40 $schema->createSequence('ignore_origin_instance_rule_id_seq');
41 }
42 }
43 }
44
45 public function postUp(Schema $schema): void
46 {
47 foreach ($this->container->getParameter('wallabag_core.default_ignore_origin_instance_rules') as $entity) {
48 $previous_rule = $this->container
49 ->get('doctrine.orm.default_entity_manager')
50 ->getConnection()
51 ->fetchArray('SELECT * FROM ' . $this->getTable('ignore_origin_instance_rule') . " WHERE rule = '" . $entity['rule'] . "'");
52
53 if (false === $previous_rule) {
54 $this->addSql('INSERT INTO ' . $this->getTable('ignore_origin_instance_rule') . " (rule) VALUES ('" . $entity['rule'] . "');");
55 }
56 }
57 }
58
59 public function down(Schema $schema): void
60 {
61 $schema->dropTable($this->getTable('ignore_origin_user_rule'));
62 $schema->dropTable($this->getTable('ignore_origin_instance_rule'));
63 }
64}
diff --git a/app/config/security.yml b/app/config/security.yml
index 760b2550..5a73440b 100644
--- a/app/config/security.yml
+++ b/app/config/security.yml
@@ -79,4 +79,5 @@ security:
79 - { path: ^/annotations, roles: ROLE_USER } 79 - { path: ^/annotations, roles: ROLE_USER }
80 - { path: ^/2fa, role: IS_AUTHENTICATED_2FA_IN_PROGRESS } 80 - { path: ^/2fa, role: IS_AUTHENTICATED_2FA_IN_PROGRESS }
81 - { path: ^/users, roles: ROLE_SUPER_ADMIN } 81 - { path: ^/users, roles: ROLE_SUPER_ADMIN }
82 - { path: ^/ignore-origin-instance-rules, roles: ROLE_SUPER_ADMIN }
82 - { path: ^/, roles: ROLE_USER } 83 - { path: ^/, roles: ROLE_USER }
diff --git a/app/config/wallabag.yml b/app/config/wallabag.yml
index eaa92507..4dad9200 100644
--- a/app/config/wallabag.yml
+++ b/app/config/wallabag.yml
@@ -165,6 +165,14 @@ wallabag_core:
165 value: 0 165 value: 0
166 section: entry 166 section: entry
167 167
168 default_ignore_origin_instance_rules:
169 -
170 rule: host = "feedproxy.google.com"
171 -
172 rule: host = "feeds.reuters.com"
173 -
174 rule: _all ~ "https?://www\.lemonde\.fr/tiny.*"
175
168wallabag_user: 176wallabag_user:
169 registration_enabled: "%fosuser_registration%" 177 registration_enabled: "%fosuser_registration%"
170 178
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 3aa332f1..8d08187a 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -12,6 +12,7 @@ use Symfony\Component\Console\Output\BufferedOutput;
12use Symfony\Component\Console\Output\OutputInterface; 12use Symfony\Component\Console\Output\OutputInterface;
13use Symfony\Component\Console\Question\Question; 13use Symfony\Component\Console\Question\Question;
14use Symfony\Component\Console\Style\SymfonyStyle; 14use Symfony\Component\Console\Style\SymfonyStyle;
15use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
15use Wallabag\CoreBundle\Entity\InternalSetting; 16use Wallabag\CoreBundle\Entity\InternalSetting;
16 17
17class InstallCommand extends ContainerAwareCommand 18class InstallCommand extends ContainerAwareCommand
@@ -277,6 +278,7 @@ class InstallCommand extends ContainerAwareCommand
277 278
278 // cleanup before insert new stuff 279 // cleanup before insert new stuff
279 $em->createQuery('DELETE FROM WallabagCoreBundle:InternalSetting')->execute(); 280 $em->createQuery('DELETE FROM WallabagCoreBundle:InternalSetting')->execute();
281 $em->createQuery('DELETE FROM WallabagCoreBundle:IgnoreOriginInstanceRule')->execute();
280 282
281 foreach ($this->getContainer()->getParameter('wallabag_core.default_internal_settings') as $setting) { 283 foreach ($this->getContainer()->getParameter('wallabag_core.default_internal_settings') as $setting) {
282 $newSetting = new InternalSetting(); 284 $newSetting = new InternalSetting();
@@ -286,6 +288,12 @@ class InstallCommand extends ContainerAwareCommand
286 $em->persist($newSetting); 288 $em->persist($newSetting);
287 } 289 }
288 290
291 foreach ($this->getContainer()->getParameter('wallabag_core.default_ignore_origin_instance_rules') as $ignore_origin_instance_rule) {
292 $newIgnoreOriginInstanceRule = new IgnoreOriginInstanceRule();
293 $newIgnoreOriginInstanceRule->setRule($ignore_origin_instance_rule['rule']);
294 $em->persist($newIgnoreOriginInstanceRule);
295 }
296
289 $em->flush(); 297 $em->flush();
290 298
291 $this->io->text('<info>Config successfully setup.</info>'); 299 $this->io->text('<info>Config successfully setup.</info>');
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 56efe82b..3efc7bb3 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -14,10 +14,13 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
14use Symfony\Component\Routing\Annotation\Route; 14use Symfony\Component\Routing\Annotation\Route;
15use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint; 15use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
16use Wallabag\CoreBundle\Entity\Config; 16use Wallabag\CoreBundle\Entity\Config;
17use Wallabag\CoreBundle\Entity\IgnoreOriginUserRule;
18use Wallabag\CoreBundle\Entity\RuleInterface;
17use Wallabag\CoreBundle\Entity\TaggingRule; 19use Wallabag\CoreBundle\Entity\TaggingRule;
18use Wallabag\CoreBundle\Form\Type\ChangePasswordType; 20use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
19use Wallabag\CoreBundle\Form\Type\ConfigType; 21use Wallabag\CoreBundle\Form\Type\ConfigType;
20use Wallabag\CoreBundle\Form\Type\FeedType; 22use Wallabag\CoreBundle\Form\Type\FeedType;
23use Wallabag\CoreBundle\Form\Type\IgnoreOriginUserRuleType;
21use Wallabag\CoreBundle\Form\Type\TaggingRuleImportType; 24use Wallabag\CoreBundle\Form\Type\TaggingRuleImportType;
22use Wallabag\CoreBundle\Form\Type\TaggingRuleType; 25use Wallabag\CoreBundle\Form\Type\TaggingRuleType;
23use Wallabag\CoreBundle\Form\Type\UserInformationType; 26use Wallabag\CoreBundle\Form\Type\UserInformationType;
@@ -173,6 +176,40 @@ class ConfigController extends Controller
173 return $this->redirect($this->generateUrl('config') . '#set5'); 176 return $this->redirect($this->generateUrl('config') . '#set5');
174 } 177 }
175 178
179 // handle ignore origin rules
180 $ignoreOriginUserRule = new IgnoreOriginUserRule();
181 $action = $this->generateUrl('config') . '#set6';
182
183 if ($request->query->has('ignore-origin-user-rule')) {
184 $ignoreOriginUserRule = $this->getDoctrine()
185 ->getRepository('WallabagCoreBundle:IgnoreOriginUserRule')
186 ->find($request->query->get('ignore-origin-user-rule'));
187
188 if ($this->getUser()->getId() !== $ignoreOriginUserRule->getConfig()->getUser()->getId()) {
189 return $this->redirect($action);
190 }
191
192 $action = $this->generateUrl('config', [
193 'ignore-origin-user-rule' => $ignoreOriginUserRule->getId(),
194 ]) . '#set6';
195 }
196
197 $newIgnoreOriginUserRule = $this->createForm(IgnoreOriginUserRuleType::class, $ignoreOriginUserRule, ['action' => $action]);
198 $newIgnoreOriginUserRule->handleRequest($request);
199
200 if ($newIgnoreOriginUserRule->isSubmitted() && $newIgnoreOriginUserRule->isValid()) {
201 $ignoreOriginUserRule->setConfig($config);
202 $em->persist($ignoreOriginUserRule);
203 $em->flush();
204
205 $this->addFlash(
206 'notice',
207 'flashes.config.notice.ignore_origin_rules_updated'
208 );
209
210 return $this->redirect($this->generateUrl('config') . '#set6');
211 }
212
176 return $this->render('WallabagCoreBundle:Config:index.html.twig', [ 213 return $this->render('WallabagCoreBundle:Config:index.html.twig', [
177 'form' => [ 214 'form' => [
178 'config' => $configForm->createView(), 215 'config' => $configForm->createView(),
@@ -181,6 +218,7 @@ class ConfigController extends Controller
181 'user' => $userForm->createView(), 218 'user' => $userForm->createView(),
182 'new_tagging_rule' => $newTaggingRule->createView(), 219 'new_tagging_rule' => $newTaggingRule->createView(),
183 'import_tagging_rule' => $taggingRulesImportform->createView(), 220 'import_tagging_rule' => $taggingRulesImportform->createView(),
221 'new_ignore_origin_user_rule' => $newIgnoreOriginUserRule->createView(),
184 ], 222 ],
185 'feed' => [ 223 'feed' => [
186 'username' => $user->getUsername(), 224 'username' => $user->getUsername(),
@@ -448,6 +486,43 @@ class ConfigController extends Controller
448 } 486 }
449 487
450 /** 488 /**
489 * Deletes an ignore origin rule and redirect to the config homepage.
490 *
491 * @Route("/ignore-origin-user-rule/delete/{id}", requirements={"id" = "\d+"}, name="delete_ignore_origin_rule")
492 *
493 * @return RedirectResponse
494 */
495 public function deleteIgnoreOriginRuleAction(IgnoreOriginUserRule $rule)
496 {
497 $this->validateRuleAction($rule);
498
499 $em = $this->getDoctrine()->getManager();
500 $em->remove($rule);
501 $em->flush();
502
503 $this->addFlash(
504 'notice',
505 'flashes.config.notice.ignore_origin_rules_deleted'
506 );
507
508 return $this->redirect($this->generateUrl('config') . '#set6');
509 }
510
511 /**
512 * Edit an ignore origin rule.
513 *
514 * @Route("/ignore-origin-user-rule/edit/{id}", requirements={"id" = "\d+"}, name="edit_ignore_origin_rule")
515 *
516 * @return RedirectResponse
517 */
518 public function editIgnoreOriginRuleAction(IgnoreOriginUserRule $rule)
519 {
520 $this->validateRuleAction($rule);
521
522 return $this->redirect($this->generateUrl('config') . '?ignore-origin-user-rule=' . $rule->getId() . '#set6');
523 }
524
525 /**
451 * Remove all annotations OR tags OR entries for the current user. 526 * Remove all annotations OR tags OR entries for the current user.
452 * 527 *
453 * @Route("/reset/{type}", requirements={"id" = "annotations|tags|entries"}, name="config_reset") 528 * @Route("/reset/{type}", requirements={"id" = "annotations|tags|entries"}, name="config_reset")
@@ -659,10 +734,10 @@ class ConfigController extends Controller
659 /** 734 /**
660 * Validate that a rule can be edited/deleted by the current user. 735 * Validate that a rule can be edited/deleted by the current user.
661 */ 736 */
662 private function validateRuleAction(TaggingRule $rule) 737 private function validateRuleAction(RuleInterface $rule)
663 { 738 {
664 if ($this->getUser()->getId() !== $rule->getConfig()->getUser()->getId()) { 739 if ($this->getUser()->getId() !== $rule->getConfig()->getUser()->getId()) {
665 throw $this->createAccessDeniedException('You can not access this tagging rule.'); 740 throw $this->createAccessDeniedException('You can not access this rule.');
666 } 741 }
667 } 742 }
668 743
diff --git a/src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php b/src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php
new file mode 100644
index 00000000..ef1f0ed7
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php
@@ -0,0 +1,138 @@
1<?php
2
3namespace Wallabag\CoreBundle\Controller;
4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Symfony\Component\HttpFoundation\Request;
7use Symfony\Component\Routing\Annotation\Route;
8use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
9
10/**
11 * IgnoreOriginInstanceRuleController controller.
12 *
13 * @Route("/ignore-origin-instance-rules")
14 */
15class IgnoreOriginInstanceRuleController extends Controller
16{
17 /**
18 * Lists all IgnoreOriginInstanceRule entities.
19 *
20 * @Route("/", name="ignore_origin_instance_rules_index", methods={"GET"})
21 */
22 public function indexAction()
23 {
24 $rules = $this->get('wallabag_core.ignore_origin_instance_rule_repository')->findAll();
25
26 return $this->render('WallabagCoreBundle:IgnoreOriginInstanceRule:index.html.twig', [
27 'rules' => $rules,
28 ]);
29 }
30
31 /**
32 * Creates a new ignore origin instance rule entity.
33 *
34 * @Route("/new", name="ignore_origin_instance_rules_new", methods={"GET", "POST"})
35 *
36 * @return \Symfony\Component\HttpFoundation\Response
37 */
38 public function newAction(Request $request)
39 {
40 $ignoreOriginInstanceRule = new IgnoreOriginInstanceRule();
41
42 $form = $this->createForm('Wallabag\CoreBundle\Form\Type\IgnoreOriginInstanceRuleType', $ignoreOriginInstanceRule);
43 $form->handleRequest($request);
44
45 if ($form->isSubmitted() && $form->isValid()) {
46 $em = $this->getDoctrine()->getManager();
47 $em->persist($ignoreOriginInstanceRule);
48 $em->flush();
49
50 $this->get('session')->getFlashBag()->add(
51 'notice',
52 $this->get('translator')->trans('flashes.ignore_origin_instance_rule.notice.added')
53 );
54
55 return $this->redirectToRoute('ignore_origin_instance_rules_index');
56 }
57
58 return $this->render('WallabagCoreBundle:IgnoreOriginInstanceRule:new.html.twig', [
59 'rule' => $ignoreOriginInstanceRule,
60 'form' => $form->createView(),
61 ]);
62 }
63
64 /**
65 * Displays a form to edit an existing ignore origin instance rule entity.
66 *
67 * @Route("/{id}/edit", name="ignore_origin_instance_rules_edit", methods={"GET", "POST"})
68 *
69 * @return \Symfony\Component\HttpFoundation\Response
70 */
71 public function editAction(Request $request, IgnoreOriginInstanceRule $ignoreOriginInstanceRule)
72 {
73 $deleteForm = $this->createDeleteForm($ignoreOriginInstanceRule);
74 $editForm = $this->createForm('Wallabag\CoreBundle\Form\Type\IgnoreOriginInstanceRuleType', $ignoreOriginInstanceRule);
75 $editForm->handleRequest($request);
76
77 if ($editForm->isSubmitted() && $editForm->isValid()) {
78 $em = $this->getDoctrine()->getManager();
79 $em->persist($ignoreOriginInstanceRule);
80 $em->flush();
81
82 $this->get('session')->getFlashBag()->add(
83 'notice',
84 $this->get('translator')->trans('flashes.ignore_origin_instance_rule.notice.updated')
85 );
86
87 return $this->redirectToRoute('ignore_origin_instance_rules_index');
88 }
89
90 return $this->render('WallabagCoreBundle:IgnoreOriginInstanceRule:edit.html.twig', [
91 'rule' => $ignoreOriginInstanceRule,
92 'edit_form' => $editForm->createView(),
93 'delete_form' => $deleteForm->createView(),
94 ]);
95 }
96
97 /**
98 * Deletes a site credential entity.
99 *
100 * @Route("/{id}", name="ignore_origin_instance_rules_delete", methods={"DELETE"})
101 *
102 * @return \Symfony\Component\HttpFoundation\RedirectResponse
103 */
104 public function deleteAction(Request $request, IgnoreOriginInstanceRule $ignoreOriginInstanceRule)
105 {
106 $form = $this->createDeleteForm($ignoreOriginInstanceRule);
107 $form->handleRequest($request);
108
109 if ($form->isSubmitted() && $form->isValid()) {
110 $this->get('session')->getFlashBag()->add(
111 'notice',
112 $this->get('translator')->trans('flashes.ignore_origin_instance_rule.notice.deleted')
113 );
114
115 $em = $this->getDoctrine()->getManager();
116 $em->remove($ignoreOriginInstanceRule);
117 $em->flush();
118 }
119
120 return $this->redirectToRoute('ignore_origin_instance_rules_index');
121 }
122
123 /**
124 * Creates a form to delete a ignore origin instance rule entity.
125 *
126 * @param IgnoreOriginInstanceRule $ignoreOriginInstanceRule The ignore origin instance rule entity
127 *
128 * @return \Symfony\Component\Form\Form The form
129 */
130 private function createDeleteForm(IgnoreOriginInstanceRule $ignoreOriginInstanceRule)
131 {
132 return $this->createFormBuilder()
133 ->setAction($this->generateUrl('ignore_origin_instance_rules_delete', ['id' => $ignoreOriginInstanceRule->getId()]))
134 ->setMethod('DELETE')
135 ->getForm()
136 ;
137 }
138}
diff --git a/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginInstanceRuleFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginInstanceRuleFixtures.php
new file mode 100644
index 00000000..8a0a06ed
--- /dev/null
+++ b/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginInstanceRuleFixtures.php
@@ -0,0 +1,36 @@
1<?php
2
3namespace Wallabag\CoreBundle\DataFixtures;
4
5use Doctrine\Bundle\FixturesBundle\Fixture;
6use Doctrine\Common\Persistence\ObjectManager;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
10
11class IgnoreOriginInstanceRuleFixtures extends Fixture implements ContainerAwareInterface
12{
13 /**
14 * @var ContainerInterface
15 */
16 private $container;
17
18 public function setContainer(ContainerInterface $container = null)
19 {
20 $this->container = $container;
21 }
22
23 /**
24 * {@inheritdoc}
25 */
26 public function load(ObjectManager $manager)
27 {
28 foreach ($this->container->getParameter('wallabag_core.default_ignore_origin_instance_rules') as $ignore_origin_instance_rule) {
29 $newIgnoreOriginInstanceRule = new IgnoreOriginInstanceRule();
30 $newIgnoreOriginInstanceRule->setRule($ignore_origin_instance_rule['rule']);
31 $manager->persist($newIgnoreOriginInstanceRule);
32 }
33
34 $manager->flush();
35 }
36}
diff --git a/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php
new file mode 100644
index 00000000..679eff7d
--- /dev/null
+++ b/src/Wallabag/CoreBundle/DataFixtures/IgnoreOriginUserRuleFixtures.php
@@ -0,0 +1,36 @@
1<?php
2
3namespace Wallabag\CoreBundle\DataFixtures;
4
5use Doctrine\Bundle\FixturesBundle\Fixture;
6use Doctrine\Common\DataFixtures\DependentFixtureInterface;
7use Doctrine\Common\Persistence\ObjectManager;
8use Wallabag\CoreBundle\Entity\IgnoreOriginUserRule;
9use Wallabag\UserBundle\DataFixtures\UserFixtures;
10
11class IgnoreOriginUserRuleFixtures extends Fixture implements DependentFixtureInterface
12{
13 /**
14 * {@inheritdoc}
15 */
16 public function load(ObjectManager $manager)
17 {
18 $rule = new IgnoreOriginUserRule();
19 $rule->setRule('host = "example.fr"');
20 $rule->setConfig($this->getReference('admin-user')->getConfig());
21
22 $manager->persist($rule);
23
24 $manager->flush();
25 }
26
27 /**
28 * {@inheritdoc}
29 */
30 public function getDependencies()
31 {
32 return [
33 UserFixtures::class,
34 ];
35 }
36}
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
index 7ae73371..85747256 100644
--- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
+++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php
@@ -65,6 +65,13 @@ class Configuration implements ConfigurationInterface
65 ->end() 65 ->end()
66 ->scalarNode('encryption_key_path') 66 ->scalarNode('encryption_key_path')
67 ->end() 67 ->end()
68 ->arrayNode('default_ignore_origin_instance_rules')
69 ->prototype('array')
70 ->children()
71 ->scalarNode('rule')->end()
72 ->end()
73 ->end()
74 ->end()
68 ->end() 75 ->end()
69 ; 76 ;
70 77
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
index e9a1e9e0..af91e588 100644
--- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
+++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
@@ -30,6 +30,7 @@ class WallabagCoreExtension extends Extension
30 $container->setParameter('wallabag_core.api_limit_mass_actions', $config['api_limit_mass_actions']); 30 $container->setParameter('wallabag_core.api_limit_mass_actions', $config['api_limit_mass_actions']);
31 $container->setParameter('wallabag_core.default_internal_settings', $config['default_internal_settings']); 31 $container->setParameter('wallabag_core.default_internal_settings', $config['default_internal_settings']);
32 $container->setParameter('wallabag_core.site_credentials.encryption_key_path', $config['encryption_key_path']); 32 $container->setParameter('wallabag_core.site_credentials.encryption_key_path', $config['encryption_key_path']);
33 $container->setParameter('wallabag_core.default_ignore_origin_instance_rules', $config['default_ignore_origin_instance_rules']);
33 34
34 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); 35 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
35 $loader->load('services.yml'); 36 $loader->load('services.yml');
diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php
index fe7942ee..1bed4513 100644
--- a/src/Wallabag/CoreBundle/Entity/Config.php
+++ b/src/Wallabag/CoreBundle/Entity/Config.php
@@ -119,6 +119,12 @@ class Config
119 */ 119 */
120 private $taggingRules; 120 private $taggingRules;
121 121
122 /**
123 * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\IgnoreOriginUserRule", mappedBy="config", cascade={"remove"})
124 * @ORM\OrderBy({"id" = "ASC"})
125 */
126 private $ignoreOriginRules;
127
122 /* 128 /*
123 * @param User $user 129 * @param User $user
124 */ 130 */
@@ -126,6 +132,7 @@ class Config
126 { 132 {
127 $this->user = $user; 133 $this->user = $user;
128 $this->taggingRules = new ArrayCollection(); 134 $this->taggingRules = new ArrayCollection();
135 $this->ignoreOriginRules = new ArrayCollection();
129 } 136 }
130 137
131 /** 138 /**
@@ -387,4 +394,22 @@ class Config
387 { 394 {
388 return $this->taggingRules; 395 return $this->taggingRules;
389 } 396 }
397
398 /**
399 * @return Config
400 */
401 public function addIgnoreOriginRule(IgnoreOriginUserRule $rule)
402 {
403 $this->ignoreOriginRules[] = $rule;
404
405 return $this;
406 }
407
408 /**
409 * @return ArrayCollection<IgnoreOriginUserRule>
410 */
411 public function getIgnoreOriginRules()
412 {
413 return $this->ignoreOriginRules;
414 }
390} 415}
diff --git a/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php b/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php
new file mode 100644
index 00000000..ce3b6e7d
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Entity/IgnoreOriginInstanceRule.php
@@ -0,0 +1,70 @@
1<?php
2
3namespace Wallabag\CoreBundle\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
6use Symfony\Bridge\RulerZ\Validator\Constraints as RulerZAssert;
7use Symfony\Component\Validator\Constraints as Assert;
8
9/**
10 * Ignore Origin rule.
11 *
12 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository")
13 * @ORM\Table(name="`ignore_origin_instance_rule`")
14 */
15class IgnoreOriginInstanceRule implements IgnoreOriginRuleInterface, RuleInterface
16{
17 /**
18 * @var int
19 *
20 * @ORM\Column(name="id", type="integer")
21 * @ORM\Id
22 * @ORM\GeneratedValue(strategy="AUTO")
23 */
24 private $id;
25
26 /**
27 * @var string
28 *
29 * @Assert\NotBlank()
30 * @Assert\Length(max=255)
31 * @RulerZAssert\ValidRule(
32 * allowed_variables={"host","_all"},
33 * allowed_operators={"=","~"}
34 * )
35 * @ORM\Column(name="rule", type="string", nullable=false)
36 */
37 private $rule;
38
39 /**
40 * Get id.
41 *
42 * @return int
43 */
44 public function getId()
45 {
46 return $this->id;
47 }
48
49 /**
50 * Set rule.
51 *
52 * @return IgnoreOriginRuleInterface
53 */
54 public function setRule(string $rule)
55 {
56 $this->rule = $rule;
57
58 return $this;
59 }
60
61 /**
62 * Get rule.
63 *
64 * @return string
65 */
66 public function getRule()
67 {
68 return $this->rule;
69 }
70}
diff --git a/src/Wallabag/CoreBundle/Entity/IgnoreOriginRuleInterface.php b/src/Wallabag/CoreBundle/Entity/IgnoreOriginRuleInterface.php
new file mode 100644
index 00000000..eb865a3a
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Entity/IgnoreOriginRuleInterface.php
@@ -0,0 +1,12 @@
1<?php
2
3namespace Wallabag\CoreBundle\Entity;
4
5interface IgnoreOriginRuleInterface
6{
7 public function getId();
8
9 public function setRule(string $rule);
10
11 public function getRule();
12}
diff --git a/src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php b/src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php
new file mode 100644
index 00000000..0b6f318d
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Entity/IgnoreOriginUserRule.php
@@ -0,0 +1,97 @@
1<?php
2
3namespace Wallabag\CoreBundle\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
6use Symfony\Bridge\RulerZ\Validator\Constraints as RulerZAssert;
7use Symfony\Component\Validator\Constraints as Assert;
8
9/**
10 * Ignore Origin rule.
11 *
12 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\IgnoreOriginUserRuleRepository")
13 * @ORM\Table(name="`ignore_origin_user_rule`")
14 */
15class IgnoreOriginUserRule implements IgnoreOriginRuleInterface, RuleInterface
16{
17 /**
18 * @var int
19 *
20 * @ORM\Column(name="id", type="integer")
21 * @ORM\Id
22 * @ORM\GeneratedValue(strategy="AUTO")
23 */
24 private $id;
25
26 /**
27 * @var string
28 *
29 * @Assert\NotBlank()
30 * @Assert\Length(max=255)
31 * @RulerZAssert\ValidRule(
32 * allowed_variables={"host","_all"},
33 * allowed_operators={"=","~"}
34 * )
35 * @ORM\Column(name="rule", type="string", nullable=false)
36 */
37 private $rule;
38
39 /**
40 * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", inversedBy="ignoreOriginRules")
41 */
42 private $config;
43
44 /**
45 * Get id.
46 *
47 * @return int
48 */
49 public function getId()
50 {
51 return $this->id;
52 }
53
54 /**
55 * Set rule.
56 *
57 * @return IgnoreOriginRuleInterface
58 */
59 public function setRule(string $rule)
60 {
61 $this->rule = $rule;
62
63 return $this;
64 }
65
66 /**
67 * Get rule.
68 *
69 * @return string
70 */
71 public function getRule()
72 {
73 return $this->rule;
74 }
75
76 /**
77 * Set config.
78 *
79 * @return IgnoreOriginUserRule
80 */
81 public function setConfig(Config $config)
82 {
83 $this->config = $config;
84
85 return $this;
86 }
87
88 /**
89 * Get config.
90 *
91 * @return Config
92 */
93 public function getConfig()
94 {
95 return $this->config;
96 }
97}
diff --git a/src/Wallabag/CoreBundle/Entity/RuleInterface.php b/src/Wallabag/CoreBundle/Entity/RuleInterface.php
new file mode 100644
index 00000000..8e9b5c45
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Entity/RuleInterface.php
@@ -0,0 +1,7 @@
1<?php
2
3namespace Wallabag\CoreBundle\Entity;
4
5interface RuleInterface
6{
7}
diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php
index f7166087..7bed7a69 100644
--- a/src/Wallabag/CoreBundle/Entity/TaggingRule.php
+++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php
@@ -17,7 +17,7 @@ use Symfony\Component\Validator\Constraints as Assert;
17 * @ORM\Table(name="`tagging_rule`") 17 * @ORM\Table(name="`tagging_rule`")
18 * @ORM\Entity 18 * @ORM\Entity
19 */ 19 */
20class TaggingRule 20class TaggingRule implements RuleInterface
21{ 21{
22 /** 22 /**
23 * @var int 23 * @var int
diff --git a/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginInstanceRuleType.php b/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginInstanceRuleType.php
new file mode 100644
index 00000000..d2e414fb
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginInstanceRuleType.php
@@ -0,0 +1,37 @@
1<?php
2
3namespace Wallabag\CoreBundle\Form\Type;
4
5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\Extension\Core\Type\SubmitType;
7use Symfony\Component\Form\Extension\Core\Type\TextType;
8use Symfony\Component\Form\FormBuilderInterface;
9use Symfony\Component\OptionsResolver\OptionsResolver;
10
11class IgnoreOriginInstanceRuleType extends AbstractType
12{
13 public function buildForm(FormBuilderInterface $builder, array $options)
14 {
15 $builder
16 ->add('rule', TextType::class, [
17 'required' => true,
18 'label' => 'config.form_rules.rule_label',
19 ])
20 ->add('save', SubmitType::class, [
21 'label' => 'config.form.save',
22 ])
23 ;
24 }
25
26 public function configureOptions(OptionsResolver $resolver)
27 {
28 $resolver->setDefaults([
29 'data_class' => 'Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule',
30 ]);
31 }
32
33 public function getBlockPrefix()
34 {
35 return 'ignore_origin_instance_rule';
36 }
37}
diff --git a/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginUserRuleType.php b/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginUserRuleType.php
new file mode 100644
index 00000000..b9110f17
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Form/Type/IgnoreOriginUserRuleType.php
@@ -0,0 +1,37 @@
1<?php
2
3namespace Wallabag\CoreBundle\Form\Type;
4
5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\Extension\Core\Type\SubmitType;
7use Symfony\Component\Form\Extension\Core\Type\TextType;
8use Symfony\Component\Form\FormBuilderInterface;
9use Symfony\Component\OptionsResolver\OptionsResolver;
10
11class IgnoreOriginUserRuleType extends AbstractType
12{
13 public function buildForm(FormBuilderInterface $builder, array $options)
14 {
15 $builder
16 ->add('rule', TextType::class, [
17 'required' => true,
18 'label' => 'config.form_rules.rule_label',
19 ])
20 ->add('save', SubmitType::class, [
21 'label' => 'config.form.save',
22 ])
23 ;
24 }
25
26 public function configureOptions(OptionsResolver $resolver)
27 {
28 $resolver->setDefaults([
29 'data_class' => 'Wallabag\CoreBundle\Entity\IgnoreOriginUserRule',
30 ]);
31 }
32
33 public function getBlockPrefix()
34 {
35 return 'ignore_origin_user_rule';
36 }
37}
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index 9c6fa8db..7e93249d 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -19,6 +19,7 @@ class ContentProxy
19{ 19{
20 protected $graby; 20 protected $graby;
21 protected $tagger; 21 protected $tagger;
22 protected $ignoreOriginProcessor;
22 protected $validator; 23 protected $validator;
23 protected $logger; 24 protected $logger;
24 protected $mimeGuesser; 25 protected $mimeGuesser;
@@ -26,10 +27,11 @@ class ContentProxy
26 protected $eventDispatcher; 27 protected $eventDispatcher;
27 protected $storeArticleHeaders; 28 protected $storeArticleHeaders;
28 29
29 public function __construct(Graby $graby, RuleBasedTagger $tagger, ValidatorInterface $validator, LoggerInterface $logger, $fetchingErrorMessage, $storeArticleHeaders = false) 30 public function __construct(Graby $graby, RuleBasedTagger $tagger, RuleBasedIgnoreOriginProcessor $ignoreOriginProcessor, ValidatorInterface $validator, LoggerInterface $logger, $fetchingErrorMessage, $storeArticleHeaders = false)
30 { 31 {
31 $this->graby = $graby; 32 $this->graby = $graby;
32 $this->tagger = $tagger; 33 $this->tagger = $tagger;
34 $this->ignoreOriginProcessor = $ignoreOriginProcessor;
33 $this->validator = $validator; 35 $this->validator = $validator;
34 $this->logger = $logger; 36 $this->logger = $logger;
35 $this->mimeGuesser = new MimeTypeExtensionGuesser(); 37 $this->mimeGuesser = new MimeTypeExtensionGuesser();
@@ -356,7 +358,7 @@ class ContentProxy
356 $diff_keys = array_keys($diff); 358 $diff_keys = array_keys($diff);
357 sort($diff_keys); 359 sort($diff_keys);
358 360
359 if ($this->ignoreUrl($entry->getUrl())) { 361 if ($this->ignoreOriginProcessor->process($entry)) {
360 $entry->setUrl($url); 362 $entry->setUrl($url);
361 363
362 return false; 364 return false;
@@ -396,41 +398,6 @@ class ContentProxy
396 } 398 }
397 399
398 /** 400 /**
399 * Check entry url against an ignore list to replace with content url.
400 *
401 * XXX: move the ignore list in the database to let users handle it
402 *
403 * @param string $url url to test
404 *
405 * @return bool true if url matches ignore list otherwise false
406 */
407 private function ignoreUrl($url)
408 {
409 $ignored_hosts = ['feedproxy.google.com', 'feeds.reuters.com'];
410 $ignored_patterns = ['https?://www\.lemonde\.fr/tiny.*'];
411
412 $parsed_url = parse_url($url);
413
414 $filtered = array_filter($ignored_hosts, function ($var) use ($parsed_url) {
415 return $var === $parsed_url['host'];
416 });
417
418 if ([] !== $filtered) {
419 return true;
420 }
421
422 $filtered = array_filter($ignored_patterns, function ($var) use ($url) {
423 return preg_match("`$var`i", $url);
424 });
425
426 if ([] !== $filtered) {
427 return true;
428 }
429
430 return false;
431 }
432
433 /**
434 * Validate that the given content has at least a title, an html and a url. 401 * Validate that the given content has at least a title, an html and a url.
435 * 402 *
436 * @return bool true if valid otherwise false 403 * @return bool true if valid otherwise false
diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedIgnoreOriginProcessor.php b/src/Wallabag/CoreBundle/Helper/RuleBasedIgnoreOriginProcessor.php
new file mode 100644
index 00000000..333e5b0a
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Helper/RuleBasedIgnoreOriginProcessor.php
@@ -0,0 +1,50 @@
1<?php
2
3namespace Wallabag\CoreBundle\Helper;
4
5use Psr\Log\LoggerInterface;
6use RulerZ\RulerZ;
7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository;
9
10class RuleBasedIgnoreOriginProcessor
11{
12 protected $rulerz;
13 protected $logger;
14 protected $ignoreOriginInstanceRuleRepository;
15
16 public function __construct(RulerZ $rulerz, LoggerInterface $logger, IgnoreOriginInstanceRuleRepository $ignoreOriginInstanceRuleRepository)
17 {
18 $this->rulerz = $rulerz;
19 $this->logger = $logger;
20 $this->ignoreOriginInstanceRuleRepository = $ignoreOriginInstanceRuleRepository;
21 }
22
23 /**
24 * @param Entry $entry Entry to process
25 *
26 * @return bool
27 */
28 public function process(Entry $entry)
29 {
30 $url = $entry->getUrl();
31 $userRules = $entry->getUser()->getConfig()->getIgnoreOriginRules()->toArray();
32 $rules = array_merge($this->ignoreOriginInstanceRuleRepository->findAll(), $userRules);
33
34 $parsed_url = parse_url($url);
35 // We add the former url as a new key _all for pattern matching
36 $parsed_url['_all'] = $url;
37
38 foreach ($rules as $rule) {
39 if ($this->rulerz->satisfies($parsed_url, $rule->getRule())) {
40 $this->logger->info('Origin url matching ignore rule.', [
41 'rule' => $rule->getRule(),
42 ]);
43
44 return true;
45 }
46 }
47
48 return false;
49 }
50}
diff --git a/src/Wallabag/CoreBundle/Operator/PHP/PatternMatches.php b/src/Wallabag/CoreBundle/Operator/PHP/PatternMatches.php
new file mode 100644
index 00000000..532e2bb3
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Operator/PHP/PatternMatches.php
@@ -0,0 +1,23 @@
1<?php
2
3namespace Wallabag\CoreBundle\Operator\PHP;
4
5/**
6 * Provides a "~" operator used for ignore origin rules.
7 *
8 * It asserts that a subject matches a given regexp pattern, in a
9 * case-insensitive way.
10 *
11 * This operator will be used to compile ignore origin rules in PHP, usable
12 * directly on Entry objects for instance.
13 * It's registered in RulerZ using a service (wallabag.operator.array.pattern_matches);
14 */
15class PatternMatches
16{
17 public function __invoke($subject, $pattern)
18 {
19 $count = preg_match("`$pattern`i", $subject);
20
21 return \is_int($count) && $count > 0;
22 }
23}
diff --git a/src/Wallabag/CoreBundle/Repository/IgnoreOriginInstanceRuleRepository.php b/src/Wallabag/CoreBundle/Repository/IgnoreOriginInstanceRuleRepository.php
new file mode 100644
index 00000000..708a0ede
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Repository/IgnoreOriginInstanceRuleRepository.php
@@ -0,0 +1,9 @@
1<?php
2
3namespace Wallabag\CoreBundle\Repository;
4
5use Doctrine\ORM\EntityRepository;
6
7class IgnoreOriginInstanceRuleRepository extends EntityRepository
8{
9}
diff --git a/src/Wallabag/CoreBundle/Repository/IgnoreOriginUserRuleRepository.php b/src/Wallabag/CoreBundle/Repository/IgnoreOriginUserRuleRepository.php
new file mode 100644
index 00000000..8aa4c265
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Repository/IgnoreOriginUserRuleRepository.php
@@ -0,0 +1,9 @@
1<?php
2
3namespace Wallabag\CoreBundle\Repository;
4
5use Doctrine\ORM\EntityRepository;
6
7class IgnoreOriginUserRuleRepository extends EntityRepository
8{
9}
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml
index 3f3d4de7..8417ac35 100644
--- a/src/Wallabag/CoreBundle/Resources/config/services.yml
+++ b/src/Wallabag/CoreBundle/Resources/config/services.yml
@@ -92,6 +92,7 @@ services:
92 arguments: 92 arguments:
93 - "@wallabag_core.graby" 93 - "@wallabag_core.graby"
94 - "@wallabag_core.rule_based_tagger" 94 - "@wallabag_core.rule_based_tagger"
95 - "@wallabag_core.rule_based_ignore_origin_processor"
95 - "@validator" 96 - "@validator"
96 - "@logger" 97 - "@logger"
97 - '%wallabag_core.fetching_error_message%' 98 - '%wallabag_core.fetching_error_message%'
@@ -110,6 +111,13 @@ services:
110 - "@wallabag_core.entry_repository" 111 - "@wallabag_core.entry_repository"
111 - "@logger" 112 - "@logger"
112 113
114 wallabag_core.rule_based_ignore_origin_processor:
115 class: Wallabag\CoreBundle\Helper\RuleBasedIgnoreOriginProcessor
116 arguments:
117 - "@rulerz"
118 - "@logger"
119 - "@wallabag_core.ignore_origin_instance_rule_repository"
120
113 # repository as a service 121 # repository as a service
114 wallabag_core.entry_repository: 122 wallabag_core.entry_repository:
115 class: Wallabag\CoreBundle\Repository\EntryRepository 123 class: Wallabag\CoreBundle\Repository\EntryRepository
@@ -131,6 +139,12 @@ services:
131 calls: 139 calls:
132 - [ setCrypto, [ "@wallabag_core.helper.crypto_proxy" ] ] 140 - [ setCrypto, [ "@wallabag_core.helper.crypto_proxy" ] ]
133 141
142 wallabag_core.ignore_origin_instance_rule_repository:
143 class: Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository
144 factory: [ "@doctrine.orm.default_entity_manager", getRepository ]
145 arguments:
146 - WallabagCoreBundle:IgnoreOriginInstanceRule
147
134 wallabag_core.helper.entries_export: 148 wallabag_core.helper.entries_export:
135 class: Wallabag\CoreBundle\Helper\EntriesExport 149 class: Wallabag\CoreBundle\Helper\EntriesExport
136 arguments: 150 arguments:
@@ -158,6 +172,11 @@ services:
158 tags: 172 tags:
159 - { name: rulerz.operator, target: doctrine, operator: notmatches, inline: true } 173 - { name: rulerz.operator, target: doctrine, operator: notmatches, inline: true }
160 174
175 wallabag.operator.array.pattern_matches:
176 class: Wallabag\CoreBundle\Operator\PHP\PatternMatches
177 tags:
178 - { name: rulerz.operator, target: native, operator: "~" }
179
161 wallabag_core.helper.redirect: 180 wallabag_core.helper.redirect:
162 class: Wallabag\CoreBundle\Helper\Redirect 181 class: Wallabag\CoreBundle\Helper\Redirect
163 arguments: 182 arguments:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
index 4d525979..54df2e64 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: 'Tilbage til de ulæste artikler' 33 back_to_unread: 'Tilbage til de ulæste artikler'
34 # users_management: 'Users management' 34 # users_management: 'Users management'
35 # site_credentials: 'Site credentials' 35 # site_credentials: 'Site credentials'
36 # ignore_origin_instance_rules: 'Global ignore origin rules'
36 # quickstart: "Quickstart" 37 # quickstart: "Quickstart"
37 top: 38 top:
38 add_new_entry: 'Tilføj ny artikel' 39 add_new_entry: 'Tilføj ny artikel'
@@ -59,6 +60,7 @@ config:
59 user_info: 'Brugeroplysninger' 60 user_info: 'Brugeroplysninger'
60 password: 'Adgangskode' 61 password: 'Adgangskode'
61 # rules: 'Tagging rules' 62 # rules: 'Tagging rules'
63 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Tilføj bruger' 64 new_user: 'Tilføj bruger'
63 # reset: 'Reset area' 65 # reset: 'Reset area'
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 # and: 'One rule AND another' 179 # and: 'One rule AND another'
178 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>' 180 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>'
179 # notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>' 181 # notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
182 form_ignore_origin_rules:
183 # faq:
184 # title: 'FAQ'
185 # ignore_origin_rules_definition_title: 'What does « ignore origin rules » mean?'
186 # ignore_origin_rules_definition_description: 'They are used by wallabag to automatically ignore an origin address after a redirect.<br />If a redirect occurs while fetching a new entry, all the ignore origin rules (<i>user defined and instance defined</i>) will be used to ignore the origin address.'
187 # how_to_use_them_title: 'How do I use them?'
188 # how_to_use_them_description: 'Let us assume you want to ignore the origin of an entry coming from « <i>rss.example.com</i> » (<i>knowing that after a redirect, the actual address is example.com</i>).<br />In that case, you should put « host = "rss.example.com" » in the <i>Rule</i> field.'
189 # variables_available_title: 'Which variables and operators can I use to write rules?'
190 # variables_available_description: 'The following variables and operators can be used to create ignore origin rules:'
191 # meaning: 'Meaning'
192 # variable_description:
193 # label: 'Variable'
194 # host: 'Host of the address'
195 # _all: 'Full address, mainly for pattern matching'
196 # operator_description:
197 # label: 'Operator'
198 # equal_to: 'Equal to…'
199 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>_all ~ "https?://rss.example.com/foobar/.*"</code>'
180 otp: 200 otp:
181 # page_title: Two-factor authentication 201 # page_title: Two-factor authentication
182 # app: 202 # app:
@@ -617,6 +637,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 637 # otp_disabled: Two-factor authentication disabled
618 # tagging_rules_imported: Tagging rules imported 638 # tagging_rules_imported: Tagging rules imported
619 # tagging_rules_not_imported: Error while importing tagging rules 639 # tagging_rules_not_imported: Error while importing tagging rules
640 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
641 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 642 entry:
621 notice: 643 notice:
622 # entry_already_saved: 'Entry already saved on %date%' 644 # entry_already_saved: 'Entry already saved on %date%'
@@ -658,3 +680,8 @@ flashes:
658 # added: 'Site credential for "%host%" added' 680 # added: 'Site credential for "%host%" added'
659 # updated: 'Site credential for "%host%" updated' 681 # updated: 'Site credential for "%host%" updated'
660 # deleted: 'Site credential for "%host%" deleted' 682 # deleted: 'Site credential for "%host%" deleted'
683 ignore_origin_instance_rule:
684 notice:
685 # added: 'Global ignore origin rule added'
686 # updated: 'Global ignore origin rule updated'
687 # deleted: 'Global ignore origin rule deleted'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
index cd70c99f..549704d0 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: 'Zurück zu ungelesenen Artikeln' 33 back_to_unread: 'Zurück zu ungelesenen Artikeln'
34 users_management: 'Benutzerverwaltung' 34 users_management: 'Benutzerverwaltung'
35 site_credentials: 'Zugangsdaten' 35 site_credentials: 'Zugangsdaten'
36 # ignore_origin_instance_rules: 'Global ignore origin rules'
36 quickstart: "Schnelleinstieg" 37 quickstart: "Schnelleinstieg"
37 top: 38 top:
38 add_new_entry: 'Neuen Artikel hinzufügen' 39 add_new_entry: 'Neuen Artikel hinzufügen'
@@ -59,6 +60,7 @@ config:
59 user_info: 'Benutzerinformation' 60 user_info: 'Benutzerinformation'
60 password: 'Kennwort' 61 password: 'Kennwort'
61 rules: 'Tagging-Regeln' 62 rules: 'Tagging-Regeln'
63 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Benutzer hinzufügen' 64 new_user: 'Benutzer hinzufügen'
63 reset: 'Zurücksetzen' 65 reset: 'Zurücksetzen'
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 and: 'Eine Regel UND eine andere' 179 and: 'Eine Regel UND eine andere'
178 matches: 'Testet, ob eine <i>Variable</i> auf eine <i>Suche</i> zutrifft (Groß- und Kleinschreibung wird nicht berücksichtigt).<br />Beispiel: <code>title matches "Fußball"</code>' 180 matches: 'Testet, ob eine <i>Variable</i> auf eine <i>Suche</i> zutrifft (Groß- und Kleinschreibung wird nicht berücksichtigt).<br />Beispiel: <code>title matches "Fußball"</code>'
179 notmatches: 'Testet, ob ein <i>Titel</i> nicht auf eine <i>Suche</i> zutrifft (Groß- und Kleinschreibung wird nicht berücksichtigt).<br />Beispiel: <code>title notmatches "Fußball"</code>' 181 notmatches: 'Testet, ob ein <i>Titel</i> nicht auf eine <i>Suche</i> zutrifft (Groß- und Kleinschreibung wird nicht berücksichtigt).<br />Beispiel: <code>title notmatches "Fußball"</code>'
182 form_ignore_origin_rules:
183 # faq:
184 # title: 'FAQ'
185 # ignore_origin_rules_definition_title: 'What does « ignore origin rules » mean?'
186 # ignore_origin_rules_definition_description: 'They are used by wallabag to automatically ignore an origin address after a redirect.<br />If a redirect occurs while fetching a new entry, all the ignore origin rules (<i>user defined and instance defined</i>) will be used to ignore the origin address.'
187 # how_to_use_them_title: 'How do I use them?'
188 # how_to_use_them_description: 'Let us assume you want to ignore the origin of an entry coming from « <i>rss.example.com</i> » (<i>knowing that after a redirect, the actual address is example.com</i>).<br />In that case, you should put « host = "rss.example.com" » in the <i>Rule</i> field.'
189 # variables_available_title: 'Which variables and operators can I use to write rules?'
190 # variables_available_description: 'The following variables and operators can be used to create ignore origin rules:'
191 # meaning: 'Meaning'
192 # variable_description:
193 # label: 'Variable'
194 # host: 'Host of the address'
195 # _all: 'Full address, mainly for pattern matching'
196 # operator_description:
197 # label: 'Operator'
198 # equal_to: 'Equal to…'
199 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>_all ~ "https?://rss.example.com/foobar/.*"</code>'
180 otp: 200 otp:
181 # page_title: Two-factor authentication 201 # page_title: Two-factor authentication
182 # app: 202 # app:
@@ -617,6 +637,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 637 # otp_disabled: Two-factor authentication disabled
618 # tagging_rules_imported: Tagging rules imported 638 # tagging_rules_imported: Tagging rules imported
619 # tagging_rules_not_imported: Error while importing tagging rules 639 # tagging_rules_not_imported: Error while importing tagging rules
640 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
641 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 642 entry:
621 notice: 643 notice:
622 entry_already_saved: 'Eintrag bereits am %date% gespeichert' 644 entry_already_saved: 'Eintrag bereits am %date% gespeichert'
@@ -658,3 +680,8 @@ flashes:
658 added: 'Zugangsdaten für "%host%" hinzugefügt' 680 added: 'Zugangsdaten für "%host%" hinzugefügt'
659 updated: 'Zugangsdaten für "%host%" aktualisiert' 681 updated: 'Zugangsdaten für "%host%" aktualisiert'
660 deleted: 'Zugangsdaten für "%host%" gelöscht' 682 deleted: 'Zugangsdaten für "%host%" gelöscht'
683 ignore_origin_instance_rule:
684 notice:
685 # added: 'Global ignore origin rule added'
686 # updated: 'Global ignore origin rule updated'
687 # deleted: 'Global ignore origin rule deleted'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
index 1bc32423..a68a7d7d 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: 'Back to unread articles' 33 back_to_unread: 'Back to unread articles'
34 users_management: 'Users management' 34 users_management: 'Users management'
35 site_credentials: 'Site credentials' 35 site_credentials: 'Site credentials'
36 ignore_origin_instance_rules: 'Global ignore origin rules'
36 quickstart: "Quickstart" 37 quickstart: "Quickstart"
37 top: 38 top:
38 add_new_entry: 'Add a new entry' 39 add_new_entry: 'Add a new entry'
@@ -59,6 +60,7 @@ config:
59 user_info: 'User information' 60 user_info: 'User information'
60 password: 'Password' 61 password: 'Password'
61 rules: 'Tagging rules' 62 rules: 'Tagging rules'
63 ignore_origin: 'Ignore origin rules'
62 new_user: 'Add a user' 64 new_user: 'Add a user'
63 reset: 'Reset area' 65 reset: 'Reset area'
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 and: 'One rule AND another' 179 and: 'One rule AND another'
178 matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>' 180 matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>'
179 notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>' 181 notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
182 form_ignore_origin_rules:
183 faq:
184 title: 'FAQ'
185 ignore_origin_rules_definition_title: 'What does « ignore origin rules » mean?'
186 ignore_origin_rules_definition_description: 'They are used by wallabag to automatically ignore an origin address after a redirect.<br />If a redirect occurs while fetching a new entry, all the ignore origin rules (<i>user defined and instance defined</i>) will be used to ignore the origin address.'
187 how_to_use_them_title: 'How do I use them?'
188 how_to_use_them_description: 'Let us assume you want to ignore the origin of an entry coming from « <i>rss.example.com</i> » (<i>knowing that after a redirect, the actual address is example.com</i>).<br />In that case, you should put « host = "rss.example.com" » in the <i>Rule</i> field.'
189 variables_available_title: 'Which variables and operators can I use to write rules?'
190 variables_available_description: 'The following variables and operators can be used to create ignore origin rules:'
191 meaning: 'Meaning'
192 variable_description:
193 label: 'Variable'
194 host: 'Host of the address'
195 _all: 'Full address, mainly for pattern matching'
196 operator_description:
197 label: 'Operator'
198 equal_to: 'Equal to…'
199 matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>_all ~ "https?://rss.example.com/foobar/.*"</code>'
180 otp: 200 otp:
181 page_title: Two-factor authentication 201 page_title: Two-factor authentication
182 app: 202 app:
@@ -594,6 +614,24 @@ site_credential:
594 delete_confirm: Are you sure? 614 delete_confirm: Are you sure?
595 back_to_list: Back to list 615 back_to_list: Back to list
596 616
617ignore_origin_instance_rule:
618 page_title: Global ignore origin rules
619 new_ignore_origin_instance_rule: Create a global ignore origin rule
620 edit_ignore_origin_instance_rule: Edit an existing ignore origin rule
621 description: "Here you can manage the global ignore origin rules used to ignore some patterns of origin url."
622 list:
623 actions: Actions
624 edit_action: Edit
625 yes: Yes
626 no: No
627 create_new_one: Create a new global ignore origin rule
628 form:
629 rule_label: Rule
630 save: Save
631 delete: Delete
632 delete_confirm: Are you sure?
633 back_to_list: Back to list
634
597error: 635error:
598 page_title: An error occurred 636 page_title: An error occurred
599 637
@@ -617,6 +655,8 @@ flashes:
617 otp_disabled: Two-factor authentication disabled 655 otp_disabled: Two-factor authentication disabled
618 tagging_rules_imported: Tagging rules imported 656 tagging_rules_imported: Tagging rules imported
619 tagging_rules_not_imported: Error while importing tagging rules 657 tagging_rules_not_imported: Error while importing tagging rules
658 ignore_origin_rules_deleted: 'Ignore origin rule deleted'
659 ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 660 entry:
621 notice: 661 notice:
622 entry_already_saved: 'Entry already saved on %date%' 662 entry_already_saved: 'Entry already saved on %date%'
@@ -658,3 +698,8 @@ flashes:
658 added: 'Site credential for "%host%" added' 698 added: 'Site credential for "%host%" added'
659 updated: 'Site credential for "%host%" updated' 699 updated: 'Site credential for "%host%" updated'
660 deleted: 'Site credential for "%host%" deleted' 700 deleted: 'Site credential for "%host%" deleted'
701 ignore_origin_instance_rule:
702 notice:
703 added: 'Global ignore origin rule added'
704 updated: 'Global ignore origin rule updated'
705 deleted: 'Global ignore origin rule deleted'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
index bced72e9..c3e3ba81 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: 'Volver a los artículos sin leer' 33 back_to_unread: 'Volver a los artículos sin leer'
34 users_management: 'Configuración de usuarios' 34 users_management: 'Configuración de usuarios'
35 site_credentials: 'Credenciales del sitio' 35 site_credentials: 'Credenciales del sitio'
36 # ignore_origin_instance_rules: 'Global ignore origin rules'
36 quickstart: "Inicio rápido" 37 quickstart: "Inicio rápido"
37 top: 38 top:
38 add_new_entry: 'Añadir un nuevo artículo' 39 add_new_entry: 'Añadir un nuevo artículo'
@@ -59,6 +60,7 @@ config:
59 user_info: 'Información de usuario' 60 user_info: 'Información de usuario'
60 password: 'Contraseña' 61 password: 'Contraseña'
61 rules: 'Reglas de etiquetado automáticas' 62 rules: 'Reglas de etiquetado automáticas'
63 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Añadir un usuario' 64 new_user: 'Añadir un usuario'
63 reset: 'Reiniciar mi cuenta' 65 reset: 'Reiniciar mi cuenta'
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 and: 'Una regla Y la otra' 179 and: 'Una regla Y la otra'
178 matches: 'Prueba si un <i>sujeto</i> corresponde a una <i>búsqueda</i> (insensible a mayúsculas).<br />Ejemplo : <code>title matches "fútbol"</code>' 180 matches: 'Prueba si un <i>sujeto</i> corresponde a una <i>búsqueda</i> (insensible a mayúsculas).<br />Ejemplo : <code>title matches "fútbol"</code>'
179 notmatches: 'Prueba si <i>subject</i> no corresponde a una <i>búsqueda</i> (insensible a mayúsculas).<br />Example: <code>title notmatches "fútbol"</code>' 181 notmatches: 'Prueba si <i>subject</i> no corresponde a una <i>búsqueda</i> (insensible a mayúsculas).<br />Example: <code>title notmatches "fútbol"</code>'
182 form_ignore_origin_rules:
183 # faq:
184 # title: 'FAQ'
185 # ignore_origin_rules_definition_title: 'What does « ignore origin rules » mean?'
186 # ignore_origin_rules_definition_description: 'They are used by wallabag to automatically ignore an origin address after a redirect.<br />If a redirect occurs while fetching a new entry, all the ignore origin rules (<i>user defined and instance defined</i>) will be used to ignore the origin address.'
187 # how_to_use_them_title: 'How do I use them?'
188 # how_to_use_them_description: 'Let us assume you want to ignore the origin of an entry coming from « <i>rss.example.com</i> » (<i>knowing that after a redirect, the actual address is example.com</i>).<br />In that case, you should put « host = "rss.example.com" » in the <i>Rule</i> field.'
189 # variables_available_title: 'Which variables and operators can I use to write rules?'
190 # variables_available_description: 'The following variables and operators can be used to create ignore origin rules:'
191 # meaning: 'Meaning'
192 # variable_description:
193 # label: 'Variable'
194 # host: 'Host of the address'
195 # _all: 'Full address, mainly for pattern matching'
196 # operator_description:
197 # label: 'Operator'
198 # equal_to: 'Equal to…'
199 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>_all ~ "https?://rss.example.com/foobar/.*"</code>'
180 otp: 200 otp:
181 page_title: Autenticación de dos pasos 201 page_title: Autenticación de dos pasos
182 app: 202 app:
@@ -617,6 +637,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 637 # otp_disabled: Two-factor authentication disabled
618 tagging_rules_imported: Reglas de etiquetado importadas 638 tagging_rules_imported: Reglas de etiquetado importadas
619 tagging_rules_not_imported: Un error se ha producico en la importación de las reglas de etiquetado 639 tagging_rules_not_imported: Un error se ha producico en la importación de las reglas de etiquetado
640 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
641 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 642 entry:
621 notice: 643 notice:
622 entry_already_saved: 'Artículo ya guardado el %fecha%' 644 entry_already_saved: 'Artículo ya guardado el %fecha%'
@@ -658,3 +680,8 @@ flashes:
658 added: 'Credenciales del sitio añadidas para "%host%"' 680 added: 'Credenciales del sitio añadidas para "%host%"'
659 updated: 'Credenciales del sitio actualizadas para "%host%"' 681 updated: 'Credenciales del sitio actualizadas para "%host%"'
660 deleted: 'Credenciales del sitio eliminadas para "%host%"' 682 deleted: 'Credenciales del sitio eliminadas para "%host%"'
683 ignore_origin_instance_rule:
684 notice:
685 # added: 'Global ignore origin rule added'
686 # updated: 'Global ignore origin rule updated'
687 # deleted: 'Global ignore origin rule deleted'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
index 0704204a..4a52a208 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: 'بازگشت به خوانده‌نشده‌ها' 33 back_to_unread: 'بازگشت به خوانده‌نشده‌ها'
34 # users_management: 'Users management' 34 # users_management: 'Users management'
35 # site_credentials: 'Site credentials' 35 # site_credentials: 'Site credentials'
36 # ignore_origin_instance_rules: 'Global ignore origin rules'
36 quickstart: "Quickstart" 37 quickstart: "Quickstart"
37 top: 38 top:
38 add_new_entry: 'افزودن مقالهٔ تازه' 39 add_new_entry: 'افزودن مقالهٔ تازه'
@@ -59,6 +60,7 @@ config:
59 user_info: 'اطلاعات کاربر' 60 user_info: 'اطلاعات کاربر'
60 password: 'رمز' 61 password: 'رمز'
61 rules: 'برچسب‌گذاری خودکار' 62 rules: 'برچسب‌گذاری خودکار'
63 # ignore_origin: 'Ignore origin rules'
62 new_user: 'افزودن کاربر' 64 new_user: 'افزودن کاربر'
63 # reset: 'Reset area' 65 # reset: 'Reset area'
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 # and: 'One rule AND another' 179 # and: 'One rule AND another'
178 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>' 180 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>'
179 # notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>' 181 # notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
182 form_ignore_origin_rules:
183 # faq:
184 # title: 'FAQ'
185 # ignore_origin_rules_definition_title: 'What does « ignore origin rules » mean?'
186 # ignore_origin_rules_definition_description: 'They are used by wallabag to automatically ignore an origin address after a redirect.<br />If a redirect occurs while fetching a new entry, all the ignore origin rules (<i>user defined and instance defined</i>) will be used to ignore the origin address.'
187 # how_to_use_them_title: 'How do I use them?'
188 # how_to_use_them_description: 'Let us assume you want to ignore the origin of an entry coming from « <i>rss.example.com</i> » (<i>knowing that after a redirect, the actual address is example.com</i>).<br />In that case, you should put « host = "rss.example.com" » in the <i>Rule</i> field.'
189 # variables_available_title: 'Which variables and operators can I use to write rules?'
190 # variables_available_description: 'The following variables and operators can be used to create ignore origin rules:'
191 # meaning: 'Meaning'
192 # variable_description:
193 # label: 'Variable'
194 # host: 'Host of the address'
195 # _all: 'Full address, mainly for pattern matching'
196 # operator_description:
197 # label: 'Operator'
198 # equal_to: 'Equal to…'
199 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>_all ~ "https?://rss.example.com/foobar/.*"</code>'
180 otp: 200 otp:
181 # page_title: Two-factor authentication 201 # page_title: Two-factor authentication
182 # app: 202 # app:
@@ -617,6 +637,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 637 # otp_disabled: Two-factor authentication disabled
618 # tagging_rules_imported: Tagging rules imported 638 # tagging_rules_imported: Tagging rules imported
619 # tagging_rules_not_imported: Error while importing tagging rules 639 # tagging_rules_not_imported: Error while importing tagging rules
640 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
641 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 642 entry:
621 notice: 643 notice:
622 entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود' 644 entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود'
@@ -658,3 +680,8 @@ flashes:
658 # added: 'Site credential for "%host%" added' 680 # added: 'Site credential for "%host%" added'
659 # updated: 'Site credential for "%host%" updated' 681 # updated: 'Site credential for "%host%" updated'
660 # deleted: 'Site credential for "%host%" deleted' 682 # deleted: 'Site credential for "%host%" deleted'
683 ignore_origin_instance_rule:
684 notice:
685 # added: 'Global ignore origin rule added'
686 # updated: 'Global ignore origin rule updated'
687 # deleted: 'Global ignore origin rule deleted'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index 5d5878eb..2cfab8cf 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: "Retour aux articles non lus" 33 back_to_unread: "Retour aux articles non lus"
34 users_management: "Gestion des utilisateurs" 34 users_management: "Gestion des utilisateurs"
35 site_credentials: 'Accès aux sites' 35 site_credentials: 'Accès aux sites'
36 ignore_origin_instance_rules: "Règles globales d'omission d'origine"
36 quickstart: "Pour bien débuter" 37 quickstart: "Pour bien débuter"
37 top: 38 top:
38 add_new_entry: "Sauvegarder un nouvel article" 39 add_new_entry: "Sauvegarder un nouvel article"
@@ -59,6 +60,7 @@ config:
59 user_info: "Mon compte" 60 user_info: "Mon compte"
60 password: "Mot de passe" 61 password: "Mot de passe"
61 rules: "Règles de tag automatiques" 62 rules: "Règles de tag automatiques"
63 ignore_origin: "Règles d'omission d'origine"
62 new_user: "Créer un compte" 64 new_user: "Créer un compte"
63 reset: "Réinitialisation" 65 reset: "Réinitialisation"
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 and: "Une règle ET l’autre" 179 and: "Une règle ET l’autre"
178 matches: "Teste si un <i>sujet</i> correspond à une <i>recherche</i> (non sensible à la casse).<br />Exemple : <code>title matches \"football\"</code>" 180 matches: "Teste si un <i>sujet</i> correspond à une <i>recherche</i> (non sensible à la casse).<br />Exemple : <code>title matches \"football\"</code>"
179 notmatches: "Teste si un <i>sujet</i> ne correspond pas à une <i>recherche</i> (non sensible à la casse).<br />Exemple : <code>title notmatches \"football\"</code>" 181 notmatches: "Teste si un <i>sujet</i> ne correspond pas à une <i>recherche</i> (non sensible à la casse).<br />Exemple : <code>title notmatches \"football\"</code>"
182 form_ignore_origin_rules:
183 faq:
184 title: "FAQ"
185 ignore_origin_rules_definition_title: "Que signifient les règles d'omission d'origine ?"
186 ignore_origin_rules_definition_description: "Ce sont des règles utilisées par wallabag pour omettre automatiquement l'adresse d'origine après une redirection.<br />Si une redirection intervient pendant la récupération d'un nouvel article, toutes les règles d'omission (<i>règles utilisateur et instance</i>) seront utilisées afin d'ignorer ou non l'adresse d'origine."
187 how_to_use_them_title: "Comment les utiliser ?"
188 how_to_use_them_description: "Imaginons que vous vouliez omettre l'origine d'un article provenant de « <i>rss.example.com</i> » (<i>sachant qu'après la redirection, l'adresse réelle est example.com</i>).<br />Dans ce cas, vous devriez mettre « host = \"rss.example.com\" » dans le champ <i>Règle</i>."
189 variables_available_title: "Quelles variables et opérateurs puis-je utiliser pour écrire des règles ?"
190 variables_available_description: "Les variables et opérateurs suivants peuvent être utilisés pour écrire des règles d'omission d'origine :"
191 meaning: "Signification"
192 variable_description:
193 label: "Variable"
194 host: "Hôte"
195 _all: "Adresse complète, utile pour les expressions régulières"
196 operator_description:
197 label: "Opérateur"
198 equal_to: "Égal à…"
199 matches: "Teste si un <i>sujet</i> correspond à une <i>recherche</i> (non sensible à la casse).<br />Exemple : <code>_all ~ \"https?://rss.example.com/foobar/.*\"</code>"
180 otp: 200 otp:
181 page_title: Authentification double-facteur 201 page_title: Authentification double-facteur
182 app: 202 app:
@@ -618,6 +638,8 @@ flashes:
618 otp_disabled: "Authentification à double-facteur désactivée" 638 otp_disabled: "Authentification à double-facteur désactivée"
619 tagging_rules_imported: Règles bien importées 639 tagging_rules_imported: Règles bien importées
620 tagging_rules_not_imported: Impossible d'importer les règles 640 tagging_rules_not_imported: Impossible d'importer les règles
641 ignore_origin_rules_deleted: "Règle d'omission d'origine supprimée"
642 ignore_origin_rules_updated: "Règle d'omission d'origine mise à jour"
621 entry: 643 entry:
622 notice: 644 notice:
623 entry_already_saved: "Article déjà sauvegardé le %date%" 645 entry_already_saved: "Article déjà sauvegardé le %date%"
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
index 23e72f20..af1c1fe7 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: 'Torna ai contenuti non letti' 33 back_to_unread: 'Torna ai contenuti non letti'
34 users_management: 'Gestione utenti' 34 users_management: 'Gestione utenti'
35 site_credentials: 'Credenziali sito' 35 site_credentials: 'Credenziali sito'
36 # ignore_origin_instance_rules: 'Global ignore origin rules'
36 quickstart: "Introduzione" 37 quickstart: "Introduzione"
37 top: 38 top:
38 add_new_entry: 'Aggiungi un nuovo contenuto' 39 add_new_entry: 'Aggiungi un nuovo contenuto'
@@ -59,6 +60,7 @@ config:
59 user_info: 'Informazioni utente' 60 user_info: 'Informazioni utente'
60 password: 'Password' 61 password: 'Password'
61 rules: 'Regole di etichettatura' 62 rules: 'Regole di etichettatura'
63 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Aggiungi utente' 64 new_user: 'Aggiungi utente'
63 reset: 'Area di reset' 65 reset: 'Area di reset'
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 and: "Una regola E un'altra" 179 and: "Una regola E un'altra"
178 matches: 'Verifica che un <i>oggetto</i> risulti in una <i>ricerca</i> (case-insensitive).<br />Esempio: <code>titolo contiene "football"</code>' 180 matches: 'Verifica che un <i>oggetto</i> risulti in una <i>ricerca</i> (case-insensitive).<br />Esempio: <code>titolo contiene "football"</code>'
179 # notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>' 181 # notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
182 form_ignore_origin_rules:
183 # faq:
184 # title: 'FAQ'
185 # ignore_origin_rules_definition_title: 'What does « ignore origin rules » mean?'
186 # ignore_origin_rules_definition_description: 'They are used by wallabag to automatically ignore an origin address after a redirect.<br />If a redirect occurs while fetching a new entry, all the ignore origin rules (<i>user defined and instance defined</i>) will be used to ignore the origin address.'
187 # how_to_use_them_title: 'How do I use them?'
188 # how_to_use_them_description: 'Let us assume you want to ignore the origin of an entry coming from « <i>rss.example.com</i> » (<i>knowing that after a redirect, the actual address is example.com</i>).<br />In that case, you should put « host = "rss.example.com" » in the <i>Rule</i> field.'
189 # variables_available_title: 'Which variables and operators can I use to write rules?'
190 # variables_available_description: 'The following variables and operators can be used to create ignore origin rules:'
191 # meaning: 'Meaning'
192 # variable_description:
193 # label: 'Variable'
194 # host: 'Host of the address'
195 # _all: 'Full address, mainly for pattern matching'
196 # operator_description:
197 # label: 'Operator'
198 # equal_to: 'Equal to…'
199 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>_all ~ "https?://rss.example.com/foobar/.*"</code>'
180 otp: 200 otp:
181 # page_title: Two-factor authentication 201 # page_title: Two-factor authentication
182 # app: 202 # app:
@@ -617,6 +637,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 637 # otp_disabled: Two-factor authentication disabled
618 # tagging_rules_imported: Tagging rules imported 638 # tagging_rules_imported: Tagging rules imported
619 # tagging_rules_not_imported: Error while importing tagging rules 639 # tagging_rules_not_imported: Error while importing tagging rules
640 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
641 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 642 entry:
621 notice: 643 notice:
622 entry_already_saved: 'Contenuto già salvato in data %date%' 644 entry_already_saved: 'Contenuto già salvato in data %date%'
@@ -658,3 +680,8 @@ flashes:
658 # added: 'Site credential for "%host%" added' 680 # added: 'Site credential for "%host%" added'
659 # updated: 'Site credential for "%host%" updated' 681 # updated: 'Site credential for "%host%" updated'
660 # deleted: 'Site credential for "%host%" deleted' 682 # deleted: 'Site credential for "%host%" deleted'
683 ignore_origin_instance_rule:
684 notice:
685 # added: 'Global ignore origin rule added'
686 # updated: 'Global ignore origin rule updated'
687 # deleted: 'Global ignore origin rule deleted'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
index 6ddff6ea..59dd9b22 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: 'Tornar als articles pas legits' 33 back_to_unread: 'Tornar als articles pas legits'
34 users_management: 'Gestion dels utilizaires' 34 users_management: 'Gestion dels utilizaires'
35 site_credentials: 'Identificants del site' 35 site_credentials: 'Identificants del site'
36 # ignore_origin_instance_rules: 'Global ignore origin rules'
36 quickstart: "Per ben començar" 37 quickstart: "Per ben començar"
37 top: 38 top:
38 add_new_entry: 'Enregistrar un novèl article' 39 add_new_entry: 'Enregistrar un novèl article'
@@ -59,6 +60,7 @@ config:
59 user_info: 'Mon compte' 60 user_info: 'Mon compte'
60 password: 'Senhal' 61 password: 'Senhal'
61 rules: "Règlas d'etiquetas automaticas" 62 rules: "Règlas d'etiquetas automaticas"
63 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Crear un compte' 64 new_user: 'Crear un compte'
63 reset: 'Zòna de reïnicializacion' 65 reset: 'Zòna de reïnicializacion'
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 and: "Una règla E l'autra" 179 and: "Una règla E l'autra"
178 matches: 'Teste se un <i>subjècte</i> correspond a una <i>recèrca</i> (non sensibla a la cassa).<br />Exemple : <code>title matches \"football\"</code>' 180 matches: 'Teste se un <i>subjècte</i> correspond a una <i>recèrca</i> (non sensibla a la cassa).<br />Exemple : <code>title matches \"football\"</code>'
179 notmatches: 'Teste se <i>subjècte</i> correspond pas a una <i>recèrca</i> (sensibla a la cassa).<br />Example : <code>title notmatches "football"</code>' 181 notmatches: 'Teste se <i>subjècte</i> correspond pas a una <i>recèrca</i> (sensibla a la cassa).<br />Example : <code>title notmatches "football"</code>'
182 form_ignore_origin_rules:
183 # faq:
184 # title: 'FAQ'
185 # ignore_origin_rules_definition_title: 'What does « ignore origin rules » mean?'
186 # ignore_origin_rules_definition_description: 'They are used by wallabag to automatically ignore an origin address after a redirect.<br />If a redirect occurs while fetching a new entry, all the ignore origin rules (<i>user defined and instance defined</i>) will be used to ignore the origin address.'
187 # how_to_use_them_title: 'How do I use them?'
188 # how_to_use_them_description: 'Let us assume you want to ignore the origin of an entry coming from « <i>rss.example.com</i> » (<i>knowing that after a redirect, the actual address is example.com</i>).<br />In that case, you should put « host = "rss.example.com" » in the <i>Rule</i> field.'
189 # variables_available_title: 'Which variables and operators can I use to write rules?'
190 # variables_available_description: 'The following variables and operators can be used to create ignore origin rules:'
191 # meaning: 'Meaning'
192 # variable_description:
193 # label: 'Variable'
194 # host: 'Host of the address'
195 # _all: 'Full address, mainly for pattern matching'
196 # operator_description:
197 # label: 'Operator'
198 # equal_to: 'Equal to…'
199 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>_all ~ "https?://rss.example.com/foobar/.*"</code>'
180 otp: 200 otp:
181 page_title: Autentificacion en dos temps 201 page_title: Autentificacion en dos temps
182 app: 202 app:
@@ -617,6 +637,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 637 # otp_disabled: Two-factor authentication disabled
618 tagging_rules_imported: Règlas d’etiquetatge importadas 638 tagging_rules_imported: Règlas d’etiquetatge importadas
619 tagging_rules_not_imported: Error en important las règlas d’etiquetatge 639 tagging_rules_not_imported: Error en important las règlas d’etiquetatge
640 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
641 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 642 entry:
621 notice: 643 notice:
622 entry_already_saved: 'Article ja salvagardat lo %date%' 644 entry_already_saved: 'Article ja salvagardat lo %date%'
@@ -658,3 +680,8 @@ flashes:
658 added: 'Identificant per "%host%" ajustat' 680 added: 'Identificant per "%host%" ajustat'
659 updated: 'Identificant per "%host%" mes a jorn' 681 updated: 'Identificant per "%host%" mes a jorn'
660 deleted: 'Identificant per "%host%" suprimit' 682 deleted: 'Identificant per "%host%" suprimit'
683 ignore_origin_instance_rule:
684 notice:
685 # added: 'Global ignore origin rule added'
686 # updated: 'Global ignore origin rule updated'
687 # deleted: 'Global ignore origin rule deleted'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
index 770477c9..c09ef47a 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: 'Powrót do nieprzeczytanych artykułów' 33 back_to_unread: 'Powrót do nieprzeczytanych artykułów'
34 users_management: 'Zarządzanie użytkownikami' 34 users_management: 'Zarządzanie użytkownikami'
35 site_credentials: 'Poświadczenia strony' 35 site_credentials: 'Poświadczenia strony'
36 # ignore_origin_instance_rules: 'Global ignore origin rules'
36 quickstart: "Szybki start" 37 quickstart: "Szybki start"
37 top: 38 top:
38 add_new_entry: 'Dodaj nowy wpis' 39 add_new_entry: 'Dodaj nowy wpis'
@@ -59,6 +60,7 @@ config:
59 user_info: 'Informacje o użytkowniku' 60 user_info: 'Informacje o użytkowniku'
60 password: 'Hasło' 61 password: 'Hasło'
61 rules: 'Zasady tagowania' 62 rules: 'Zasady tagowania'
63 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Dodaj użytkownika' 64 new_user: 'Dodaj użytkownika'
63 reset: 'Reset' 65 reset: 'Reset'
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 and: 'Jedna reguła I inna' 179 and: 'Jedna reguła I inna'
178 matches: 'Sprawdź czy <i>temat</i> pasuje <i>szukaj</i> (duże lub małe litery).<br />Przykład: <code>tytuł zawiera "piłka nożna"</code>' 180 matches: 'Sprawdź czy <i>temat</i> pasuje <i>szukaj</i> (duże lub małe litery).<br />Przykład: <code>tytuł zawiera "piłka nożna"</code>'
179 notmatches: 'Sprawdź czy <i>temat</i> nie zawiera <i>szukaj</i> (duże lub małe litery).<br />Przykład: <code>tytuł nie zawiera "piłka nożna"</code>' 181 notmatches: 'Sprawdź czy <i>temat</i> nie zawiera <i>szukaj</i> (duże lub małe litery).<br />Przykład: <code>tytuł nie zawiera "piłka nożna"</code>'
182 form_ignore_origin_rules:
183 # faq:
184 # title: 'FAQ'
185 # ignore_origin_rules_definition_title: 'What does « ignore origin rules » mean?'
186 # ignore_origin_rules_definition_description: 'They are used by wallabag to automatically ignore an origin address after a redirect.<br />If a redirect occurs while fetching a new entry, all the ignore origin rules (<i>user defined and instance defined</i>) will be used to ignore the origin address.'
187 # how_to_use_them_title: 'How do I use them?'
188 # how_to_use_them_description: 'Let us assume you want to ignore the origin of an entry coming from « <i>rss.example.com</i> » (<i>knowing that after a redirect, the actual address is example.com</i>).<br />In that case, you should put « host = "rss.example.com" » in the <i>Rule</i> field.'
189 # variables_available_title: 'Which variables and operators can I use to write rules?'
190 # variables_available_description: 'The following variables and operators can be used to create ignore origin rules:'
191 # meaning: 'Meaning'
192 # variable_description:
193 # label: 'Variable'
194 # host: 'Host of the address'
195 # _all: 'Full address, mainly for pattern matching'
196 # operator_description:
197 # label: 'Operator'
198 # equal_to: 'Equal to…'
199 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>_all ~ "https?://rss.example.com/foobar/.*"</code>'
180 otp: 200 otp:
181 # page_title: Two-factor authentication 201 # page_title: Two-factor authentication
182 # app: 202 # app:
@@ -617,6 +637,8 @@ flashes:
617 # otp_disabled: Two-factor authentication disabled 637 # otp_disabled: Two-factor authentication disabled
618 # tagging_rules_imported: Tagging rules imported 638 # tagging_rules_imported: Tagging rules imported
619 # tagging_rules_not_imported: Error while importing tagging rules 639 # tagging_rules_not_imported: Error while importing tagging rules
640 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
641 # ignore_origin_rules_updated: 'Ignore origin rule updated'
620 entry: 642 entry:
621 notice: 643 notice:
622 entry_already_saved: 'Wpis już został dodany %date%' 644 entry_already_saved: 'Wpis już został dodany %date%'
@@ -658,3 +680,8 @@ flashes:
658 added: 'Poświadczenie dla "%host%" dodane' 680 added: 'Poświadczenie dla "%host%" dodane'
659 updated: 'Poświadczenie dla "%host%" zaktualizowane' 681 updated: 'Poświadczenie dla "%host%" zaktualizowane'
660 deleted: 'Poświadczenie dla "%host%" usuniętę' 682 deleted: 'Poświadczenie dla "%host%" usuniętę'
683 ignore_origin_instance_rule:
684 notice:
685 # added: 'Global ignore origin rule added'
686 # updated: 'Global ignore origin rule updated'
687 # deleted: 'Global ignore origin rule deleted'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
index d993cb05..293a4e44 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: 'Voltar para os artigos não lidos' 33 back_to_unread: 'Voltar para os artigos não lidos'
34 users_management: 'Gestão de Usuários' 34 users_management: 'Gestão de Usuários'
35 site_credentials: 'Credenciais do site' 35 site_credentials: 'Credenciais do site'
36 # ignore_origin_instance_rules: 'Global ignore origin rules'
36 quickstart: "Começo Rápido" 37 quickstart: "Começo Rápido"
37 top: 38 top:
38 add_new_entry: 'Adicionar um novo artigo' 39 add_new_entry: 'Adicionar um novo artigo'
@@ -59,6 +60,7 @@ config:
59 user_info: 'Informação do Usuário' 60 user_info: 'Informação do Usuário'
60 password: 'Senha' 61 password: 'Senha'
61 rules: 'Regras de tags' 62 rules: 'Regras de tags'
63 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Adicionar um usuário' 64 new_user: 'Adicionar um usuário'
63 reset: 'Reiniciar minha conta' 65 reset: 'Reiniciar minha conta'
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 and: 'Uma regra E outra' 179 and: 'Uma regra E outra'
178 matches: 'Testa que um <i>assunto</i> corresponde a uma <i>pesquisa</i> (maiúscula ou minúscula).<br />Exemplo: <code>title matches "futebol"</code>' 180 matches: 'Testa que um <i>assunto</i> corresponde a uma <i>pesquisa</i> (maiúscula ou minúscula).<br />Exemplo: <code>title matches "futebol"</code>'
179 notmatches: 'Testa que um <i>assunto</i> não corresponde a uma <i>search</i> (maiúscula ou minúscula).<br />Exemplo: <code>title notmatches "futebol"</code>' 181 notmatches: 'Testa que um <i>assunto</i> não corresponde a uma <i>search</i> (maiúscula ou minúscula).<br />Exemplo: <code>title notmatches "futebol"</code>'
182 form_ignore_origin_rules:
183 # faq:
184 # title: 'FAQ'
185 # ignore_origin_rules_definition_title: 'What does « ignore origin rules » mean?'
186 # ignore_origin_rules_definition_description: 'They are used by wallabag to automatically ignore an origin address after a redirect.<br />If a redirect occurs while fetching a new entry, all the ignore origin rules (<i>user defined and instance defined</i>) will be used to ignore the origin address.'
187 # how_to_use_them_title: 'How do I use them?'
188 # how_to_use_them_description: 'Let us assume you want to ignore the origin of an entry coming from « <i>rss.example.com</i> » (<i>knowing that after a redirect, the actual address is example.com</i>).<br />In that case, you should put « host = "rss.example.com" » in the <i>Rule</i> field.'
189 # variables_available_title: 'Which variables and operators can I use to write rules?'
190 # variables_available_description: 'The following variables and operators can be used to create ignore origin rules:'
191 # meaning: 'Meaning'
192 # variable_description:
193 # label: 'Variable'
194 # host: 'Host of the address'
195 # _all: 'Full address, mainly for pattern matching'
196 # operator_description:
197 # label: 'Operator'
198 # equal_to: 'Equal to…'
199 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>_all ~ "https?://rss.example.com/foobar/.*"</code>'
180 otp: 200 otp:
181 page_title: Autenticação de dois fatores 201 page_title: Autenticação de dois fatores
182 app: 202 app:
@@ -657,3 +677,8 @@ flashes:
657 added: 'Credencial do site para "%host%" foi adicionada' 677 added: 'Credencial do site para "%host%" foi adicionada'
658 updated: 'Credencial do site pa "%host%" atualizada' 678 updated: 'Credencial do site pa "%host%" atualizada'
659 deleted: 'Credencial do site pa "%host%" removida' 679 deleted: 'Credencial do site pa "%host%" removida'
680 ignore_origin_instance_rule:
681 notice:
682 # added: 'Global ignore origin rule added'
683 # updated: 'Global ignore origin rule updated'
684 # deleted: 'Global ignore origin rule deleted'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
index bc8b72e0..3c605709 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: 'Înapoi la articolele necitite' 33 back_to_unread: 'Înapoi la articolele necitite'
34 # users_management: 'Users management' 34 # users_management: 'Users management'
35 # site_credentials: 'Site credentials' 35 # site_credentials: 'Site credentials'
36 # ignore_origin_instance_rules: 'Global ignore origin rules'
36 # quickstart: "Quickstart" 37 # quickstart: "Quickstart"
37 top: 38 top:
38 add_new_entry: 'Introdu un nou articol' 39 add_new_entry: 'Introdu un nou articol'
@@ -59,6 +60,7 @@ config:
59 user_info: 'Informații despre utilizator' 60 user_info: 'Informații despre utilizator'
60 password: 'Parolă' 61 password: 'Parolă'
61 # rules: 'Tagging rules' 62 # rules: 'Tagging rules'
63 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Crează un utilizator' 64 new_user: 'Crează un utilizator'
63 # reset: 'Reset area' 65 # reset: 'Reset area'
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 # and: 'One rule AND another' 179 # and: 'One rule AND another'
178 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>' 180 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>'
179 # notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>' 181 # notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
182 form_ignore_origin_rules:
183 # faq:
184 # title: 'FAQ'
185 # ignore_origin_rules_definition_title: 'What does « ignore origin rules » mean?'
186 # ignore_origin_rules_definition_description: 'They are used by wallabag to automatically ignore an origin address after a redirect.<br />If a redirect occurs while fetching a new entry, all the ignore origin rules (<i>user defined and instance defined</i>) will be used to ignore the origin address.'
187 # how_to_use_them_title: 'How do I use them?'
188 # how_to_use_them_description: 'Let us assume you want to ignore the origin of an entry coming from « <i>rss.example.com</i> » (<i>knowing that after a redirect, the actual address is example.com</i>).<br />In that case, you should put « host = "rss.example.com" » in the <i>Rule</i> field.'
189 # variables_available_title: 'Which variables and operators can I use to write rules?'
190 # variables_available_description: 'The following variables and operators can be used to create ignore origin rules:'
191 # meaning: 'Meaning'
192 # variable_description:
193 # label: 'Variable'
194 # host: 'Host of the address'
195 # _all: 'Full address, mainly for pattern matching'
196 # operator_description:
197 # label: 'Operator'
198 # equal_to: 'Equal to…'
199 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>_all ~ "https?://rss.example.com/foobar/.*"</code>'
180 otp: 200 otp:
181 # page_title: Two-factor authentication 201 # page_title: Two-factor authentication
182 # app: 202 # app:
@@ -616,6 +636,8 @@ flashes:
616 # otp_disabled: Two-factor authentication disabled 636 # otp_disabled: Two-factor authentication disabled
617 # tagging_rules_imported: Tagging rules imported 637 # tagging_rules_imported: Tagging rules imported
618 # tagging_rules_not_imported: Error while importing tagging rules 638 # tagging_rules_not_imported: Error while importing tagging rules
639 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
640 # ignore_origin_rules_updated: 'Ignore origin rule updated'
619 entry: 641 entry:
620 notice: 642 notice:
621 # entry_already_saved: 'Entry already saved on %date%' 643 # entry_already_saved: 'Entry already saved on %date%'
@@ -657,3 +679,8 @@ flashes:
657 # added: 'Site credential for "%host%" added' 679 # added: 'Site credential for "%host%" added'
658 # updated: 'Site credential for "%host%" updated' 680 # updated: 'Site credential for "%host%" updated'
659 # deleted: 'Site credential for "%host%" deleted' 681 # deleted: 'Site credential for "%host%" deleted'
682 ignore_origin_instance_rule:
683 notice:
684 # added: 'Global ignore origin rule added'
685 # updated: 'Global ignore origin rule updated'
686 # deleted: 'Global ignore origin rule deleted'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
index 2f7f55e5..eead4ec6 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: 'Назад к непрочитанным записям' 33 back_to_unread: 'Назад к непрочитанным записям'
34 users_management: 'Управление пользователями' 34 users_management: 'Управление пользователями'
35 site_credentials: 'Site credentials' 35 site_credentials: 'Site credentials'
36 # ignore_origin_instance_rules: 'Global ignore origin rules'
36 quickstart: "Быстрый старт" 37 quickstart: "Быстрый старт"
37 top: 38 top:
38 add_new_entry: 'Добавить новую запись' 39 add_new_entry: 'Добавить новую запись'
@@ -59,6 +60,7 @@ config:
59 user_info: 'Информация о пользователе' 60 user_info: 'Информация о пользователе'
60 password: 'Пароль' 61 password: 'Пароль'
61 rules: 'Правила настройки простановки тегов' 62 rules: 'Правила настройки простановки тегов'
63 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Добавить пользователя' 64 new_user: 'Добавить пользователя'
63 reset: 'Сброс данных' 65 reset: 'Сброс данных'
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 and: 'Одно правило И другое' 179 and: 'Одно правило И другое'
178 matches: 'Тесты, в которых <i> тема </i> соответствует <i> поиску </i> (без учета регистра). Пример: <code> title matches "футбол" </code>' 180 matches: 'Тесты, в которых <i> тема </i> соответствует <i> поиску </i> (без учета регистра). Пример: <code> title matches "футбол" </code>'
179 # notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>' 181 # notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
182 form_ignore_origin_rules:
183 # faq:
184 # title: 'FAQ'
185 # ignore_origin_rules_definition_title: 'What does « ignore origin rules » mean?'
186 # ignore_origin_rules_definition_description: 'They are used by wallabag to automatically ignore an origin address after a redirect.<br />If a redirect occurs while fetching a new entry, all the ignore origin rules (<i>user defined and instance defined</i>) will be used to ignore the origin address.'
187 # how_to_use_them_title: 'How do I use them?'
188 # how_to_use_them_description: 'Let us assume you want to ignore the origin of an entry coming from « <i>rss.example.com</i> » (<i>knowing that after a redirect, the actual address is example.com</i>).<br />In that case, you should put « host = "rss.example.com" » in the <i>Rule</i> field.'
189 # variables_available_title: 'Which variables and operators can I use to write rules?'
190 # variables_available_description: 'The following variables and operators can be used to create ignore origin rules:'
191 # meaning: 'Meaning'
192 # variable_description:
193 # label: 'Variable'
194 # host: 'Host of the address'
195 # _all: 'Full address, mainly for pattern matching'
196 # operator_description:
197 # label: 'Operator'
198 # equal_to: 'Equal to…'
199 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>_all ~ "https?://rss.example.com/foobar/.*"</code>'
180 otp: 200 otp:
181 # page_title: Two-factor authentication 201 # page_title: Two-factor authentication
182 # app: 202 # app:
@@ -616,6 +636,8 @@ flashes:
616 # otp_disabled: Two-factor authentication disabled 636 # otp_disabled: Two-factor authentication disabled
617 # tagging_rules_imported: Tagging rules imported 637 # tagging_rules_imported: Tagging rules imported
618 # tagging_rules_not_imported: Error while importing tagging rules 638 # tagging_rules_not_imported: Error while importing tagging rules
639 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
640 # ignore_origin_rules_updated: 'Ignore origin rule updated'
619 entry: 641 entry:
620 notice: 642 notice:
621 entry_already_saved: 'Запись была сохранена ранее %date%' 643 entry_already_saved: 'Запись была сохранена ранее %date%'
@@ -657,3 +679,8 @@ flashes:
657 # added: 'Site credential for "%host%" added' 679 # added: 'Site credential for "%host%" added'
658 # updated: 'Site credential for "%host%" updated' 680 # updated: 'Site credential for "%host%" updated'
659 # deleted: 'Site credential for "%host%" deleted' 681 # deleted: 'Site credential for "%host%" deleted'
682 ignore_origin_instance_rule:
683 notice:
684 # added: 'Global ignore origin rule added'
685 # updated: 'Global ignore origin rule updated'
686 # deleted: 'Global ignore origin rule deleted'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
index 48e1c34a..8d2b05f3 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: 'กลับไปยังรายการที่ไม่ได้อ่าน' 33 back_to_unread: 'กลับไปยังรายการที่ไม่ได้อ่าน'
34 users_management: 'การจัดการผู้ใช้' 34 users_management: 'การจัดการผู้ใช้'
35 site_credentials: 'การรับรองไซต์' 35 site_credentials: 'การรับรองไซต์'
36 # ignore_origin_instance_rules: 'Global ignore origin rules'
36 quickstart: "เริ่มแบบด่วน" 37 quickstart: "เริ่มแบบด่วน"
37 top: 38 top:
38 add_new_entry: 'เพิ่มรายการใหม่' 39 add_new_entry: 'เพิ่มรายการใหม่'
@@ -59,6 +60,7 @@ config:
59 user_info: 'ข้อมูลผู้ใช้' 60 user_info: 'ข้อมูลผู้ใช้'
60 password: 'รหัสผ่าน' 61 password: 'รหัสผ่าน'
61 rules: 'การแท็กข้อบังคับ' 62 rules: 'การแท็กข้อบังคับ'
63 # ignore_origin: 'Ignore origin rules'
62 new_user: 'เพิ่มผู้ใช้' 64 new_user: 'เพิ่มผู้ใช้'
63 reset: 'รีเซ็ตพื้นที่ ' 65 reset: 'รีเซ็ตพื้นที่ '
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 and: 'หนึ่งข้อบังคับและอื่นๆ' 179 and: 'หนึ่งข้อบังคับและอื่นๆ'
178 matches: 'ทดสอบว่า <i>เรื่อง</i> นี้ตรงกับ <i>การต้นหา</i> (กรณีไม่ทราบ).<br />ตัวอย่าง: <code>หัวข้อที่ตรงกับ "football"</code>' 180 matches: 'ทดสอบว่า <i>เรื่อง</i> นี้ตรงกับ <i>การต้นหา</i> (กรณีไม่ทราบ).<br />ตัวอย่าง: <code>หัวข้อที่ตรงกับ "football"</code>'
179 notmatches: 'ทดสอบว่า <i>เรื่อง</i> นี้ไม่ตรงกับ <i>การต้นหา</i> (กรณีไม่ทราบ).<br />ตัวอย่าง: <code>หัวข้อทีไม่ตรงกับ "football"</code>' 181 notmatches: 'ทดสอบว่า <i>เรื่อง</i> นี้ไม่ตรงกับ <i>การต้นหา</i> (กรณีไม่ทราบ).<br />ตัวอย่าง: <code>หัวข้อทีไม่ตรงกับ "football"</code>'
182 form_ignore_origin_rules:
183 # faq:
184 # title: 'FAQ'
185 # ignore_origin_rules_definition_title: 'What does « ignore origin rules » mean?'
186 # ignore_origin_rules_definition_description: 'They are used by wallabag to automatically ignore an origin address after a redirect.<br />If a redirect occurs while fetching a new entry, all the ignore origin rules (<i>user defined and instance defined</i>) will be used to ignore the origin address.'
187 # how_to_use_them_title: 'How do I use them?'
188 # how_to_use_them_description: 'Let us assume you want to ignore the origin of an entry coming from « <i>rss.example.com</i> » (<i>knowing that after a redirect, the actual address is example.com</i>).<br />In that case, you should put « host = "rss.example.com" » in the <i>Rule</i> field.'
189 # variables_available_title: 'Which variables and operators can I use to write rules?'
190 # variables_available_description: 'The following variables and operators can be used to create ignore origin rules:'
191 # meaning: 'Meaning'
192 # variable_description:
193 # label: 'Variable'
194 # host: 'Host of the address'
195 # _all: 'Full address, mainly for pattern matching'
196 # operator_description:
197 # label: 'Operator'
198 # equal_to: 'Equal to…'
199 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>_all ~ "https?://rss.example.com/foobar/.*"</code>'
180 otp: 200 otp:
181 # page_title: Two-factor authentication 201 # page_title: Two-factor authentication
182 # app: 202 # app:
@@ -616,6 +636,8 @@ flashes:
616 # otp_disabled: Two-factor authentication disabled 636 # otp_disabled: Two-factor authentication disabled
617 # tagging_rules_imported: Tagging rules imported 637 # tagging_rules_imported: Tagging rules imported
618 # tagging_rules_not_imported: Error while importing tagging rules 638 # tagging_rules_not_imported: Error while importing tagging rules
639 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
640 # ignore_origin_rules_updated: 'Ignore origin rule updated'
619 entry: 641 entry:
620 notice: 642 notice:
621 entry_already_saved: 'รายการพร้อมบันทึกที่ %date%' 643 entry_already_saved: 'รายการพร้อมบันทึกที่ %date%'
@@ -657,3 +679,8 @@ flashes:
657 added: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการเพิ่ม' 679 added: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการเพิ่ม'
658 updated: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการอัปเดต' 680 updated: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการอัปเดต'
659 deleted: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการลบ' 681 deleted: 'ไซต์ข้อมูลประจำตัวสำหรับ "%host%" ที่ทำการลบ'
682 ignore_origin_instance_rule:
683 notice:
684 # added: 'Global ignore origin rule added'
685 # updated: 'Global ignore origin rule updated'
686 # deleted: 'Global ignore origin rule deleted'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
index 19029c0b..dfbc3010 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
@@ -33,6 +33,7 @@ menu:
33 back_to_unread: 'Okunmayan makalelere geri dön' 33 back_to_unread: 'Okunmayan makalelere geri dön'
34 # users_management: 'Users management' 34 # users_management: 'Users management'
35 # site_credentials: 'Site credentials' 35 # site_credentials: 'Site credentials'
36 # ignore_origin_instance_rules: 'Global ignore origin rules'
36 quickstart: "Hızlı başlangıç" 37 quickstart: "Hızlı başlangıç"
37 top: 38 top:
38 add_new_entry: 'Yeni bir makale ekle' 39 add_new_entry: 'Yeni bir makale ekle'
@@ -59,6 +60,7 @@ config:
59 user_info: 'Kullanıcı bilgileri' 60 user_info: 'Kullanıcı bilgileri'
60 password: 'Şifre' 61 password: 'Şifre'
61 rules: 'Etiketleme kuralları' 62 rules: 'Etiketleme kuralları'
63 # ignore_origin: 'Ignore origin rules'
62 new_user: 'Bir kullanıcı ekle' 64 new_user: 'Bir kullanıcı ekle'
63 # reset: 'Reset area' 65 # reset: 'Reset area'
64 form: 66 form:
@@ -177,6 +179,24 @@ config:
177 and: 'Bir kural ve diğeri' 179 and: 'Bir kural ve diğeri'
178 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>' 180 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>title matches "football"</code>'
179 # notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>' 181 # notmatches: 'Tests that a <i>subject</i> doesn''t match match a <i>search</i> (case-insensitive).<br />Example: <code>title notmatches "football"</code>'
182 form_ignore_origin_rules:
183 # faq:
184 # title: 'FAQ'
185 # ignore_origin_rules_definition_title: 'What does « ignore origin rules » mean?'
186 # ignore_origin_rules_definition_description: 'They are used by wallabag to automatically ignore an origin address after a redirect.<br />If a redirect occurs while fetching a new entry, all the ignore origin rules (<i>user defined and instance defined</i>) will be used to ignore the origin address.'
187 # how_to_use_them_title: 'How do I use them?'
188 # how_to_use_them_description: 'Let us assume you want to ignore the origin of an entry coming from « <i>rss.example.com</i> » (<i>knowing that after a redirect, the actual address is example.com</i>).<br />In that case, you should put « host = "rss.example.com" » in the <i>Rule</i> field.'
189 # variables_available_title: 'Which variables and operators can I use to write rules?'
190 # variables_available_description: 'The following variables and operators can be used to create ignore origin rules:'
191 # meaning: 'Meaning'
192 # variable_description:
193 # label: 'Variable'
194 # host: 'Host of the address'
195 # _all: 'Full address, mainly for pattern matching'
196 # operator_description:
197 # label: 'Operator'
198 # equal_to: 'Equal to…'
199 # matches: 'Tests that a <i>subject</i> matches a <i>search</i> (case-insensitive).<br />Example: <code>_all ~ "https?://rss.example.com/foobar/.*"</code>'
180 otp: 200 otp:
181 # page_title: Two-factor authentication 201 # page_title: Two-factor authentication
182 # app: 202 # app:
@@ -616,6 +636,8 @@ flashes:
616 # otp_disabled: Two-factor authentication disabled 636 # otp_disabled: Two-factor authentication disabled
617 # tagging_rules_imported: Tagging rules imported 637 # tagging_rules_imported: Tagging rules imported
618 # tagging_rules_not_imported: Error while importing tagging rules 638 # tagging_rules_not_imported: Error while importing tagging rules
639 # ignore_origin_rules_deleted: 'Ignore origin rule deleted'
640 # ignore_origin_rules_updated: 'Ignore origin rule updated'
619 entry: 641 entry:
620 notice: 642 notice:
621 entry_already_saved: 'Entry already saved on %date%' 643 entry_already_saved: 'Entry already saved on %date%'
@@ -657,3 +679,8 @@ flashes:
657 # added: 'Site credential for "%host%" added' 679 # added: 'Site credential for "%host%" added'
658 # updated: 'Site credential for "%host%" updated' 680 # updated: 'Site credential for "%host%" updated'
659 # deleted: 'Site credential for "%host%" deleted' 681 # deleted: 'Site credential for "%host%" deleted'
682 ignore_origin_instance_rule:
683 notice:
684 # added: 'Global ignore origin rule added'
685 # updated: 'Global ignore origin rule updated'
686 # deleted: 'Global ignore origin rule deleted'
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 eb395eac..b6edce39 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
@@ -404,6 +404,76 @@
404 </div> 404 </div>
405 </div> 405 </div>
406 406
407 <h2>{{ 'config.tab_menu.ignore_origin'|trans }}</h2>
408
409 <ul>
410 {% for ignore_origin_rule in app.user.config.ignoreOriginRules %}
411 <li>
412 {{ 'config.form_rules.if_label'|trans }}
413 « {{ ignore_origin_rule.rule }} »
414 <a href="{{ path('edit_ignore_origin_rule', {id: ignore_origin_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}" class="tool mode_edit">✎</a>
415 <a href="{{ path('delete_ignore_origin_rule', {id: ignore_origin_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}" class="tool delete icon-trash icon"></a>
416 </li>
417 {% endfor %}
418 </ul>
419
420 {{ form_start(form.new_ignore_origin_user_rule) }}
421 {{ form_errors(form.new_ignore_origin_user_rule) }}
422
423 <fieldset class="w500p inline">
424 <div class="row">
425 {{ form_label(form.new_ignore_origin_user_rule.rule) }}
426 {{ form_errors(form.new_ignore_origin_user_rule.rule) }}
427 {{ form_widget(form.new_ignore_origin_user_rule.rule) }}
428 </div>
429 </fieldset>
430
431 {{ form_rest(form.new_ignore_origin_user_rule) }}
432 </form>
433
434 <div class="row">
435 <div class="input-field col s12">
436 <h4>{{ 'config.form_ignore_origin_rules.faq.title'|trans }}</h4>
437
438 <h5>{{ 'config.form_ignore_origin_rules.faq.ignore_origin_rules_definition_title'|trans }}</h5>
439 <p class="help">{{ 'config.form_ignore_origin_rules.faq.ignore_origin_rules_definition_description'|trans|raw }}</p>
440
441 <h5>{{ 'config.form_ignore_origin_rules.faq.how_to_use_them_title'|trans }}</h5>
442 <p class="help">{{ 'config.form_ignore_origin_rules.faq.how_to_use_them_description'|trans|raw }}</p>
443
444 <h5>{{ 'config.form_ignore_origin_rules.faq.variables_available_title'|trans }}</h5>
445 <p class="help">
446 {{ 'config.form_ignore_origin_rules.faq.variables_available_description'|trans }}
447 </p>
448
449 <table class="bordered">
450 <thead>
451 <tr>
452 <th>{{ 'config.form_ignore_origin_rules.faq.variable_description.label'|trans }}</th>
453 <th>{{ 'config.form_ignore_origin_rules.faq.meaning'|trans }}</th>
454 <th>{{ 'config.form_ignore_origin_rules.faq.operator_description.label'|trans }}</th>
455 <th>{{ 'config.form_ignore_origin_rules.faq.meaning'|trans }}</th>
456 </tr>
457 </thead>
458
459 <tbody>
460 <tr>
461 <td>host</td>
462 <td>{{ 'config.form_ignore_origin_rules.faq.variable_description.host'|trans }}</td>
463 <td>=</td>
464 <td>{{ 'config.form_ignore_origin_rules.faq.operator_description.equal_to'|trans }}</td>
465 </tr>
466 <tr>
467 <td>_all</td>
468 <td>{{ 'config.form_ignore_origin_rules.faq.variable_description._all'|trans }}</td>
469 <td>~</td>
470 <td>{{ 'config.form_ignore_origin_rules.faq.operator_description.matches'|trans|raw }}</td>
471 </tr>
472 </tbody>
473 </table>
474 </div>
475 </div>
476
407 <h2>{{ 'config.reset.title'|trans }}</h2> 477 <h2>{{ 'config.reset.title'|trans }}</h2>
408 <fieldset class="w500p inline"> 478 <fieldset class="w500p inline">
409 <p>{{ 'config.reset.description'|trans }}</p> 479 <p>{{ 'config.reset.description'|trans }}</p>
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
index 00000000..30c2a520
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/edit.html.twig
@@ -0,0 +1,87 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
4
5{% block content %}
6
7 <div class="row">
8 <div class="col s12">
9 <div class="card-panel">
10 <div class="row">
11 <div class="input-field col s12">
12 <h4>{{ 'ignore_origin_instance_rule.edit_ignore_origin_instance_rule'|trans }}</h4>
13
14 <div id="set6" class="col s12">
15 {{ form_start(edit_form) }}
16 {{ form_errors(edit_form) }}
17
18 <div class="row">
19 <div class="input-field col s12">
20 {{ form_label(edit_form.rule) }}
21 {{ form_errors(edit_form.rule) }}
22 {{ form_widget(edit_form.rule) }}
23 </div>
24 </div>
25
26 <br/>
27
28 {{ form_widget(edit_form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
29 {{ form_widget(edit_form._token) }}
30 </form>
31 <p>
32 {{ form_start(delete_form) }}
33 <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>
34 {{ form_end(delete_form) }}
35 </p>
36 <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>
37 </div>
38 </div>
39 </div>
40
41 <div class="row">
42 <div class="input-field col s12">
43 <h4>{{ 'config.form_ignore_origin_rules.faq.title'|trans }}</h4>
44
45 <h5>{{ 'config.form_ignore_origin_rules.faq.ignore_origin_rules_definition_title'|trans }}</h5>
46 <p class="help">{{ 'config.form_ignore_origin_rules.faq.ignore_origin_rules_definition_description'|trans|raw }}</p>
47
48 <h5>{{ 'config.form_ignore_origin_rules.faq.how_to_use_them_title'|trans }}</h5>
49 <p class="help">{{ 'config.form_ignore_origin_rules.faq.how_to_use_them_description'|trans|raw }}</p>
50
51 <h5>{{ 'config.form_ignore_origin_rules.faq.variables_available_title'|trans }}</h5>
52 <p class="help">
53 {{ 'config.form_ignore_origin_rules.faq.variables_available_description'|trans }}
54 </p>
55
56 <table class="bordered">
57 <thead>
58 <tr>
59 <th>{{ 'config.form_ignore_origin_rules.faq.variable_description.label'|trans }}</th>
60 <th>{{ 'config.form_ignore_origin_rules.faq.meaning'|trans }}</th>
61 <th>{{ 'config.form_ignore_origin_rules.faq.operator_description.label'|trans }}</th>
62 <th>{{ 'config.form_ignore_origin_rules.faq.meaning'|trans }}</th>
63 </tr>
64 </thead>
65
66 <tbody>
67 <tr>
68 <td>host</td>
69 <td>{{ 'config.form_ignore_origin_rules.faq.variable_description.host'|trans }}</td>
70 <td>=</td>
71 <td>{{ 'config.form_ignore_origin_rules.faq.operator_description.equal_to'|trans }}</td>
72 </tr>
73 <tr>
74 <td>_all</td>
75 <td>{{ 'config.form_ignore_origin_rules.faq.variable_description._all'|trans }}</td>
76 <td>~</td>
77 <td>{{ 'config.form_ignore_origin_rules.faq.operator_description.matches'|trans|raw }}</td>
78 </tr>
79 </tbody>
80 </table>
81 </div>
82 </div>
83 </div>
84 </div>
85 </div>
86
87{% 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
index 00000000..2de7cf0a
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/index.html.twig
@@ -0,0 +1,42 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
4
5{% block content %}
6
7 <div class="row">
8 <div class="col s12">
9 <div class="card-panel">
10 <div class="row">
11 <div class="input-field col s12">
12 <p class="help">{{ 'ignore_origin_instance_rule.description'|trans|raw }}</p>
13
14 <table class="bordered">
15 <thead>
16 <tr>
17 <th>{{ 'ignore_origin_instance_rule.form.rule_label'|trans }}</th>
18 <th>{{ 'ignore_origin_instance_rule.list.actions'|trans }}</th>
19 </tr>
20 </thead>
21 <tbody>
22 {% for rule in rules %}
23 <tr>
24 <td>{{ rule.rule }}</td>
25 <td>
26 <a href="{{ path('ignore_origin_instance_rules_edit', { 'id': rule.id }) }}">{{ 'ignore_origin_instance_rule.list.edit_action'|trans }}</a>
27 </td>
28 </tr>
29 {% endfor %}
30 </tbody>
31 </table>
32 <br />
33 <p>
34 <a href="{{ path('ignore_origin_instance_rules_new') }}" class="waves-effect waves-light btn">{{ 'ignore_origin_instance_rule.list.create_new_one'|trans }}</a>
35 </p>
36 </div>
37 </div>
38 </div>
39 </div>
40 </div>
41
42{% 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
index 00000000..cb052ff0
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/IgnoreOriginInstanceRule/new.html.twig
@@ -0,0 +1,80 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
4
5{% block content %}
6
7 <div class="row">
8 <div class="col s12">
9 <div class="card-panel">
10 <div class="row">
11 <div class="input-field col s12">
12 <h4>{{ 'ignore_origin_instance_rule.new_ignore_origin_instance_rule'|trans }}</h4>
13
14 <div id="set6" class="col s12">
15 {{ form_start(form) }}
16 {{ form_errors(form) }}
17
18 <div class="row">
19 <div class="input-field col s12">
20 {{ form_label(form.rule) }}
21 {{ form_errors(form.rule) }}
22 {{ form_widget(form.rule) }}
23 </div>
24 </div>
25
26 {{ form_widget(form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
27 {{ form_rest(form) }}
28 </form>
29 <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>
30 </div>
31 </div>
32 </div>
33
34 <div class="row">
35 <div class="input-field col s12">
36 <h4>{{ 'config.form_ignore_origin_rules.faq.title'|trans }}</h4>
37
38 <h5>{{ 'config.form_ignore_origin_rules.faq.ignore_origin_rules_definition_title'|trans }}</h5>
39 <p class="help">{{ 'config.form_ignore_origin_rules.faq.ignore_origin_rules_definition_description'|trans|raw }}</p>
40
41 <h5>{{ 'config.form_ignore_origin_rules.faq.how_to_use_them_title'|trans }}</h5>
42 <p class="help">{{ 'config.form_ignore_origin_rules.faq.how_to_use_them_description'|trans|raw }}</p>
43
44 <h5>{{ 'config.form_ignore_origin_rules.faq.variables_available_title'|trans }}</h5>
45 <p class="help">
46 {{ 'config.form_ignore_origin_rules.faq.variables_available_description'|trans }}
47 </p>
48
49 <table class="bordered">
50 <thead>
51 <tr>
52 <th>{{ 'config.form_ignore_origin_rules.faq.variable_description.label'|trans }}</th>
53 <th>{{ 'config.form_ignore_origin_rules.faq.meaning'|trans }}</th>
54 <th>{{ 'config.form_ignore_origin_rules.faq.operator_description.label'|trans }}</th>
55 <th>{{ 'config.form_ignore_origin_rules.faq.meaning'|trans }}</th>
56 </tr>
57 </thead>
58
59 <tbody>
60 <tr>
61 <td>host</td>
62 <td>{{ 'config.form_ignore_origin_rules.faq.variable_description.host'|trans }}</td>
63 <td>=</td>
64 <td>{{ 'config.form_ignore_origin_rules.faq.operator_description.equal_to'|trans }}</td>
65 </tr>
66 <tr>
67 <td>_all</td>
68 <td>{{ 'config.form_ignore_origin_rules.faq.variable_description._all'|trans }}</td>
69 <td>~</td>
70 <td>{{ 'config.form_ignore_origin_rules.faq.operator_description.matches'|trans|raw }}</td>
71 </tr>
72 </tbody>
73 </table>
74 </div>
75 </div>
76 </div>
77 </div>
78 </div>
79
80{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig
index 6b1e2bd7..e1446ff7 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig
@@ -45,6 +45,7 @@
45 {% if is_granted('ROLE_SUPER_ADMIN') %} 45 {% if is_granted('ROLE_SUPER_ADMIN') %}
46 <li class="menu users"><a href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a></li> 46 <li class="menu users"><a href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a></li>
47 <li class="menu internal"><a href="{{ path('craue_config_settings_modify') }}">{{ 'menu.left.internal_settings'|trans }}</a></li> 47 <li class="menu internal"><a href="{{ path('craue_config_settings_modify') }}">{{ 'menu.left.internal_settings'|trans }}</a></li>
48 <li class="menu ignore"><a href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'menu.left.ignore_origin_instance_rules'|trans }}</a></li>
48 {% endif %} 49 {% endif %}
49 <li class="menu import"><a href="{{ path('import') }}">{{ 'menu.left.import'|trans }}</a></li> 50 <li class="menu import"><a href="{{ path('import') }}">{{ 'menu.left.import'|trans }}</a></li>
50 <li class="menu howto"><a href="{{ path('howto') }}">{{ 'menu.left.howto'|trans }}</a></li> 51 <li class="menu howto"><a href="{{ path('howto') }}">{{ 'menu.left.howto'|trans }}</a></li>
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 c2e92ad1..22b38a1b 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
@@ -16,7 +16,8 @@
16 <li class="tab col s12 m6 l3"><a href="#set3">{{ 'config.tab_menu.user_info'|trans }}</a></li> 16 <li class="tab col s12 m6 l3"><a href="#set3">{{ 'config.tab_menu.user_info'|trans }}</a></li>
17 <li class="tab col s12 m6 l3"><a href="#set4">{{ 'config.tab_menu.password'|trans }}</a></li> 17 <li class="tab col s12 m6 l3"><a href="#set4">{{ 'config.tab_menu.password'|trans }}</a></li>
18 <li class="tab col s12 m6 l3"><a href="#set5">{{ 'config.tab_menu.rules'|trans }}</a></li> 18 <li class="tab col s12 m6 l3"><a href="#set5">{{ 'config.tab_menu.rules'|trans }}</a></li>
19 <li class="tab col s12 m6 l3"><a href="#set6">{{ 'config.tab_menu.reset'|trans }}</a></li> 19 <li class="tab col s12 m6 l3"><a href="#set6">{{ 'config.tab_menu.ignore_origin'|trans }}</a></li>
20 <li class="tab col s12 m6 l3"><a href="#set7">{{ 'config.tab_menu.reset'|trans }}</a></li>
20 </ul> 21 </ul>
21 </div> 22 </div>
22 23
@@ -294,11 +295,11 @@
294 « {{ tagging_rule.rule }} » 295 « {{ tagging_rule.rule }} »
295 {{ 'config.form_rules.then_tag_as_label'|trans }} 296 {{ 'config.form_rules.then_tag_as_label'|trans }}
296 « {{ tagging_rule.tags|join(', ') }} » 297 « {{ tagging_rule.tags|join(', ') }} »
297 <a href="{{ path('edit_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}"> 298 <a href="{{ path('edit_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}" class="mode_edit">
298 <i class="tool grey-text mode_edit material-icons">mode_edit</i> 299 <i class="tool grey-text material-icons">mode_edit</i>
299 </a> 300 </a>
300 <a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}"> 301 <a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}" class="delete">
301 <i class="tool grey-text delete material-icons">delete</i> 302 <i class="tool grey-text material-icons">delete</i>
302 </a> 303 </a>
303 </li> 304 </li>
304 {% endfor %} 305 {% endfor %}
@@ -466,6 +467,89 @@
466 </div> 467 </div>
467 468
468 <div id="set6" class="col s12"> 469 <div id="set6" class="col s12">
470 {% if app.user.config.ignoreOriginRules is not empty %}
471 <div class="row">
472 <div class="input-field col s12">
473 <ul>
474 {% for ignore_origin_rule in app.user.config.ignoreOriginRules %}
475 <li>
476 {{ 'config.form_rules.if_label'|trans }}
477 « {{ ignore_origin_rule.rule }} »
478 <a href="{{ path('edit_ignore_origin_rule', {id: ignore_origin_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}" class="mode_edit">
479 <i class="tool grey-text material-icons">mode_edit</i>
480 </a>
481 <a href="{{ path('delete_ignore_origin_rule', {id: ignore_origin_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}" class="delete">
482 <i class="tool grey-text material-icons">delete</i>
483 </a>
484 </li>
485 {% endfor %}
486 </ul>
487 </div>
488 </div>
489 {% endif %}
490
491 {{ form_start(form.new_ignore_origin_user_rule) }}
492 {{ form_errors(form.new_ignore_origin_user_rule) }}
493
494 <div class="row">
495 <div class="input-field col s12">
496 {{ form_label(form.new_ignore_origin_user_rule.rule) }}
497 {{ form_errors(form.new_ignore_origin_user_rule.rule) }}
498 {{ form_widget(form.new_ignore_origin_user_rule.rule) }}
499 </div>
500 </div>
501
502 {{ form_widget(form.new_ignore_origin_user_rule.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
503 {{ form_rest(form.new_ignore_origin_user_rule) }}
504 </form>
505
506
507
508 <div class="row">
509 <div class="input-field col s12">
510 <h4>{{ 'config.form_ignore_origin_rules.faq.title'|trans }}</h4>
511
512 <h5>{{ 'config.form_ignore_origin_rules.faq.ignore_origin_rules_definition_title'|trans }}</h5>
513 <p class="help">{{ 'config.form_ignore_origin_rules.faq.ignore_origin_rules_definition_description'|trans|raw }}</p>
514
515 <h5>{{ 'config.form_ignore_origin_rules.faq.how_to_use_them_title'|trans }}</h5>
516 <p class="help">{{ 'config.form_ignore_origin_rules.faq.how_to_use_them_description'|trans|raw }}</p>
517
518 <h5>{{ 'config.form_ignore_origin_rules.faq.variables_available_title'|trans }}</h5>
519 <p class="help">
520 {{ 'config.form_ignore_origin_rules.faq.variables_available_description'|trans }}
521 </p>
522
523 <table class="bordered">
524 <thead>
525 <tr>
526 <th>{{ 'config.form_ignore_origin_rules.faq.variable_description.label'|trans }}</th>
527 <th>{{ 'config.form_ignore_origin_rules.faq.meaning'|trans }}</th>
528 <th>{{ 'config.form_ignore_origin_rules.faq.operator_description.label'|trans }}</th>
529 <th>{{ 'config.form_ignore_origin_rules.faq.meaning'|trans }}</th>
530 </tr>
531 </thead>
532
533 <tbody>
534 <tr>
535 <td>host</td>
536 <td>{{ 'config.form_ignore_origin_rules.faq.variable_description.host'|trans }}</td>
537 <td>=</td>
538 <td>{{ 'config.form_ignore_origin_rules.faq.operator_description.equal_to'|trans }}</td>
539 </tr>
540 <tr>
541 <td>_all</td>
542 <td>{{ 'config.form_ignore_origin_rules.faq.variable_description._all'|trans }}</td>
543 <td>~</td>
544 <td>{{ 'config.form_ignore_origin_rules.faq.operator_description.matches'|trans|raw }}</td>
545 </tr>
546 </tbody>
547 </table>
548 </div>
549 </div>
550 </div>
551
552 <div id="set7" class="col s12">
469 <div class="row"> 553 <div class="row">
470 <h5>{{ 'config.reset.title'|trans }}</h5> 554 <h5>{{ 'config.reset.title'|trans }}</h5>
471 <p>{{ 'config.reset.description'|trans }}</p> 555 <p>{{ 'config.reset.description'|trans }}</p>
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
index 00000000..30c2a520
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/edit.html.twig
@@ -0,0 +1,87 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
4
5{% block content %}
6
7 <div class="row">
8 <div class="col s12">
9 <div class="card-panel">
10 <div class="row">
11 <div class="input-field col s12">
12 <h4>{{ 'ignore_origin_instance_rule.edit_ignore_origin_instance_rule'|trans }}</h4>
13
14 <div id="set6" class="col s12">
15 {{ form_start(edit_form) }}
16 {{ form_errors(edit_form) }}
17
18 <div class="row">
19 <div class="input-field col s12">
20 {{ form_label(edit_form.rule) }}
21 {{ form_errors(edit_form.rule) }}
22 {{ form_widget(edit_form.rule) }}
23 </div>
24 </div>
25
26 <br/>
27
28 {{ form_widget(edit_form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
29 {{ form_widget(edit_form._token) }}
30 </form>
31 <p>
32 {{ form_start(delete_form) }}
33 <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>
34 {{ form_end(delete_form) }}
35 </p>
36 <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>
37 </div>
38 </div>
39 </div>
40
41 <div class="row">
42 <div class="input-field col s12">
43 <h4>{{ 'config.form_ignore_origin_rules.faq.title'|trans }}</h4>
44
45 <h5>{{ 'config.form_ignore_origin_rules.faq.ignore_origin_rules_definition_title'|trans }}</h5>
46 <p class="help">{{ 'config.form_ignore_origin_rules.faq.ignore_origin_rules_definition_description'|trans|raw }}</p>
47
48 <h5>{{ 'config.form_ignore_origin_rules.faq.how_to_use_them_title'|trans }}</h5>
49 <p class="help">{{ 'config.form_ignore_origin_rules.faq.how_to_use_them_description'|trans|raw }}</p>
50
51 <h5>{{ 'config.form_ignore_origin_rules.faq.variables_available_title'|trans }}</h5>
52 <p class="help">
53 {{ 'config.form_ignore_origin_rules.faq.variables_available_description'|trans }}
54 </p>
55
56 <table class="bordered">
57 <thead>
58 <tr>
59 <th>{{ 'config.form_ignore_origin_rules.faq.variable_description.label'|trans }}</th>
60 <th>{{ 'config.form_ignore_origin_rules.faq.meaning'|trans }}</th>
61 <th>{{ 'config.form_ignore_origin_rules.faq.operator_description.label'|trans }}</th>
62 <th>{{ 'config.form_ignore_origin_rules.faq.meaning'|trans }}</th>
63 </tr>
64 </thead>
65
66 <tbody>
67 <tr>
68 <td>host</td>
69 <td>{{ 'config.form_ignore_origin_rules.faq.variable_description.host'|trans }}</td>
70 <td>=</td>
71 <td>{{ 'config.form_ignore_origin_rules.faq.operator_description.equal_to'|trans }}</td>
72 </tr>
73 <tr>
74 <td>_all</td>
75 <td>{{ 'config.form_ignore_origin_rules.faq.variable_description._all'|trans }}</td>
76 <td>~</td>
77 <td>{{ 'config.form_ignore_origin_rules.faq.operator_description.matches'|trans|raw }}</td>
78 </tr>
79 </tbody>
80 </table>
81 </div>
82 </div>
83 </div>
84 </div>
85 </div>
86
87{% 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
index 00000000..2de7cf0a
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/index.html.twig
@@ -0,0 +1,42 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
4
5{% block content %}
6
7 <div class="row">
8 <div class="col s12">
9 <div class="card-panel">
10 <div class="row">
11 <div class="input-field col s12">
12 <p class="help">{{ 'ignore_origin_instance_rule.description'|trans|raw }}</p>
13
14 <table class="bordered">
15 <thead>
16 <tr>
17 <th>{{ 'ignore_origin_instance_rule.form.rule_label'|trans }}</th>
18 <th>{{ 'ignore_origin_instance_rule.list.actions'|trans }}</th>
19 </tr>
20 </thead>
21 <tbody>
22 {% for rule in rules %}
23 <tr>
24 <td>{{ rule.rule }}</td>
25 <td>
26 <a href="{{ path('ignore_origin_instance_rules_edit', { 'id': rule.id }) }}">{{ 'ignore_origin_instance_rule.list.edit_action'|trans }}</a>
27 </td>
28 </tr>
29 {% endfor %}
30 </tbody>
31 </table>
32 <br />
33 <p>
34 <a href="{{ path('ignore_origin_instance_rules_new') }}" class="waves-effect waves-light btn">{{ 'ignore_origin_instance_rule.list.create_new_one'|trans }}</a>
35 </p>
36 </div>
37 </div>
38 </div>
39 </div>
40 </div>
41
42{% 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
index 00000000..cb052ff0
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/IgnoreOriginInstanceRule/new.html.twig
@@ -0,0 +1,80 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{{ 'ignore_origin_instance_rule.page_title'|trans }}{% endblock %}
4
5{% block content %}
6
7 <div class="row">
8 <div class="col s12">
9 <div class="card-panel">
10 <div class="row">
11 <div class="input-field col s12">
12 <h4>{{ 'ignore_origin_instance_rule.new_ignore_origin_instance_rule'|trans }}</h4>
13
14 <div id="set6" class="col s12">
15 {{ form_start(form) }}
16 {{ form_errors(form) }}
17
18 <div class="row">
19 <div class="input-field col s12">
20 {{ form_label(form.rule) }}
21 {{ form_errors(form.rule) }}
22 {{ form_widget(form.rule) }}
23 </div>
24 </div>
25
26 {{ form_widget(form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
27 {{ form_rest(form) }}
28 </form>
29 <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>
30 </div>
31 </div>
32 </div>
33
34 <div class="row">
35 <div class="input-field col s12">
36 <h4>{{ 'config.form_ignore_origin_rules.faq.title'|trans }}</h4>
37
38 <h5>{{ 'config.form_ignore_origin_rules.faq.ignore_origin_rules_definition_title'|trans }}</h5>
39 <p class="help">{{ 'config.form_ignore_origin_rules.faq.ignore_origin_rules_definition_description'|trans|raw }}</p>
40
41 <h5>{{ 'config.form_ignore_origin_rules.faq.how_to_use_them_title'|trans }}</h5>
42 <p class="help">{{ 'config.form_ignore_origin_rules.faq.how_to_use_them_description'|trans|raw }}</p>
43
44 <h5>{{ 'config.form_ignore_origin_rules.faq.variables_available_title'|trans }}</h5>
45 <p class="help">
46 {{ 'config.form_ignore_origin_rules.faq.variables_available_description'|trans }}
47 </p>
48
49 <table class="bordered">
50 <thead>
51 <tr>
52 <th>{{ 'config.form_ignore_origin_rules.faq.variable_description.label'|trans }}</th>
53 <th>{{ 'config.form_ignore_origin_rules.faq.meaning'|trans }}</th>
54 <th>{{ 'config.form_ignore_origin_rules.faq.operator_description.label'|trans }}</th>
55 <th>{{ 'config.form_ignore_origin_rules.faq.meaning'|trans }}</th>
56 </tr>
57 </thead>
58
59 <tbody>
60 <tr>
61 <td>host</td>
62 <td>{{ 'config.form_ignore_origin_rules.faq.variable_description.host'|trans }}</td>
63 <td>=</td>
64 <td>{{ 'config.form_ignore_origin_rules.faq.operator_description.equal_to'|trans }}</td>
65 </tr>
66 <tr>
67 <td>_all</td>
68 <td>{{ 'config.form_ignore_origin_rules.faq.variable_description._all'|trans }}</td>
69 <td>~</td>
70 <td>{{ 'config.form_ignore_origin_rules.faq.operator_description.matches'|trans|raw }}</td>
71 </tr>
72 </tbody>
73 </table>
74 </div>
75 </div>
76 </div>
77 </div>
78 </div>
79
80{% 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 c51d07fc..d9b6d190 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
@@ -78,9 +78,13 @@
78 <a class="waves-effect" href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a> 78 <a class="waves-effect" href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a>
79 </li> 79 </li>
80 80
81 <li class="bold border-bottom {% if currentRoute == 'craue_config_settings_modify' %}active{% endif %}"> 81 <li class="bold {% if currentRoute == 'craue_config_settings_modify' %}active{% endif %}">
82 <a class="waves-effect" href="{{ path('craue_config_settings_modify') }}">{{ 'menu.left.internal_settings'|trans }}</a> 82 <a class="waves-effect" href="{{ path('craue_config_settings_modify') }}">{{ 'menu.left.internal_settings'|trans }}</a>
83 </li> 83 </li>
84
85 <li class="bold border-bottom {% if currentRoute == 'ignore_origin_instance_rules_index' %}active{% endif %}">
86 <a class="waves-effect" href="{{ path('ignore_origin_instance_rules_index') }}">{{ 'menu.left.ignore_origin_instance_rules'|trans }}</a>
87 </li>
84 {% endif %} 88 {% endif %}
85 <li class="bold {% if currentRoute == 'import' %}active{% endif %}"> 89 <li class="bold {% if currentRoute == 'import' %}active{% endif %}">
86 <a class="waves-effect" href="{{ path('import') }}">{{ 'menu.left.import'|trans }}</a> 90 <a class="waves-effect" href="{{ path('import') }}">{{ 'menu.left.import'|trans }}</a>
diff --git a/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php b/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php
index c4bd6dac..a0e2939c 100644
--- a/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php
+++ b/tests/Wallabag/CoreBundle/Command/ReloadEntryCommandTest.php
@@ -45,6 +45,9 @@ class ReloadEntryCommandTest extends WallabagCoreTestCase
45 $this->getEntityManager()->flush(); 45 $this->getEntityManager()->flush();
46 } 46 }
47 47
48 /**
49 * @group NetworkCalls
50 */
48 public function testRunReloadEntryCommand() 51 public function testRunReloadEntryCommand()
49 { 52 {
50 $application = new Application($this->getClient()->getKernel()); 53 $application = new Application($this->getClient()->getKernel());
@@ -70,6 +73,9 @@ class ReloadEntryCommandTest extends WallabagCoreTestCase
70 $this->assertContains('Done', $tester->getDisplay()); 73 $this->assertContains('Done', $tester->getDisplay());
71 } 74 }
72 75
76 /**
77 * @group NetworkCalls
78 */
73 public function testRunReloadEntryWithUsernameCommand() 79 public function testRunReloadEntryWithUsernameCommand()
74 { 80 {
75 $application = new Application($this->getClient()->getKernel()); 81 $application = new Application($this->getClient()->getKernel());
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
index b3b3a19a..92d22267 100644
--- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
@@ -435,7 +435,6 @@ class ConfigControllerTest extends WallabagCoreTestCase
435 public function testTaggingRuleCreation() 435 public function testTaggingRuleCreation()
436 { 436 {
437 $this->logInAs('admin'); 437 $this->logInAs('admin');
438 $this->useTheme('baggy');
439 $client = $this->getClient(); 438 $client = $this->getClient();
440 439
441 $crawler = $client->request('GET', '/config'); 440 $crawler = $client->request('GET', '/config');
@@ -457,7 +456,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
457 456
458 $this->assertContains('flashes.config.notice.tagging_rules_updated', $crawler->filter('body')->extract(['_text'])[0]); 457 $this->assertContains('flashes.config.notice.tagging_rules_updated', $crawler->filter('body')->extract(['_text'])[0]);
459 458
460 $editLink = $crawler->filter('.mode_edit')->last()->link(); 459 $editLink = $crawler->filter('div[id=set5] a.mode_edit')->last()->link();
461 460
462 $crawler = $client->click($editLink); 461 $crawler = $client->click($editLink);
463 $this->assertSame(302, $client->getResponse()->getStatusCode()); 462 $this->assertSame(302, $client->getResponse()->getStatusCode());
@@ -482,7 +481,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
482 481
483 $this->assertContains('readingTime <= 30', $crawler->filter('body')->extract(['_text'])[0]); 482 $this->assertContains('readingTime <= 30', $crawler->filter('body')->extract(['_text'])[0]);
484 483
485 $deleteLink = $crawler->filter('.delete')->last()->link(); 484 $deleteLink = $crawler->filter('div[id=set5] a.delete')->last()->link();
486 485
487 $crawler = $client->click($deleteLink); 486 $crawler = $client->click($deleteLink);
488 $this->assertSame(302, $client->getResponse()->getStatusCode()); 487 $this->assertSame(302, $client->getResponse()->getStatusCode());
@@ -574,11 +573,11 @@ class ConfigControllerTest extends WallabagCoreTestCase
574 ->getRepository('WallabagCoreBundle:TaggingRule') 573 ->getRepository('WallabagCoreBundle:TaggingRule')
575 ->findAll()[0]; 574 ->findAll()[0];
576 575
577 $crawler = $client->request('GET', '/tagging-rule/edit/' . $rule->getId()); 576 $crawler = $client->request('GET', '/tagging-rule/delete/' . $rule->getId());
578 577
579 $this->assertSame(403, $client->getResponse()->getStatusCode()); 578 $this->assertSame(403, $client->getResponse()->getStatusCode());
580 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 579 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
581 $this->assertContains('You can not access this tagging rule', $body[0]); 580 $this->assertContains('You can not access this rule', $body[0]);
582 } 581 }
583 582
584 public function testEditingTaggingRuleFromAnOtherUser() 583 public function testEditingTaggingRuleFromAnOtherUser()
@@ -594,7 +593,144 @@ class ConfigControllerTest extends WallabagCoreTestCase
594 593
595 $this->assertSame(403, $client->getResponse()->getStatusCode()); 594 $this->assertSame(403, $client->getResponse()->getStatusCode());
596 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 595 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
597 $this->assertContains('You can not access this tagging rule', $body[0]); 596 $this->assertContains('You can not access this rule', $body[0]);
597 }
598
599 public function testIgnoreOriginRuleCreation()
600 {
601 $this->logInAs('admin');
602 $client = $this->getClient();
603
604 $crawler = $client->request('GET', '/config');
605
606 $this->assertSame(200, $client->getResponse()->getStatusCode());
607
608 $form = $crawler->filter('button[id=ignore_origin_user_rule_save]')->form();
609
610 $data = [
611 'ignore_origin_user_rule[rule]' => 'host = "example.com"',
612 ];
613
614 $client->submit($form, $data);
615
616 $this->assertSame(302, $client->getResponse()->getStatusCode());
617
618 $crawler = $client->followRedirect();
619
620 $this->assertContains('flashes.config.notice.ignore_origin_rules_updated', $crawler->filter('body')->extract(['_text'])[0]);
621
622 $editLink = $crawler->filter('div[id=set6] a.mode_edit')->last()->link();
623
624 $crawler = $client->click($editLink);
625 $this->assertSame(302, $client->getResponse()->getStatusCode());
626 $this->assertContains('?ignore-origin-user-rule=', $client->getResponse()->headers->get('location'));
627
628 $crawler = $client->followRedirect();
629
630 $form = $crawler->filter('button[id=ignore_origin_user_rule_save]')->form();
631
632 $data = [
633 'ignore_origin_user_rule[rule]' => 'host = "example.org"',
634 ];
635
636 $client->submit($form, $data);
637
638 $this->assertSame(302, $client->getResponse()->getStatusCode());
639
640 $crawler = $client->followRedirect();
641
642 $this->assertContains('flashes.config.notice.ignore_origin_rules_updated', $crawler->filter('body')->extract(['_text'])[0]);
643
644 $this->assertContains('host = "example.org"', $crawler->filter('body')->extract(['_text'])[0]);
645
646 $deleteLink = $crawler->filter('div[id=set6] a.delete')->last()->link();
647
648 $crawler = $client->click($deleteLink);
649 $this->assertSame(302, $client->getResponse()->getStatusCode());
650
651 $crawler = $client->followRedirect();
652 $this->assertContains('flashes.config.notice.ignore_origin_rules_deleted', $crawler->filter('body')->extract(['_text'])[0]);
653 }
654
655 public function dataForIgnoreOriginRuleCreationFail()
656 {
657 return [
658 [
659 [
660 'ignore_origin_user_rule[rule]' => 'foo = "bar"',
661 ],
662 [
663 'The variable',
664 'does not exist.',
665 ],
666 ],
667 [
668 [
669 'ignore_origin_user_rule[rule]' => '_all != "none"',
670 ],
671 [
672 'The operator',
673 'does not exist.',
674 ],
675 ],
676 ];
677 }
678
679 /**
680 * @dataProvider dataForIgnoreOriginRuleCreationFail
681 */
682 public function testIgnoreOriginRuleCreationFail($data, $messages)
683 {
684 $this->logInAs('admin');
685 $client = $this->getClient();
686
687 $crawler = $client->request('GET', '/config');
688
689 $this->assertSame(200, $client->getResponse()->getStatusCode());
690
691 $form = $crawler->filter('button[id=ignore_origin_user_rule_save]')->form();
692
693 $crawler = $client->submit($form, $data);
694
695 $this->assertSame(200, $client->getResponse()->getStatusCode());
696
697 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
698
699 foreach ($messages as $message) {
700 $this->assertContains($message, $body[0]);
701 }
702 }
703
704 public function testDeletingIgnoreOriginRuleFromAnOtherUser()
705 {
706 $this->logInAs('bob');
707 $client = $this->getClient();
708
709 $rule = $client->getContainer()->get('doctrine.orm.entity_manager')
710 ->getRepository('WallabagCoreBundle:IgnoreOriginUserRule')
711 ->findAll()[0];
712
713 $crawler = $client->request('GET', '/ignore-origin-user-rule/edit/' . $rule->getId());
714
715 $this->assertSame(403, $client->getResponse()->getStatusCode());
716 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
717 $this->assertContains('You can not access this rule', $body[0]);
718 }
719
720 public function testEditingIgnoreOriginRuleFromAnOtherUser()
721 {
722 $this->logInAs('bob');
723 $client = $this->getClient();
724
725 $rule = $client->getContainer()->get('doctrine.orm.entity_manager')
726 ->getRepository('WallabagCoreBundle:IgnoreOriginUserRule')
727 ->findAll()[0];
728
729 $crawler = $client->request('GET', '/ignore-origin-user-rule/edit/' . $rule->getId());
730
731 $this->assertSame(403, $client->getResponse()->getStatusCode());
732 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
733 $this->assertContains('You can not access this rule', $body[0]);
598 } 734 }
599 735
600 public function testDemoMode() 736 public function testDemoMode()
@@ -676,6 +812,9 @@ class ConfigControllerTest extends WallabagCoreTestCase
676 $em->flush(); 812 $em->flush();
677 } 813 }
678 814
815 /**
816 * @group NetworkCalls
817 */
679 public function testDeleteAccount() 818 public function testDeleteAccount()
680 { 819 {
681 $client = $this->getClient(); 820 $client = $this->getClient();
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 5b806830..0aa562d8 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -40,6 +40,9 @@ class EntryControllerTest extends WallabagCoreTestCase
40 $this->assertContains('login', $client->getResponse()->headers->get('location')); 40 $this->assertContains('login', $client->getResponse()->headers->get('location'));
41 } 41 }
42 42
43 /**
44 * @group NetworkCalls
45 */
43 public function testQuickstart() 46 public function testQuickstart()
44 { 47 {
45 $this->logInAs('empty'); 48 $this->logInAs('empty');
@@ -87,6 +90,9 @@ class EntryControllerTest extends WallabagCoreTestCase
87 $this->assertCount(1, $crawler->filter('form[name=entry]')); 90 $this->assertCount(1, $crawler->filter('form[name=entry]'));
88 } 91 }
89 92
93 /**
94 * @group NetworkCalls
95 */
90 public function testPostNewViaBookmarklet() 96 public function testPostNewViaBookmarklet()
91 { 97 {
92 $this->logInAs('admin'); 98 $this->logInAs('admin');
@@ -131,7 +137,7 @@ class EntryControllerTest extends WallabagCoreTestCase
131 } 137 }
132 138
133 /** 139 /**
134 * This test will require an internet connection. 140 * @group NetworkCalls
135 */ 141 */
136 public function testPostNewOk() 142 public function testPostNewOk()
137 { 143 {
@@ -169,6 +175,9 @@ class EntryControllerTest extends WallabagCoreTestCase
169 $client->getContainer()->get('craue_config')->set('store_article_headers', 0); 175 $client->getContainer()->get('craue_config')->set('store_article_headers', 0);
170 } 176 }
171 177
178 /**
179 * @group NetworkCalls
180 */
172 public function testPostWithMultipleAuthors() 181 public function testPostWithMultipleAuthors()
173 { 182 {
174 $url = 'https://www.liberation.fr/planete/2017/04/05/donald-trump-et-xi-jinping-tentative-de-flirt-en-floride_1560768'; 183 $url = 'https://www.liberation.fr/planete/2017/04/05/donald-trump-et-xi-jinping-tentative-de-flirt-en-floride_1560768';
@@ -229,6 +238,9 @@ class EntryControllerTest extends WallabagCoreTestCase
229 $this->assertContains('/view/', $client->getResponse()->getTargetUrl()); 238 $this->assertContains('/view/', $client->getResponse()->getTargetUrl());
230 } 239 }
231 240
241 /**
242 * @group NetworkCalls
243 */
232 public function testPostNewOkUrlExistWithAccent() 244 public function testPostNewOkUrlExistWithAccent()
233 { 245 {
234 $this->logInAs('admin'); 246 $this->logInAs('admin');
@@ -265,7 +277,7 @@ class EntryControllerTest extends WallabagCoreTestCase
265 } 277 }
266 278
267 /** 279 /**
268 * This test will require an internet connection. 280 * @group NetworkCalls
269 */ 281 */
270 public function testPostNewOkUrlExistWithRedirection() 282 public function testPostNewOkUrlExistWithRedirection()
271 { 283 {
@@ -303,7 +315,7 @@ class EntryControllerTest extends WallabagCoreTestCase
303 } 315 }
304 316
305 /** 317 /**
306 * This test will require an internet connection. 318 * @group NetworkCalls
307 */ 319 */
308 public function testPostNewThatWillBeTagged() 320 public function testPostNewThatWillBeTagged()
309 { 321 {
@@ -430,7 +442,7 @@ class EntryControllerTest extends WallabagCoreTestCase
430 } 442 }
431 443
432 /** 444 /**
433 * This test will require an internet connection. 445 * @group NetworkCalls
434 */ 446 */
435 public function testReload() 447 public function testReload()
436 { 448 {
@@ -1056,6 +1068,9 @@ class EntryControllerTest extends WallabagCoreTestCase
1056 $this->assertSame(404, $client->getResponse()->getStatusCode()); 1068 $this->assertSame(404, $client->getResponse()->getStatusCode());
1057 } 1069 }
1058 1070
1071 /**
1072 * @group NetworkCalls
1073 */
1059 public function testNewEntryWithDownloadImagesEnabled() 1074 public function testNewEntryWithDownloadImagesEnabled()
1060 { 1075 {
1061 $this->downloadImagesEnabled = true; 1076 $this->downloadImagesEnabled = true;
@@ -1383,6 +1398,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1383 1398
1384 /** 1399 /**
1385 * @dataProvider dataForLanguage 1400 * @dataProvider dataForLanguage
1401 * @group NetworkCalls
1386 */ 1402 */
1387 public function testLanguageValidation($url, $expectedLanguage) 1403 public function testLanguageValidation($url, $expectedLanguage)
1388 { 1404 {
@@ -1414,7 +1430,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1414 } 1430 }
1415 1431
1416 /** 1432 /**
1417 * This test will require an internet connection. 1433 * @group NetworkCalls
1418 */ 1434 */
1419 public function testRestrictedArticle() 1435 public function testRestrictedArticle()
1420 { 1436 {
diff --git a/tests/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleControllerTest.php b/tests/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleControllerTest.php
new file mode 100644
index 00000000..9783cd25
--- /dev/null
+++ b/tests/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleControllerTest.php
@@ -0,0 +1,148 @@
1<?php
2
3namespace Tests\Wallabag\CoreBundle\Controller;
4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6
7class IgnoreOriginInstanceRuleControllerTest extends WallabagCoreTestCase
8{
9 public function testListIgnoreOriginInstanceRule()
10 {
11 $this->logInAs('admin');
12 $client = $this->getClient();
13
14 $crawler = $client->request('GET', '/ignore-origin-instance-rules/');
15
16 $this->assertSame(200, $client->getResponse()->getStatusCode());
17
18 $body = $crawler->filter('body')->extract(['_text'])[0];
19
20 $this->assertContains('ignore_origin_instance_rule.description', $body);
21 $this->assertContains('ignore_origin_instance_rule.list.create_new_one', $body);
22 }
23
24 public function testIgnoreOriginInstanceRuleCreationEditionDeletion()
25 {
26 $this->logInAs('admin');
27 $client = $this->getClient();
28
29 // Creation
30 $crawler = $client->request('GET', '/ignore-origin-instance-rules/new');
31
32 $this->assertSame(200, $client->getResponse()->getStatusCode());
33
34 $body = $crawler->filter('body')->extract(['_text'])[0];
35
36 $this->assertContains('ignore_origin_instance_rule.new_ignore_origin_instance_rule', $body);
37 $this->assertContains('ignore_origin_instance_rule.form.back_to_list', $body);
38
39 $form = $crawler->filter('button[id=ignore_origin_instance_rule_save]')->form();
40
41 $data = [
42 'ignore_origin_instance_rule[rule]' => 'host = "foo.example.com"',
43 ];
44
45 $client->submit($form, $data);
46
47 $this->assertSame(302, $client->getResponse()->getStatusCode());
48
49 $crawler = $client->followRedirect();
50
51 $this->assertContains('flashes.ignore_origin_instance_rule.notice.added', $crawler->filter('body')->extract(['_text'])[0]);
52
53 // Edition
54 $editLink = $crawler->filter('div[id=content] table a')->last()->link();
55
56 $crawler = $client->click($editLink);
57
58 $this->assertSame(200, $client->getResponse()->getStatusCode());
59
60 $this->assertContains('foo.example.com', $crawler->filter('form[name=ignore_origin_instance_rule] input[type=text]')->extract(['value'])[0]);
61
62 $body = $crawler->filter('body')->extract(['_text'])[0];
63
64 $this->assertContains('ignore_origin_instance_rule.edit_ignore_origin_instance_rule', $body);
65 $this->assertContains('ignore_origin_instance_rule.form.back_to_list', $body);
66
67 $form = $crawler->filter('button[id=ignore_origin_instance_rule_save]')->form();
68
69 $data = [
70 'ignore_origin_instance_rule[rule]' => 'host = "bar.example.com"',
71 ];
72
73 $client->submit($form, $data);
74
75 $this->assertSame(302, $client->getResponse()->getStatusCode());
76
77 $crawler = $client->followRedirect();
78
79 $this->assertContains('flashes.ignore_origin_instance_rule.notice.updated', $crawler->filter('body')->extract(['_text'])[0]);
80
81 $editLink = $crawler->filter('div[id=content] table a')->last()->link();
82
83 $crawler = $client->click($editLink);
84
85 $this->assertSame(200, $client->getResponse()->getStatusCode());
86
87 $this->assertContains('bar.example.com', $crawler->filter('form[name=ignore_origin_instance_rule] input[type=text]')->extract(['value'])[0]);
88
89 $deleteForm = $crawler->filter('body')->selectButton('ignore_origin_instance_rule.form.delete')->form();
90
91 $client->submit($deleteForm, []);
92
93 $this->assertSame(302, $client->getResponse()->getStatusCode());
94
95 $crawler = $client->followRedirect();
96
97 $this->assertContains('flashes.ignore_origin_instance_rule.notice.deleted', $crawler->filter('body')->extract(['_text'])[0]);
98 }
99
100 public function dataForIgnoreOriginInstanceRuleCreationFail()
101 {
102 return [
103 [
104 [
105 'ignore_origin_instance_rule[rule]' => 'foo = "bar"',
106 ],
107 [
108 'The variable',
109 'does not exist.',
110 ],
111 ],
112 [
113 [
114 'ignore_origin_instance_rule[rule]' => '_all != "none"',
115 ],
116 [
117 'The operator',
118 'does not exist.',
119 ],
120 ],
121 ];
122 }
123
124 /**
125 * @dataProvider dataForIgnoreOriginInstanceRuleCreationFail
126 */
127 public function testIgnoreOriginInstanceRuleCreationFail($data, $messages)
128 {
129 $this->logInAs('admin');
130 $client = $this->getClient();
131
132 $crawler = $client->request('GET', '/ignore-origin-instance-rules/new');
133
134 $this->assertSame(200, $client->getResponse()->getStatusCode());
135
136 $form = $crawler->filter('button[id=ignore_origin_instance_rule_save]')->form();
137
138 $crawler = $client->submit($form, $data);
139
140 $this->assertSame(200, $client->getResponse()->getStatusCode());
141
142 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
143
144 foreach ($messages as $message) {
145 $this->assertContains($message, $body[0]);
146 }
147 }
148}
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index 9ce72c79..a65ac17c 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -12,6 +12,7 @@ use Symfony\Component\Validator\ConstraintViolationList;
12use Symfony\Component\Validator\Validator\RecursiveValidator; 12use Symfony\Component\Validator\Validator\RecursiveValidator;
13use Wallabag\CoreBundle\Entity\Entry; 13use Wallabag\CoreBundle\Entity\Entry;
14use Wallabag\CoreBundle\Helper\ContentProxy; 14use Wallabag\CoreBundle\Helper\ContentProxy;
15use Wallabag\CoreBundle\Helper\RuleBasedIgnoreOriginProcessor;
15use Wallabag\CoreBundle\Helper\RuleBasedTagger; 16use Wallabag\CoreBundle\Helper\RuleBasedTagger;
16use Wallabag\UserBundle\Entity\User; 17use Wallabag\UserBundle\Entity\User;
17 18
@@ -25,6 +26,8 @@ class ContentProxyTest extends TestCase
25 $tagger->expects($this->once()) 26 $tagger->expects($this->once())
26 ->method('tag'); 27 ->method('tag');
27 28
29 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
30
28 $graby = $this->getMockBuilder('Graby\Graby') 31 $graby = $this->getMockBuilder('Graby\Graby')
29 ->setMethods(['fetchContent']) 32 ->setMethods(['fetchContent'])
30 ->disableOriginalConstructor() 33 ->disableOriginalConstructor()
@@ -42,7 +45,7 @@ class ContentProxyTest extends TestCase
42 'language' => '', 45 'language' => '',
43 ]); 46 ]);
44 47
45 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 48 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
46 $entry = new Entry(new User()); 49 $entry = new Entry(new User());
47 $proxy->updateEntry($entry, 'http://user@:80'); 50 $proxy->updateEntry($entry, 'http://user@:80');
48 51
@@ -62,6 +65,8 @@ class ContentProxyTest extends TestCase
62 $tagger->expects($this->once()) 65 $tagger->expects($this->once())
63 ->method('tag'); 66 ->method('tag');
64 67
68 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
69
65 $graby = $this->getMockBuilder('Graby\Graby') 70 $graby = $this->getMockBuilder('Graby\Graby')
66 ->setMethods(['fetchContent']) 71 ->setMethods(['fetchContent'])
67 ->disableOriginalConstructor() 72 ->disableOriginalConstructor()
@@ -79,7 +84,7 @@ class ContentProxyTest extends TestCase
79 'language' => '', 84 'language' => '',
80 ]); 85 ]);
81 86
82 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 87 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
83 $entry = new Entry(new User()); 88 $entry = new Entry(new User());
84 $proxy->updateEntry($entry, 'http://0.0.0.0'); 89 $proxy->updateEntry($entry, 'http://0.0.0.0');
85 90
@@ -99,6 +104,8 @@ class ContentProxyTest extends TestCase
99 $tagger->expects($this->once()) 104 $tagger->expects($this->once())
100 ->method('tag'); 105 ->method('tag');
101 106
107 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
108
102 $graby = $this->getMockBuilder('Graby\Graby') 109 $graby = $this->getMockBuilder('Graby\Graby')
103 ->setMethods(['fetchContent']) 110 ->setMethods(['fetchContent'])
104 ->disableOriginalConstructor() 111 ->disableOriginalConstructor()
@@ -118,7 +125,7 @@ class ContentProxyTest extends TestCase
118 'description' => 'desc', 125 'description' => 'desc',
119 ]); 126 ]);
120 127
121 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 128 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
122 $entry = new Entry(new User()); 129 $entry = new Entry(new User());
123 $proxy->updateEntry($entry, 'http://domain.io'); 130 $proxy->updateEntry($entry, 'http://domain.io');
124 131
@@ -139,6 +146,10 @@ class ContentProxyTest extends TestCase
139 $tagger->expects($this->once()) 146 $tagger->expects($this->once())
140 ->method('tag'); 147 ->method('tag');
141 148
149 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
150 $ruleBasedIgnoreOriginProcessor->expects($this->once())
151 ->method('process');
152
142 $graby = $this->getMockBuilder('Graby\Graby') 153 $graby = $this->getMockBuilder('Graby\Graby')
143 ->setMethods(['fetchContent']) 154 ->setMethods(['fetchContent'])
144 ->disableOriginalConstructor() 155 ->disableOriginalConstructor()
@@ -159,7 +170,7 @@ class ContentProxyTest extends TestCase
159 ], 170 ],
160 ]); 171 ]);
161 172
162 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 173 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
163 $entry = new Entry(new User()); 174 $entry = new Entry(new User());
164 $proxy->updateEntry($entry, 'http://0.0.0.0'); 175 $proxy->updateEntry($entry, 'http://0.0.0.0');
165 176
@@ -180,6 +191,10 @@ class ContentProxyTest extends TestCase
180 $tagger->expects($this->once()) 191 $tagger->expects($this->once())
181 ->method('tag'); 192 ->method('tag');
182 193
194 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
195 $ruleBasedIgnoreOriginProcessor->expects($this->once())
196 ->method('process');
197
183 $graby = $this->getMockBuilder('Graby\Graby') 198 $graby = $this->getMockBuilder('Graby\Graby')
184 ->setMethods(['fetchContent']) 199 ->setMethods(['fetchContent'])
185 ->disableOriginalConstructor() 200 ->disableOriginalConstructor()
@@ -200,7 +215,7 @@ class ContentProxyTest extends TestCase
200 ], 215 ],
201 ]); 216 ]);
202 217
203 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 218 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
204 $entry = new Entry(new User()); 219 $entry = new Entry(new User());
205 $proxy->updateEntry($entry, 'http://0.0.0.0'); 220 $proxy->updateEntry($entry, 'http://0.0.0.0');
206 221
@@ -221,6 +236,10 @@ class ContentProxyTest extends TestCase
221 $tagger->expects($this->once()) 236 $tagger->expects($this->once())
222 ->method('tag'); 237 ->method('tag');
223 238
239 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
240 $ruleBasedIgnoreOriginProcessor->expects($this->once())
241 ->method('process');
242
224 $graby = $this->getMockBuilder('Graby\Graby') 243 $graby = $this->getMockBuilder('Graby\Graby')
225 ->setMethods(['fetchContent']) 244 ->setMethods(['fetchContent'])
226 ->disableOriginalConstructor() 245 ->disableOriginalConstructor()
@@ -240,7 +259,7 @@ class ContentProxyTest extends TestCase
240 'image' => null, 259 'image' => null,
241 ]); 260 ]);
242 261
243 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 262 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
244 $entry = new Entry(new User()); 263 $entry = new Entry(new User());
245 $proxy->updateEntry($entry, 'http://0.0.0.0'); 264 $proxy->updateEntry($entry, 'http://0.0.0.0');
246 265
@@ -261,6 +280,10 @@ class ContentProxyTest extends TestCase
261 $tagger->expects($this->once()) 280 $tagger->expects($this->once())
262 ->method('tag'); 281 ->method('tag');
263 282
283 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
284 $ruleBasedIgnoreOriginProcessor->expects($this->once())
285 ->method('process');
286
264 $graby = $this->getMockBuilder('Graby\Graby') 287 $graby = $this->getMockBuilder('Graby\Graby')
265 ->setMethods(['fetchContent']) 288 ->setMethods(['fetchContent'])
266 ->disableOriginalConstructor() 289 ->disableOriginalConstructor()
@@ -280,7 +303,7 @@ class ContentProxyTest extends TestCase
280 'image' => 'http://3.3.3.3/cover.jpg', 303 'image' => 'http://3.3.3.3/cover.jpg',
281 ]); 304 ]);
282 305
283 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 306 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
284 $entry = new Entry(new User()); 307 $entry = new Entry(new User());
285 $proxy->updateEntry($entry, 'http://0.0.0.0'); 308 $proxy->updateEntry($entry, 'http://0.0.0.0');
286 309
@@ -301,6 +324,10 @@ class ContentProxyTest extends TestCase
301 $tagger->expects($this->once()) 324 $tagger->expects($this->once())
302 ->method('tag'); 325 ->method('tag');
303 326
327 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
328 $ruleBasedIgnoreOriginProcessor->expects($this->once())
329 ->method('process');
330
304 $validator = $this->getValidator(false); 331 $validator = $this->getValidator(false);
305 $validator->expects($this->once()) 332 $validator->expects($this->once())
306 ->method('validate') 333 ->method('validate')
@@ -324,7 +351,7 @@ class ContentProxyTest extends TestCase
324 ], 351 ],
325 ]); 352 ]);
326 353
327 $proxy = new ContentProxy($graby, $tagger, $validator, $this->getLogger(), $this->fetchingErrorMessage); 354 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $validator, $this->getLogger(), $this->fetchingErrorMessage);
328 $entry = new Entry(new User()); 355 $entry = new Entry(new User());
329 $proxy->updateEntry($entry, 'http://0.0.0.0'); 356 $proxy->updateEntry($entry, 'http://0.0.0.0');
330 357
@@ -344,6 +371,10 @@ class ContentProxyTest extends TestCase
344 $tagger->expects($this->once()) 371 $tagger->expects($this->once())
345 ->method('tag'); 372 ->method('tag');
346 373
374 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
375 $ruleBasedIgnoreOriginProcessor->expects($this->once())
376 ->method('process');
377
347 $validator = $this->getValidator(false); 378 $validator = $this->getValidator(false);
348 $validator->expects($this->exactly(2)) 379 $validator->expects($this->exactly(2))
349 ->method('validate') 380 ->method('validate')
@@ -372,7 +403,7 @@ class ContentProxyTest extends TestCase
372 'image' => 'https://', 403 'image' => 'https://',
373 ]); 404 ]);
374 405
375 $proxy = new ContentProxy($graby, $tagger, $validator, $this->getLogger(), $this->fetchingErrorMessage); 406 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $validator, $this->getLogger(), $this->fetchingErrorMessage);
376 $entry = new Entry(new User()); 407 $entry = new Entry(new User());
377 $proxy->updateEntry($entry, 'http://0.0.0.0'); 408 $proxy->updateEntry($entry, 'http://0.0.0.0');
378 409
@@ -393,7 +424,11 @@ class ContentProxyTest extends TestCase
393 $tagger->expects($this->once()) 424 $tagger->expects($this->once())
394 ->method('tag'); 425 ->method('tag');
395 426
396 $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage, true); 427 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
428 $ruleBasedIgnoreOriginProcessor->expects($this->once())
429 ->method('process');
430
431 $proxy = new ContentProxy((new Graby()), $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage, true);
397 $entry = new Entry(new User()); 432 $entry = new Entry(new User());
398 $proxy->updateEntry( 433 $proxy->updateEntry(
399 $entry, 434 $entry,
@@ -433,10 +468,12 @@ class ContentProxyTest extends TestCase
433 $tagger->expects($this->once()) 468 $tagger->expects($this->once())
434 ->method('tag'); 469 ->method('tag');
435 470
471 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
472
436 $logHandler = new TestHandler(); 473 $logHandler = new TestHandler();
437 $logger = new Logger('test', [$logHandler]); 474 $logger = new Logger('test', [$logHandler]);
438 475
439 $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $logger, $this->fetchingErrorMessage); 476 $proxy = new ContentProxy((new Graby()), $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $logger, $this->fetchingErrorMessage);
440 $entry = new Entry(new User()); 477 $entry = new Entry(new User());
441 $proxy->updateEntry( 478 $proxy->updateEntry(
442 $entry, 479 $entry,
@@ -469,11 +506,13 @@ class ContentProxyTest extends TestCase
469 $tagger->expects($this->once()) 506 $tagger->expects($this->once())
470 ->method('tag'); 507 ->method('tag');
471 508
509 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
510
472 $logger = new Logger('foo'); 511 $logger = new Logger('foo');
473 $handler = new TestHandler(); 512 $handler = new TestHandler();
474 $logger->pushHandler($handler); 513 $logger->pushHandler($handler);
475 514
476 $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $logger, $this->fetchingErrorMessage); 515 $proxy = new ContentProxy((new Graby()), $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $logger, $this->fetchingErrorMessage);
477 $entry = new Entry(new User()); 516 $entry = new Entry(new User());
478 $proxy->updateEntry( 517 $proxy->updateEntry(
479 $entry, 518 $entry,
@@ -512,7 +551,9 @@ class ContentProxyTest extends TestCase
512 ->method('tag') 551 ->method('tag')
513 ->will($this->throwException(new \Exception())); 552 ->will($this->throwException(new \Exception()));
514 553
515 $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 554 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
555
556 $proxy = new ContentProxy((new Graby()), $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
516 $entry = new Entry(new User()); 557 $entry = new Entry(new User());
517 $proxy->updateEntry( 558 $proxy->updateEntry(
518 $entry, 559 $entry,
@@ -554,7 +595,9 @@ class ContentProxyTest extends TestCase
554 $tagger->expects($this->once()) 595 $tagger->expects($this->once())
555 ->method('tag'); 596 ->method('tag');
556 597
557 $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 598 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
599
600 $proxy = new ContentProxy((new Graby()), $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
558 $entry = new Entry(new User()); 601 $entry = new Entry(new User());
559 $proxy->updateEntry( 602 $proxy->updateEntry(
560 $entry, 603 $entry,
@@ -590,6 +633,8 @@ class ContentProxyTest extends TestCase
590 $tagger->expects($this->once()) 633 $tagger->expects($this->once())
591 ->method('tag'); 634 ->method('tag');
592 635
636 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
637
593 $graby = $this->getMockBuilder('Graby\Graby') 638 $graby = $this->getMockBuilder('Graby\Graby')
594 ->setMethods(['fetchContent']) 639 ->setMethods(['fetchContent'])
595 ->disableOriginalConstructor() 640 ->disableOriginalConstructor()
@@ -607,7 +652,7 @@ class ContentProxyTest extends TestCase
607 ], 652 ],
608 ]); 653 ]);
609 654
610 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 655 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
611 $entry = new Entry(new User()); 656 $entry = new Entry(new User());
612 $proxy->updateEntry($entry, 'http://0.0.0.0'); 657 $proxy->updateEntry($entry, 'http://0.0.0.0');
613 658
@@ -631,6 +676,8 @@ class ContentProxyTest extends TestCase
631 $tagger->expects($this->once()) 676 $tagger->expects($this->once())
632 ->method('tag'); 677 ->method('tag');
633 678
679 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
680
634 $graby = $this->getMockBuilder('Graby\Graby') 681 $graby = $this->getMockBuilder('Graby\Graby')
635 ->setMethods(['fetchContent']) 682 ->setMethods(['fetchContent'])
636 ->disableOriginalConstructor() 683 ->disableOriginalConstructor()
@@ -648,7 +695,7 @@ class ContentProxyTest extends TestCase
648 'language' => '', 695 'language' => '',
649 ]); 696 ]);
650 697
651 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 698 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
652 $entry = new Entry(new User()); 699 $entry = new Entry(new User());
653 $proxy->updateEntry($entry, 'http://0.0.0.0'); 700 $proxy->updateEntry($entry, 'http://0.0.0.0');
654 701
@@ -668,6 +715,8 @@ class ContentProxyTest extends TestCase
668 $tagger->expects($this->once()) 715 $tagger->expects($this->once())
669 ->method('tag'); 716 ->method('tag');
670 717
718 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
719
671 $graby = $this->getMockBuilder('Graby\Graby') 720 $graby = $this->getMockBuilder('Graby\Graby')
672 ->setMethods(['fetchContent']) 721 ->setMethods(['fetchContent'])
673 ->disableOriginalConstructor() 722 ->disableOriginalConstructor()
@@ -685,7 +734,7 @@ class ContentProxyTest extends TestCase
685 'language' => '', 734 'language' => '',
686 ]); 735 ]);
687 736
688 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 737 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
689 $entry = new Entry(new User()); 738 $entry = new Entry(new User());
690 $proxy->updateEntry($entry, 'http://0.0.0.0'); 739 $proxy->updateEntry($entry, 'http://0.0.0.0');
691 740
@@ -704,6 +753,8 @@ class ContentProxyTest extends TestCase
704 $tagger->expects($this->once()) 753 $tagger->expects($this->once())
705 ->method('tag'); 754 ->method('tag');
706 755
756 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
757
707 $graby = $this->getMockBuilder('Graby\Graby') 758 $graby = $this->getMockBuilder('Graby\Graby')
708 ->setMethods(['fetchContent']) 759 ->setMethods(['fetchContent'])
709 ->disableOriginalConstructor() 760 ->disableOriginalConstructor()
@@ -721,7 +772,7 @@ class ContentProxyTest extends TestCase
721 'language' => '', 772 'language' => '',
722 ]); 773 ]);
723 774
724 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 775 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
725 $entry = new Entry(new User()); 776 $entry = new Entry(new User());
726 $proxy->updateEntry($entry, 'http://0.0.0.0'); 777 $proxy->updateEntry($entry, 'http://0.0.0.0');
727 778
@@ -740,6 +791,8 @@ class ContentProxyTest extends TestCase
740 $tagger->expects($this->once()) 791 $tagger->expects($this->once())
741 ->method('tag'); 792 ->method('tag');
742 793
794 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
795
743 $graby = $this->getMockBuilder('Graby\Graby') 796 $graby = $this->getMockBuilder('Graby\Graby')
744 ->setMethods(['fetchContent']) 797 ->setMethods(['fetchContent'])
745 ->disableOriginalConstructor() 798 ->disableOriginalConstructor()
@@ -757,7 +810,7 @@ class ContentProxyTest extends TestCase
757 'language' => '', 810 'language' => '',
758 ]); 811 ]);
759 812
760 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 813 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
761 $entry = new Entry(new User()); 814 $entry = new Entry(new User());
762 $proxy->updateEntry($entry, 'http://0.0.0.0'); 815 $proxy->updateEntry($entry, 'http://0.0.0.0');
763 816
@@ -776,6 +829,8 @@ class ContentProxyTest extends TestCase
776 $tagger->expects($this->once()) 829 $tagger->expects($this->once())
777 ->method('tag'); 830 ->method('tag');
778 831
832 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
833
779 $graby = $this->getMockBuilder('Graby\Graby') 834 $graby = $this->getMockBuilder('Graby\Graby')
780 ->setMethods(['fetchContent']) 835 ->setMethods(['fetchContent'])
781 ->disableOriginalConstructor() 836 ->disableOriginalConstructor()
@@ -793,7 +848,7 @@ class ContentProxyTest extends TestCase
793 'language' => '', 848 'language' => '',
794 ]); 849 ]);
795 850
796 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 851 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
797 $entry = new Entry(new User()); 852 $entry = new Entry(new User());
798 $proxy->updateEntry($entry, 'http://0.0.0.0'); 853 $proxy->updateEntry($entry, 'http://0.0.0.0');
799 854
@@ -813,6 +868,8 @@ class ContentProxyTest extends TestCase
813 $tagger->expects($this->once()) 868 $tagger->expects($this->once())
814 ->method('tag'); 869 ->method('tag');
815 870
871 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
872
816 $graby = $this->getMockBuilder('Graby\Graby') 873 $graby = $this->getMockBuilder('Graby\Graby')
817 ->setMethods(['fetchContent']) 874 ->setMethods(['fetchContent'])
818 ->disableOriginalConstructor() 875 ->disableOriginalConstructor()
@@ -830,7 +887,7 @@ class ContentProxyTest extends TestCase
830 'language' => '', 887 'language' => '',
831 ]); 888 ]);
832 889
833 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 890 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
834 $entry = new Entry(new User()); 891 $entry = new Entry(new User());
835 $proxy->updateEntry($entry, 'http://0.0.0.0'); 892 $proxy->updateEntry($entry, 'http://0.0.0.0');
836 893
@@ -850,6 +907,7 @@ class ContentProxyTest extends TestCase
850 * $expected_entry_url 907 * $expected_entry_url
851 * $expected_origin_url 908 * $expected_origin_url
852 * $expected_domain 909 * $expected_domain
910 * $processor_result
853 */ 911 */
854 public function dataForChangedUrl() 912 public function dataForChangedUrl()
855 { 913 {
@@ -861,6 +919,7 @@ class ContentProxyTest extends TestCase
861 'http://1.1.1.1', 919 'http://1.1.1.1',
862 'http://0.0.0.0', 920 'http://0.0.0.0',
863 '1.1.1.1', 921 '1.1.1.1',
922 false,
864 ], 923 ],
865 'origin already set' => [ 924 'origin already set' => [
866 'http://0.0.0.0', 925 'http://0.0.0.0',
@@ -869,6 +928,7 @@ class ContentProxyTest extends TestCase
869 'http://1.1.1.1', 928 'http://1.1.1.1',
870 'http://hello', 929 'http://hello',
871 '1.1.1.1', 930 '1.1.1.1',
931 false,
872 ], 932 ],
873 'trailing slash' => [ 933 'trailing slash' => [
874 'https://example.com/hello-world', 934 'https://example.com/hello-world',
@@ -877,6 +937,7 @@ class ContentProxyTest extends TestCase
877 'https://example.com/hello-world/', 937 'https://example.com/hello-world/',
878 null, 938 null,
879 'example.com', 939 'example.com',
940 false,
880 ], 941 ],
881 'query string in fetched content' => [ 942 'query string in fetched content' => [
882 'https://example.org/hello', 943 'https://example.org/hello',
@@ -885,6 +946,7 @@ class ContentProxyTest extends TestCase
885 'https://example.org/hello?world=1', 946 'https://example.org/hello?world=1',
886 'https://example.org/hello', 947 'https://example.org/hello',
887 'example.org', 948 'example.org',
949 false,
888 ], 950 ],
889 'fragment in fetched content' => [ 951 'fragment in fetched content' => [
890 'https://example.org/hello', 952 'https://example.org/hello',
@@ -893,6 +955,7 @@ class ContentProxyTest extends TestCase
893 'https://example.org/hello', 955 'https://example.org/hello',
894 null, 956 null,
895 'example.org', 957 'example.org',
958 false,
896 ], 959 ],
897 'fragment and query string in fetched content' => [ 960 'fragment and query string in fetched content' => [
898 'https://example.org/hello', 961 'https://example.org/hello',
@@ -901,6 +964,7 @@ class ContentProxyTest extends TestCase
901 'https://example.org/hello?foo#world', 964 'https://example.org/hello?foo#world',
902 'https://example.org/hello', 965 'https://example.org/hello',
903 'example.org', 966 'example.org',
967 false,
904 ], 968 ],
905 'different path and query string in fetch content' => [ 969 'different path and query string in fetch content' => [
906 'https://example.org/hello', 970 'https://example.org/hello',
@@ -909,6 +973,7 @@ class ContentProxyTest extends TestCase
909 'https://example.org/world?foo', 973 'https://example.org/world?foo',
910 'https://example.org/hello', 974 'https://example.org/hello',
911 'example.org', 975 'example.org',
976 false,
912 ], 977 ],
913 'feedproxy ignore list test' => [ 978 'feedproxy ignore list test' => [
914 'http://feedproxy.google.com/~r/Wallabag/~3/helloworld', 979 'http://feedproxy.google.com/~r/Wallabag/~3/helloworld',
@@ -917,6 +982,7 @@ class ContentProxyTest extends TestCase
917 'https://example.org/hello-wallabag', 982 'https://example.org/hello-wallabag',
918 null, 983 null,
919 'example.org', 984 'example.org',
985 true,
920 ], 986 ],
921 'feedproxy ignore list test with origin url already set' => [ 987 'feedproxy ignore list test with origin url already set' => [
922 'http://feedproxy.google.com/~r/Wallabag/~3/helloworld', 988 'http://feedproxy.google.com/~r/Wallabag/~3/helloworld',
@@ -925,6 +991,7 @@ class ContentProxyTest extends TestCase
925 'https://example.org/hello-wallabag', 991 'https://example.org/hello-wallabag',
926 'https://example.org/this-is-source', 992 'https://example.org/this-is-source',
927 'example.org', 993 'example.org',
994 true,
928 ], 995 ],
929 'lemonde ignore pattern test' => [ 996 'lemonde ignore pattern test' => [
930 'http://www.lemonde.fr/tiny/url', 997 'http://www.lemonde.fr/tiny/url',
@@ -933,6 +1000,7 @@ class ContentProxyTest extends TestCase
933 'http://example.com/hello-world', 1000 'http://example.com/hello-world',
934 null, 1001 null,
935 'example.com', 1002 'example.com',
1003 true,
936 ], 1004 ],
937 ]; 1005 ];
938 } 1006 }
@@ -940,13 +1008,18 @@ class ContentProxyTest extends TestCase
940 /** 1008 /**
941 * @dataProvider dataForChangedUrl 1009 * @dataProvider dataForChangedUrl
942 */ 1010 */
943 public function testWithChangedUrl($entry_url, $origin_url, $content_url, $expected_entry_url, $expected_origin_url, $expected_domain) 1011 public function testWithChangedUrl($entry_url, $origin_url, $content_url, $expected_entry_url, $expected_origin_url, $expected_domain, $processor_result)
944 { 1012 {
945 $tagger = $this->getTaggerMock(); 1013 $tagger = $this->getTaggerMock();
946 $tagger->expects($this->once()) 1014 $tagger->expects($this->once())
947 ->method('tag'); 1015 ->method('tag');
948 1016
949 $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage, true); 1017 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
1018 $ruleBasedIgnoreOriginProcessor->expects($this->once())
1019 ->method('process')
1020 ->willReturn($processor_result);
1021
1022 $proxy = new ContentProxy((new Graby()), $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage, true);
950 $entry = new Entry(new User()); 1023 $entry = new Entry(new User());
951 $entry->setOriginUrl($origin_url); 1024 $entry->setOriginUrl($origin_url);
952 $proxy->updateEntry( 1025 $proxy->updateEntry(
@@ -1015,6 +1088,14 @@ class ContentProxyTest extends TestCase
1015 ->getMock(); 1088 ->getMock();
1016 } 1089 }
1017 1090
1091 private function getRuleBasedIgnoreOriginProcessorMock()
1092 {
1093 return $this->getMockBuilder(RuleBasedIgnoreOriginProcessor::class)
1094 ->setMethods(['process'])
1095 ->disableOriginalConstructor()
1096 ->getMock();
1097 }
1098
1018 private function getLogger() 1099 private function getLogger()
1019 { 1100 {
1020 return new NullLogger(); 1101 return new NullLogger();
diff --git a/tests/Wallabag/CoreBundle/Helper/RuleBasedIgnoreOriginProcessorTest.php b/tests/Wallabag/CoreBundle/Helper/RuleBasedIgnoreOriginProcessorTest.php
new file mode 100644
index 00000000..9e39bc81
--- /dev/null
+++ b/tests/Wallabag/CoreBundle/Helper/RuleBasedIgnoreOriginProcessorTest.php
@@ -0,0 +1,212 @@
1<?php
2
3namespace Tests\Wallabag\CoreBundle\Helper;
4
5use Monolog\Handler\TestHandler;
6use Monolog\Logger;
7use PHPUnit\Framework\TestCase;
8use Wallabag\CoreBundle\Entity\Config;
9use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
11use Wallabag\CoreBundle\Entity\IgnoreOriginUserRule;
12use Wallabag\CoreBundle\Helper\RuleBasedIgnoreOriginProcessor;
13use Wallabag\UserBundle\Entity\User;
14
15class RuleBasedIgnoreOriginProcessorTest extends TestCase
16{
17 private $rulerz;
18 private $processor;
19 private $ignoreOriginInstanceRuleRepository;
20 private $logger;
21 private $handler;
22
23 public function setUp()
24 {
25 $this->rulerz = $this->getRulerZMock();
26 $this->logger = $this->getLogger();
27 $this->ignoreOriginInstanceRuleRepository = $this->getIgnoreOriginInstanceRuleRepositoryMock();
28 $this->handler = new TestHandler();
29 $this->logger->pushHandler($this->handler);
30
31 $this->processor = new RuleBasedIgnoreOriginProcessor($this->rulerz, $this->logger, $this->ignoreOriginInstanceRuleRepository);
32 }
33
34 public function testProcessWithNoRule()
35 {
36 $user = $this->getUser();
37 $entry = new Entry($user);
38 $entry->setUrl('http://example.com/hello-world');
39
40 $this->ignoreOriginInstanceRuleRepository
41 ->expects($this->once())
42 ->method('findAll')
43 ->willReturn([]);
44
45 $this->rulerz
46 ->expects($this->never())
47 ->method('satisfies');
48
49 $result = $this->processor->process($entry);
50
51 $this->assertFalse($result);
52 }
53
54 public function testProcessWithNoMatchingRule()
55 {
56 $userRule = $this->getIgnoreOriginUserRule('rule as string');
57 $user = $this->getUser([$userRule]);
58 $entry = new Entry($user);
59 $entry->setUrl('http://example.com/hello-world');
60
61 $this->ignoreOriginInstanceRuleRepository
62 ->expects($this->once())
63 ->method('findAll')
64 ->willReturn([]);
65
66 $this->rulerz
67 ->expects($this->once())
68 ->method('satisfies')
69 ->willReturn(false);
70
71 $result = $this->processor->process($entry);
72
73 $this->assertFalse($result);
74 }
75
76 public function testProcessWithAMatchingRule()
77 {
78 $userRule = $this->getIgnoreOriginUserRule('rule as string');
79 $user = $this->getUser([$userRule]);
80 $entry = new Entry($user);
81 $entry->setUrl('http://example.com/hello-world');
82
83 $this->ignoreOriginInstanceRuleRepository
84 ->expects($this->once())
85 ->method('findAll')
86 ->willReturn([]);
87
88 $this->rulerz
89 ->expects($this->once())
90 ->method('satisfies')
91 ->willReturn(true);
92
93 $result = $this->processor->process($entry);
94
95 $this->assertTrue($result);
96 }
97
98 public function testProcessWithAMixOfMatchingRules()
99 {
100 $userRule = $this->getIgnoreOriginUserRule('rule as string');
101 $anotherUserRule = $this->getIgnoreOriginUserRule('another rule as string');
102 $user = $this->getUser([$userRule, $anotherUserRule]);
103 $entry = new Entry($user);
104 $entry->setUrl('http://example.com/hello-world');
105
106 $this->ignoreOriginInstanceRuleRepository
107 ->expects($this->once())
108 ->method('findAll')
109 ->willReturn([]);
110
111 $this->rulerz
112 ->method('satisfies')
113 ->will($this->onConsecutiveCalls(false, true));
114
115 $result = $this->processor->process($entry);
116
117 $this->assertTrue($result);
118 }
119
120 public function testProcessWithInstanceRules()
121 {
122 $user = $this->getUser();
123 $entry = new Entry($user);
124 $entry->setUrl('http://example.com/hello-world');
125
126 $instanceRule = $this->getIgnoreOriginInstanceRule('rule as string');
127 $this->ignoreOriginInstanceRuleRepository
128 ->expects($this->once())
129 ->method('findAll')
130 ->willReturn([$instanceRule]);
131
132 $this->rulerz
133 ->expects($this->once())
134 ->method('satisfies')
135 ->willReturn(true);
136
137 $result = $this->processor->process($entry);
138
139 $this->assertTrue($result);
140 }
141
142 public function testProcessWithMixedRules()
143 {
144 $userRule = $this->getIgnoreOriginUserRule('rule as string');
145 $user = $this->getUser([$userRule]);
146 $entry = new Entry($user);
147 $entry->setUrl('http://example.com/hello-world');
148
149 $instanceRule = $this->getIgnoreOriginInstanceRule('rule as string');
150 $this->ignoreOriginInstanceRuleRepository
151 ->expects($this->once())
152 ->method('findAll')
153 ->willReturn([$instanceRule]);
154
155 $this->rulerz
156 ->method('satisfies')
157 ->will($this->onConsecutiveCalls(false, true));
158
159 $result = $this->processor->process($entry);
160
161 $this->assertTrue($result);
162 }
163
164 private function getUser(array $ignoreOriginRules = [])
165 {
166 $user = new User();
167 $config = new Config($user);
168
169 $user->setConfig($config);
170
171 foreach ($ignoreOriginRules as $rule) {
172 $config->addIgnoreOriginRule($rule);
173 }
174
175 return $user;
176 }
177
178 private function getIgnoreOriginUserRule($rule)
179 {
180 $ignoreOriginUserRule = new IgnoreOriginUserRule();
181 $ignoreOriginUserRule->setRule($rule);
182
183 return $ignoreOriginUserRule;
184 }
185
186 private function getIgnoreOriginInstanceRule($rule)
187 {
188 $ignoreOriginInstanceRule = new IgnoreOriginInstanceRule();
189 $ignoreOriginInstanceRule->setRule($rule);
190
191 return $ignoreOriginInstanceRule;
192 }
193
194 private function getRulerZMock()
195 {
196 return $this->getMockBuilder('RulerZ\RulerZ')
197 ->disableOriginalConstructor()
198 ->getMock();
199 }
200
201 private function getIgnoreOriginInstanceRuleRepositoryMock()
202 {
203 return $this->getMockBuilder('Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository')
204 ->disableOriginalConstructor()
205 ->getMock();
206 }
207
208 private function getLogger()
209 {
210 return new Logger('foo');
211 }
212}