diff options
author | Kevin Decherf <kevin@kdecherf.com> | 2019-08-11 23:55:12 +0200 |
---|---|---|
committer | Kevin Decherf <kevin@kdecherf.com> | 2020-04-25 15:59:23 +0200 |
commit | 2495b197614d82b99eed6bbec4562078f4429ad7 (patch) | |
tree | c01fabd2a44139caa9fd5778b85946d5bc44f458 | |
parent | f39c5a2a702036750b4d7c32d02e7f92955a4eed (diff) | |
download | wallabag-2495b197614d82b99eed6bbec4562078f4429ad7.tar.gz wallabag-2495b197614d82b99eed6bbec4562078f4429ad7.tar.zst wallabag-2495b197614d82b99eed6bbec4562078f4429ad7.zip |
Add default system-wide ignore origin rules with install support
Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
5 files changed, 60 insertions, 0 deletions
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 | |||
168 | wallabag_user: | 176 | wallabag_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; | |||
12 | use Symfony\Component\Console\Output\OutputInterface; | 12 | use Symfony\Component\Console\Output\OutputInterface; |
13 | use Symfony\Component\Console\Question\Question; | 13 | use Symfony\Component\Console\Question\Question; |
14 | use Symfony\Component\Console\Style\SymfonyStyle; | 14 | use Symfony\Component\Console\Style\SymfonyStyle; |
15 | use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule; | ||
15 | use Wallabag\CoreBundle\Entity\InternalSetting; | 16 | use Wallabag\CoreBundle\Entity\InternalSetting; |
16 | 17 | ||
17 | class InstallCommand extends ContainerAwareCommand | 18 | class 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/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 | |||
3 | namespace Wallabag\CoreBundle\DataFixtures; | ||
4 | |||
5 | use Doctrine\Bundle\FixturesBundle\Fixture; | ||
6 | use Doctrine\Common\Persistence\ObjectManager; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule; | ||
10 | |||
11 | class 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/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'); |