Merge pull request #3425 from wallabag/add-setting-for-headers

Added internal setting to enable/disable headers storage
This commit is contained in:
Nicolas Lœuillet 2017-11-21 13:26:24 +01:00 committed by GitHub
commit 95b7d92ea5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 105 additions and 3 deletions

View file

@ -0,0 +1,52 @@
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Add store_article_headers in craue_config_setting.
*/
class Version20171120163128 extends AbstractMigration implements ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
private $container;
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$storeArticleHeaders = $this->container
->get('doctrine.orm.default_entity_manager')
->getConnection()
->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'store_article_headers'");
$this->skipIf(false !== $storeArticleHeaders, 'It seems that you already played this migration.');
$this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('store_article_headers', '0', 'entry')");
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'store_article_headers';");
}
private function getTable($tableName)
{
return $this->container->getParameter('database_table_prefix') . $tableName;
}
}

View file

@ -12,6 +12,8 @@ export_xml: Aktiver eksport til XML
# import_with_rabbitmq: Enable RabbitMQ to import data asynchronously # import_with_rabbitmq: Enable RabbitMQ to import data asynchronously
# import_with_redis: Enable Redis to import data asynchronously # import_with_redis: Enable Redis to import data asynchronously
shaarli_url: Shaarli-URL, hvis tjenesten er aktiv shaarli_url: Shaarli-URL, hvis tjenesten er aktiv
scuttle_url: Scuttle-URL, hvis tjenesten er aktiv
unmark_url: Unmark-URL, hvis tjenesten er aktiv
share_diaspora: Aktiver deling til Diaspora share_diaspora: Aktiver deling til Diaspora
share_mail: Aktiver deling med email share_mail: Aktiver deling med email
share_shaarli: Aktiver deling gennem Shaarli share_shaarli: Aktiver deling gennem Shaarli
@ -34,3 +36,4 @@ demo_mode_username: "Demobruger"
# download_images_enabled: Download images locally # download_images_enabled: Download images locally
# restricted_access: Enable authentication for websites with paywall # restricted_access: Enable authentication for websites with paywall
# api_user_registration: Enable user to be registered using the API # api_user_registration: Enable user to be registered using the API
# store_article_headers: Enable if wallabag stores HTTP headers for each article

View file

@ -12,6 +12,8 @@ export_xml: 'XML-Export aktivieren'
import_with_rabbitmq: 'Aktiviere RabbitMQ, um Artikel asynchron zu importieren' import_with_rabbitmq: 'Aktiviere RabbitMQ, um Artikel asynchron zu importieren'
import_with_redis: 'Aktiviere Redis, um Artikel asynchron zu importieren' import_with_redis: 'Aktiviere Redis, um Artikel asynchron zu importieren'
shaarli_url: 'Shaarli-URL, sofern der Service aktiviert ist' shaarli_url: 'Shaarli-URL, sofern der Service aktiviert ist'
scuttle_url: 'Scuttle-URL, sofern der Service aktiviert ist'
unmark_url: 'Unmark-URL, sofern der Service aktiviert ist'
share_diaspora: 'Teilen zu Diaspora aktiveren' share_diaspora: 'Teilen zu Diaspora aktiveren'
share_mail: 'Teilen via E-Mail aktiveren' share_mail: 'Teilen via E-Mail aktiveren'
share_shaarli: 'Teilen zu Shaarli aktiveren' share_shaarli: 'Teilen zu Shaarli aktiveren'
@ -34,3 +36,4 @@ share_public: 'Erlaube eine öffentliche URL für Einträge'
download_images_enabled: 'Bilder lokal herunterladen' download_images_enabled: 'Bilder lokal herunterladen'
restricted_access: 'Authentifizierung für Webseiten mit Paywall aktivieren' restricted_access: 'Authentifizierung für Webseiten mit Paywall aktivieren'
api_user_registration: 'Registrierung eines Benutzers über die API ermöglichen' api_user_registration: 'Registrierung eines Benutzers über die API ermöglichen'
# store_article_headers: Enable if wallabag stores HTTP headers for each article

