aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-11-22 14:56:53 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-11-22 14:56:53 +0100
commitd64bf7953b0e4e793d7f75ec50bf6e42652560b2 (patch)
treec4b024b290911a3521d5a5b6166718dd9475661e
parent40f3ea57fbc86247495ef3c335f40f966a69aa50 (diff)
downloadwallabag-d64bf7953b0e4e793d7f75ec50bf6e42652560b2.tar.gz
wallabag-d64bf7953b0e4e793d7f75ec50bf6e42652560b2.tar.zst
wallabag-d64bf7953b0e4e793d7f75ec50bf6e42652560b2.zip
Added internal setting to enable/disable articles with paywall
-rw-r--r--app/DoctrineMigrations/Version20161122144743.php45
-rw-r--r--app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml1
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php5
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php5
-rw-r--r--src/Wallabag/CoreBundle/Helper/HttpClientFactory.php12
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml1
6 files changed, 67 insertions, 2 deletions
diff --git a/app/DoctrineMigrations/Version20161122144743.php b/app/DoctrineMigrations/Version20161122144743.php
new file mode 100644
index 00000000..ec80c48e
--- /dev/null
+++ b/app/DoctrineMigrations/Version20161122144743.php
@@ -0,0 +1,45 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Add the restricted_access internal setting for articles with paywall
12 */
13class Version20161122144743 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix') . $tableName;
28 }
29
30 /**
31 * @param Schema $schema
32 */
33 public function up(Schema $schema)
34 {
35 $this->addSql("INSERT INTO ".$this->getTable('craue_config_setting')." (name, value, section) VALUES ('restricted_access', 0, 'entry')");
36 }
37
38 /**
39 * @param Schema $schema
40 */
41 public function down(Schema $schema)
42 {
43 $this->addSql("DELETE FROM ".$this->getTable('craue_config_setting')." WHERE name = 'restricted_access';");
44 }
45}
diff --git a/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml
index 23de7a43..52cb8e20 100644
--- a/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml
+++ b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml
@@ -32,3 +32,4 @@ demo_mode_enabled: "Enable demo mode ? (only used for the wallabag public demo)"
32demo_mode_username: "Demo user" 32demo_mode_username: "Demo user"
33share_public: Allow public url for entries 33share_public: Allow public url for entries
34download_images_enabled: Download images locally 34download_images_enabled: Download images locally
35restricted_access: Enable authentication for websites with paywall
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index e95c3a7b..f0738b91 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -432,6 +432,11 @@ class InstallCommand extends ContainerAwareCommand
432 'value' => '0', 432 'value' => '0',
433 'section' => 'misc', 433 'section' => 'misc',
434 ], 434 ],
435 [
436 'name' => 'restricted_access',
437 'value' => '0',
438 'section' => 'entry',
439 ],
435 ]; 440 ];
436 441
437 foreach ($settings as $setting) { 442 foreach ($settings as $setting) {
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
index 1f74891a..a723656e 100644
--- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
+++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
@@ -155,6 +155,11 @@ class LoadSettingData extends AbstractFixture implements OrderedFixtureInterface
155 'value' => '0', 155 'value' => '0',
156 'section' => 'misc', 156 'section' => 'misc',
157 ], 157 ],
158 [
159 'name' => 'restricted_access',
160 'value' => '0',
161 'section' => 'entry',
162 ],
158 ]; 163 ];
159 164
160 foreach ($settings as $setting) { 165 foreach ($settings as $setting) {
diff --git a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php
index 161a5e9f..ca84c8da 100644
--- a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php
+++ b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php
@@ -18,23 +18,31 @@ class HttpClientFactory
18 /** @var \GuzzleHttp\Cookie\CookieJar */ 18 /** @var \GuzzleHttp\Cookie\CookieJar */
19 private $cookieJar; 19 private $cookieJar;
20 20
21 private $restrictedAccess;
22
21 /** 23 /**
22 * HttpClientFactory constructor. 24 * HttpClientFactory constructor.
23 * 25 *
24 * @param \GuzzleHttp\Event\SubscriberInterface $authenticatorSubscriber 26 * @param \GuzzleHttp\Event\SubscriberInterface $authenticatorSubscriber
25 * @param \GuzzleHttp\Cookie\CookieJar $cookieJar 27 * @param \GuzzleHttp\Cookie\CookieJar $cookieJar
28 * @param string $restrictedAccess
26 */ 29 */
27 public function __construct(SubscriberInterface $authenticatorSubscriber, CookieJar $cookieJar) 30 public function __construct(SubscriberInterface $authenticatorSubscriber, CookieJar $cookieJar, $restrictedAccess)
28 { 31 {
29 $this->authenticatorSubscriber = $authenticatorSubscriber; 32 $this->authenticatorSubscriber = $authenticatorSubscriber;
30 $this->cookieJar = $cookieJar; 33 $this->cookieJar = $cookieJar;
34 $this->restrictedAccess = $restrictedAccess;
31 } 35 }
32 36
33 /** 37 /**
34 * @return \GuzzleHttp\Client 38 * @return \GuzzleHttp\Client|null
35 */ 39 */
36 public function buildHttpClient() 40 public function buildHttpClient()
37 { 41 {
42 if (0 === (int) $this->restrictedAccess) {
43 return null;
44 }
45
38 // we clear the cookie to avoid websites who use cookies for analytics 46 // we clear the cookie to avoid websites who use cookies for analytics
39 $this->cookieJar->clear(); 47 $this->cookieJar->clear();
40 // need to set the (shared) cookie jar 48 // need to set the (shared) cookie jar
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml
index 1b7f39fc..bcf0c9ca 100644
--- a/src/Wallabag/CoreBundle/Resources/config/services.yml
+++ b/src/Wallabag/CoreBundle/Resources/config/services.yml
@@ -73,6 +73,7 @@ services:
73 arguments: 73 arguments:
74 - "@bd_guzzle_site_authenticator.authenticator_subscriber" 74 - "@bd_guzzle_site_authenticator.authenticator_subscriber"
75 - "@wallabag_core.guzzle.cookie_jar" 75 - "@wallabag_core.guzzle.cookie_jar"
76 - '@=service(''craue_config'').get(''restricted_access'')'
76 77
77 wallabag_core.guzzle.cookie_jar: 78 wallabag_core.guzzle.cookie_jar:
78 class: GuzzleHttp\Cookie\FileCookieJar 79 class: GuzzleHttp\Cookie\FileCookieJar