View file

@ -12,6 +12,8 @@ export_xml: Enable XML export
import_with_rabbitmq: Enable RabbitMQ to import data asynchronously import_with_rabbitmq: Enable RabbitMQ to import data asynchronously
import_with_redis: Enable Redis to import data asynchronously import_with_redis: Enable Redis to import data asynchronously
shaarli_url: Shaarli URL, if the service is enabled shaarli_url: Shaarli URL, if the service is enabled
scuttle_url: Scuttle URL, if the service is enabled
unmark_url: Unmark URL, if the service is enabled
share_diaspora: Enable share to diaspora* share_diaspora: Enable share to diaspora*
share_mail: Enable share by e-mail share_mail: Enable share by e-mail
share_shaarli: Enable sharing to Shaarli share_shaarli: Enable sharing to Shaarli
@ -34,3 +36,4 @@ share_public: Allow public URL for entries
download_images_enabled: Download images locally download_images_enabled: Download images locally
restricted_access: Enable authentication for paywalled websites restricted_access: Enable authentication for paywalled websites
api_user_registration: Enable user to be registered using the API api_user_registration: Enable user to be registered using the API
store_article_headers: Enable if wallabag stores HTTP headers for each article

View file

@ -12,6 +12,8 @@ export_xml: Activar exportación a XML
import_with_rabbitmq: Activar RabbitMQ para importar datos de forma asíncrona import_with_rabbitmq: Activar RabbitMQ para importar datos de forma asíncrona
import_with_redis: Activar Redis para importar datos de forma asíncrona import_with_redis: Activar Redis para importar datos de forma asíncrona
shaarli_url: URL de Shaarli, si el servicio está activado shaarli_url: URL de Shaarli, si el servicio está activado
scuttle_url: URL de Scuttle, si el servicio está activado
unmark_url: URL de Unmark, si el servicio está activado
share_diaspora: Activar compartir con Diaspora share_diaspora: Activar compartir con Diaspora
share_mail: Activar compartir con Email share_mail: Activar compartir con Email
share_shaarli: Activar compartir con Shaarli share_shaarli: Activar compartir con Shaarli
@ -34,3 +36,4 @@ share_public: Permitir URL pública para los artículos
download_images_enabled: Descargar imágenes localmente download_images_enabled: Descargar imágenes localmente
restricted_access: Activar autenticación para websites con paywall restricted_access: Activar autenticación para websites con paywall
# api_user_registration: Enable user to be registered using the API # api_user_registration: Enable user to be registered using the API
# store_article_headers: Enable if wallabag stores HTTP headers for each article

View file

@ -12,6 +12,8 @@ export_xml: فعال‌سازی برون‌سپاری به XML
# import_with_rabbitmq: Enable RabbitMQ to import data asynchronously # import_with_rabbitmq: Enable RabbitMQ to import data asynchronously
# import_with_redis: Enable Redis to import data asynchronously # import_with_redis: Enable Redis to import data asynchronously
shaarli_url: نشانی Shaarli، اگر فعال بود shaarli_url: نشانی Shaarli، اگر فعال بود
scuttle_url: نشانی Scuttle، اگر فعال بود
unmark_url: نشانی Unmark، اگر فعال بود
share_diaspora: فعال‌سازی هم‌رسانی به Diaspora share_diaspora: فعال‌سازی هم‌رسانی به Diaspora
share_mail: فعال‌سازی هم‌رسانی با ایمیل share_mail: فعال‌سازی هم‌رسانی با ایمیل
share_shaarli: فعال‌سازی هم‌رسانی به Shaarli share_shaarli: فعال‌سازی هم‌رسانی به Shaarli
@ -34,3 +36,4 @@ modify_settings: "اعمال"
# download_images_enabled: Download images locally # download_images_enabled: Download images locally
# restricted_access: Enable authentication for websites with paywall # restricted_access: Enable authentication for websites with paywall
# api_user_registration: Enable user to be registered using the API # api_user_registration: Enable user to be registered using the API
# store_article_headers: Enable if wallabag stores HTTP headers for each article

View file

@ -12,6 +12,8 @@ export_xml: Activer l'export XML
import_with_rabbitmq: Activer RabbitMQ pour gérer les imports de façon asynchrone import_with_rabbitmq: Activer RabbitMQ pour gérer les imports de façon asynchrone
import_with_redis: Activer Redis pour gérer les imports de façon asynchrone import_with_redis: Activer Redis pour gérer les imports de façon asynchrone
shaarli_url: URL de Shaarli, si le service Shaarli est activé shaarli_url: URL de Shaarli, si le service Shaarli est activé
scuttle_url: URL de Scuttle, si le service Scuttle est activé
unmark_url: URL de Unmark, si le service Unmark est activé
share_diaspora: Activer le partage vers Diaspora share_diaspora: Activer le partage vers Diaspora
share_mail: Activer le partage par email share_mail: Activer le partage par email
share_shaarli: Activer le partage vers Shaarli share_shaarli: Activer le partage vers Shaarli
@ -34,3 +36,4 @@ share_public: Autoriser une URL publique pour les articles
download_images_enabled: Télécharger les images en local download_images_enabled: Télécharger les images en local
restricted_access: Activer l'authentification pour les articles derrière un paywall restricted_access: Activer l'authentification pour les articles derrière un paywall
api_user_registration: Activer la création de compte depuis l'API api_user_registration: Activer la création de compte depuis l'API
store_article_headers: Activer le stockage des en-têtes HTTP de chaque article

View file

@ -12,6 +12,8 @@ export_xml: Abilita esportazione XML
# import_with_rabbitmq: Enable RabbitMQ to import data asynchronously # import_with_rabbitmq: Enable RabbitMQ to import data asynchronously
# import_with_redis: Enable Redis to import data asynchronously # import_with_redis: Enable Redis to import data asynchronously
shaarli_url: Shaarli URL, se il servizio è abilitato shaarli_url: Shaarli URL, se il servizio è abilitato
scuttle_url: Scuttle URL, se il servizio è abilitato
unmark_url: Unmark URL, se il servizio è abilitato
share_diaspora: Abilita la condivisione con Diaspora share_diaspora: Abilita la condivisione con Diaspora
share_mail: Abilita la condivisione per email share_mail: Abilita la condivisione per email
share_shaarli: Abilita la condivisione con Shaarli share_shaarli: Abilita la condivisione con Shaarli
@ -34,3 +36,4 @@ demo_mode_username: "Utente Demo"
# download_images_enabled: Download images locally # download_images_enabled: Download images locally
# restricted_access: Enable authentication for websites with paywall # restricted_access: Enable authentication for websites with paywall
api_user_registration: Abilita la registrazione dell'utente attraverso l'API api_user_registration: Abilita la registrazione dell'utente attraverso l'API
# store_article_headers: Enable if wallabag stores HTTP headers for each article

View file

@ -12,6 +12,8 @@ export_xml: Activar l'expòrt XML
import_with_rabbitmq: Activar RabbitMQ per importar de donadas de manièra asincròna import_with_rabbitmq: Activar RabbitMQ per importar de donadas de manièra asincròna
import_with_redis: Activar Redis per importar de donadas de manièra asincròna import_with_redis: Activar Redis per importar de donadas de manièra asincròna
shaarli_url: URL de Shaarli, se lo servici Shaarli es activat shaarli_url: URL de Shaarli, se lo servici Shaarli es activat
scuttle_url: URL de Scuttle, se lo servici Scuttle es activat
unmark_url: URL de Unmark, se lo servici Scuttle es activat
share_diaspora: Activar lo partatge cap a Diaspora* share_diaspora: Activar lo partatge cap a Diaspora*
share_mail: Activar lo partatge per corrièl share_mail: Activar lo partatge per corrièl
share_shaarli: Activar lo partatge cap a Shaarli share_shaarli: Activar lo partatge cap a Shaarli
@ -34,3 +36,4 @@ share_public: Autorizar una URL publica pels articles
download_images_enabled: Telecargar los imatges en local download_images_enabled: Telecargar los imatges en local
restricted_access: Activar l'autenticacion pels sites amb peatge restricted_access: Activar l'autenticacion pels sites amb peatge
api_user_registration: Autorizar los utilizaires a se marcar amb l'API api_user_registration: Autorizar los utilizaires a se marcar amb l'API
# store_article_headers: Enable if wallabag stores HTTP headers for each article

View file

@ -12,6 +12,7 @@ export_xml: Włącz eksport do XML
import_with_rabbitmq: Włącz RabbitMQ dla asynchronicznego importu danych import_with_rabbitmq: Włącz RabbitMQ dla asynchronicznego importu danych
import_with_redis: Włącz Redis dla asynchronicznego importu danych import_with_redis: Włącz Redis dla asynchronicznego importu danych
shaarli_url: Adress URL Shaarli, jeżeli usługa jest włączona shaarli_url: Adress URL Shaarli, jeżeli usługa jest włączona
scuttle_url: Adress URL Scuttle, jeżeli usługa jest włączona
share_diaspora: Włącz udostępnianie dla Diaspora share_diaspora: Włącz udostępnianie dla Diaspora
share_mail: Włącz udostępnianie przez email share_mail: Włącz udostępnianie przez email
share_shaarli: Włącz udostępnianie dla Shaarli share_shaarli: Włącz udostępnianie dla Shaarli
@ -34,3 +35,4 @@ share_public: Zezwalaj na publiczny adres url dla wpisow
download_images_enabled: Pobierz obrazy lokalnie download_images_enabled: Pobierz obrazy lokalnie
restricted_access: Włącz autoryzację dla stron z paywallem restricted_access: Włącz autoryzację dla stron z paywallem
api_user_registration: Włącz rejestrację użytkownika przy użyciu API api_user_registration: Włącz rejestrację użytkownika przy użyciu API
# store_article_headers: Enable if wallabag stores HTTP headers for each article

View file

@ -12,6 +12,8 @@ export_xml: Habilita exportação para XML
# import_with_rabbitmq: Enable RabbitMQ to import data asynchronously # import_with_rabbitmq: Enable RabbitMQ to import data asynchronously
# import_with_redis: Enable Redis to import data asynchronously # import_with_redis: Enable Redis to import data asynchronously
shaarli_url: URL Shaarli, se o serviço está habilitado shaarli_url: URL Shaarli, se o serviço está habilitado
scuttle_url: URL Scuttle, se o serviço está habilitado
unmark_url: URL Unmark, se o serviço está habilitado
share_diaspora: Habilitar compartilhamento para o Diaspora share_diaspora: Habilitar compartilhamento para o Diaspora
share_mail: Habilitar compartilhamento por e-mail share_mail: Habilitar compartilhamento por e-mail
share_shaarli: Habilitar compartilhamento para o Shaarli share_shaarli: Habilitar compartilhamento para o Shaarli
@ -34,3 +36,4 @@ demo_mode_username: "Usuário demo"
# download_images_enabled: Download images locally # download_images_enabled: Download images locally
# restricted_access: Enable authentication for websites with paywall # restricted_access: Enable authentication for websites with paywall
# api_user_registration: Enable user to be registered using the API # api_user_registration: Enable user to be registered using the API
# store_article_headers: Enable if wallabag stores HTTP headers for each article

View file

@ -12,6 +12,8 @@ export_xml: Permite exportare XML
# import_with_rabbitmq: Enable RabbitMQ to import data asynchronously # import_with_rabbitmq: Enable RabbitMQ to import data asynchronously
# import_with_redis: Enable Redis to import data asynchronously # import_with_redis: Enable Redis to import data asynchronously
shaarli_url: Shaarli URL, dacă serviciul este permis shaarli_url: Shaarli URL, dacă serviciul este permis
scuttle_url: Scuttle URL, dacă serviciul este permis
unmark_url: Unmark URL, dacă serviciul este permis
share_diaspora: Permite share către Diaspora share_diaspora: Permite share către Diaspora
share_mail: Permite share prin email share_mail: Permite share prin email
share_shaarli: Permite share către Shaarli share_shaarli: Permite share către Shaarli
@ -34,3 +36,4 @@ modify_settings: "aplică"
# download_images_enabled: Download images locally # download_images_enabled: Download images locally
# restricted_access: Enable authentication for websites with paywall # restricted_access: Enable authentication for websites with paywall
# api_user_registration: Enable user to be registered using the API # api_user_registration: Enable user to be registered using the API
# store_article_headers: Enable if wallabag stores HTTP headers for each article

View file

@ -12,6 +12,8 @@ export_xml: "Включить XML экспорт"
import_with_rabbitmq: "Включить RabbitMQ для импорта данных(асинхронно)" import_with_rabbitmq: "Включить RabbitMQ для импорта данных(асинхронно)"
import_with_redis: "Включить Redis для импорта данных(асинхронно)" import_with_redis: "Включить Redis для импорта данных(асинхронно)"
shaarli_url: "Shaarli URL, если сервис включен" shaarli_url: "Shaarli URL, если сервис включен"
scuttle_url: "Scuttle URL, если сервис включен"
unmark_url: "Unmark URL, если сервис включен"
share_diaspora: "Включить возможность поделиться в соц.сети Diaspora" share_diaspora: "Включить возможность поделиться в соц.сети Diaspora"
share_mail: "Включить возможность поделиться по email" share_mail: "Включить возможность поделиться по email"
share_shaarli: "Включить возможность поделиться в Shaarli" share_shaarli: "Включить возможность поделиться в Shaarli"
@ -33,3 +35,5 @@ demo_mode_username: "Демо пользователь"
share_public: "Разрешить публичные ссылки на записи" share_public: "Разрешить публичные ссылки на записи"
download_images_enabled: "Скачивать изображения локально" download_images_enabled: "Скачивать изображения локально"
restricted_access: "Включить авторизацию на сайте с помощью paywall" restricted_access: "Включить авторизацию на сайте с помощью paywall"
# api_user_registration: Enable user to be registered using the API
# store_article_headers: Enable if wallabag stores HTTP headers for each article

View file

@ -12,6 +12,8 @@
# import_with_rabbitmq: Enable RabbitMQ to import data asynchronously # import_with_rabbitmq: Enable RabbitMQ to import data asynchronously
# import_with_redis: Enable Redis to import data asynchronously # import_with_redis: Enable Redis to import data asynchronously
# shaarli_url: Shaarli URL, if the service is enabled # shaarli_url: Shaarli URL, if the service is enabled
# scuttle_url: Scuttle URL, if the service is enabled
# unmark_url: Unmark URL, if the service is enabled
# share_diaspora: Enable share to Diaspora # share_diaspora: Enable share to Diaspora
# share_mail: Enable share by email # share_mail: Enable share by email
# share_shaarli: Enable share to Shaarli # share_shaarli: Enable share to Shaarli
@ -35,3 +37,4 @@
# download_images_enabled: Download images locally # download_images_enabled: Download images locally
# restricted_access: Enable authentication for websites with paywall # restricted_access: Enable authentication for websites with paywall
# api_user_registration: Enable user to be registered using the API # api_user_registration: Enable user to be registered using the API
# store_article_headers: Enable if wallabag stores HTTP headers for each article

View file

@ -153,6 +153,10 @@ wallabag_core:
name: api_user_registration name: api_user_registration
value: 0 value: 0
section: api section: api
-
name: store_article_headers
value: 0
section: entry
wallabag_user: wallabag_user:
registration_enabled: "%fosuser_registration%" registration_enabled: "%fosuser_registration%"

View file

@ -24,8 +24,9 @@ class ContentProxy
protected $mimeGuesser; protected $mimeGuesser;
protected $fetchingErrorMessage; protected $fetchingErrorMessage;
protected $eventDispatcher; protected $eventDispatcher;
protected $storeArticleHeaders;
public function __construct(Graby $graby, RuleBasedTagger $tagger, ValidatorInterface $validator, LoggerInterface $logger, $fetchingErrorMessage) public function __construct(Graby $graby, RuleBasedTagger $tagger, ValidatorInterface $validator, LoggerInterface $logger, $fetchingErrorMessage, $storeArticleHeaders = false)
{ {
$this->graby = $graby; $this->graby = $graby;
$this->tagger = $tagger; $this->tagger = $tagger;
@ -33,6 +34,7 @@ class ContentProxy
$this->logger = $logger; $this->logger = $logger;
$this->mimeGuesser = new MimeTypeExtensionGuesser(); $this->mimeGuesser = new MimeTypeExtensionGuesser();
$this->fetchingErrorMessage = $fetchingErrorMessage; $this->fetchingErrorMessage = $fetchingErrorMessage;
$this->storeArticleHeaders = $storeArticleHeaders;
} }
/** /**
@ -185,7 +187,7 @@ class ContentProxy
$entry->setPublishedBy($content['authors']); $entry->setPublishedBy($content['authors']);
} }
if (!empty($content['all_headers'])) { if (!empty($content['all_headers']) && $this->storeArticleHeaders) {
$entry->setHeaders($content['all_headers']); $entry->setHeaders($content['all_headers']);
} }

View file

@ -94,6 +94,7 @@ services:
- "@validator" - "@validator"
- "@logger" - "@logger"
- '%wallabag_core.fetching_error_message%' - '%wallabag_core.fetching_error_message%'
- '@=service(''craue_config'').get(''store_article_headers'')'
wallabag_core.tags_assigner: wallabag_core.tags_assigner:
class: Wallabag\CoreBundle\Helper\TagsAssigner class: Wallabag\CoreBundle\Helper\TagsAssigner

View file

@ -137,6 +137,8 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->logInAs('admin'); $this->logInAs('admin');
$client = $this->getClient(); $client = $this->getClient();
$client->getContainer()->get('craue_config')->set('store_article_headers', 1);
$crawler = $client->request('GET', '/new'); $crawler = $client->request('GET', '/new');
$this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertSame(200, $client->getResponse()->getStatusCode());
@ -165,6 +167,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->assertSame('2015-03-28 11:43:19', $content->getPublishedAt()->format('Y-m-d H:i:s')); $this->assertSame('2015-03-28 11:43:19', $content->getPublishedAt()->format('Y-m-d H:i:s'));
$this->assertSame('Morgane Tual', $author[0]); $this->assertSame('Morgane Tual', $author[0]);
$this->assertArrayHasKey('x-varnish1', $content->getHeaders()); $this->assertArrayHasKey('x-varnish1', $content->getHeaders());
$client->getContainer()->get('craue_config')->set('store_article_headers', 0);
} }
public function testPostWithMultipleAuthors() public function testPostWithMultipleAuthors()

View file

@ -311,7 +311,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
$tagger->expects($this->once()) $tagger->expects($this->once())
->method('tag'); ->method('tag');
$proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage, true);
$entry = new Entry(new User()); $entry = new Entry(new User());
$proxy->updateEntry( $proxy->updateEntry(
$entry, $entry,
@ -341,6 +341,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
$this->assertContains('Jeremy', $entry->getPublishedBy()); $this->assertContains('Jeremy', $entry->getPublishedBy());
$this->assertContains('Nico', $entry->getPublishedBy()); $this->assertContains('Nico', $entry->getPublishedBy());
$this->assertContains('Thomas', $entry->getPublishedBy()); $this->assertContains('Thomas', $entry->getPublishedBy());
$this->assertNotNull($entry->getHeaders(), 'Headers are stored, so value is not null');
$this->assertContains('no-cache', $entry->getHeaders()); $this->assertContains('no-cache', $entry->getHeaders());
} }