diff --git a/app/DoctrineMigrations/Version20230613121354.php b/app/DoctrineMigrations/Version20230613121354.php new file mode 100644 index 000000000..07a70a182 --- /dev/null +++ b/app/DoctrineMigrations/Version20230613121354.php @@ -0,0 +1,30 @@ +getTable($this->getTable('config')); + + $this->skipIf($configTable->hasColumn('display_thumbnails'), 'It seems that you already played this migration.'); + + $configTable->addColumn('display_thumbnails', 'integer', [ + 'default' => 1, + 'notnull' => false, + ]); + } + + public function down(Schema $schema): void + { + $configTable = $schema->getTable($this->getTable('config')); + $configTable->dropColumn('display_thumbnails'); + } +} diff --git a/app/config/services.yml b/app/config/services.yml index d63413d48..eb5d0e4e2 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -300,6 +300,7 @@ services: $readingSpeed: "%wallabag_core.reading_speed%" $actionMarkAsRead: "%wallabag_core.action_mark_as_read%" $listMode: "%wallabag_core.list_mode%" + $displayThumbnails: "%wallabag_core.display_thumbnails%" Wallabag\UserBundle\EventListener\AuthenticationFailureListener: tags: diff --git a/app/config/wallabag.yml b/app/config/wallabag.yml index 7643d06ac..8339348fe 100644 --- a/app/config/wallabag.yml +++ b/app/config/wallabag.yml @@ -30,6 +30,7 @@ wallabag_core: cache_lifetime: 10 action_mark_as_read: 1 list_mode: 0 + display_thumbnails: 1 fetching_error_message_title: 'No title found' fetching_error_message: | wallabag can't retrieve contents for this article. Please troubleshoot this issue. diff --git a/src/Wallabag/CoreBundle/DataFixtures/ConfigFixtures.php b/src/Wallabag/CoreBundle/DataFixtures/ConfigFixtures.php index a8a1a78ae..77809f95b 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ConfigFixtures.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ConfigFixtures.php @@ -23,6 +23,7 @@ class ConfigFixtures extends Fixture implements DependentFixtureInterface $adminConfig->setPocketConsumerKey('xxxxx'); $adminConfig->setActionMarkAsRead(0); $adminConfig->setListMode(0); + $adminConfig->setDisplayThumbnails(0); $manager->persist($adminConfig); @@ -35,6 +36,7 @@ class ConfigFixtures extends Fixture implements DependentFixtureInterface $bobConfig->setPocketConsumerKey(null); $bobConfig->setActionMarkAsRead(1); $bobConfig->setListMode(1); + $bobConfig->setDisplayThumbnails(1); $manager->persist($bobConfig); @@ -47,6 +49,7 @@ class ConfigFixtures extends Fixture implements DependentFixtureInterface $emptyConfig->setPocketConsumerKey(null); $emptyConfig->setActionMarkAsRead(0); $emptyConfig->setListMode(0); + $emptyConfig->setDisplayThumbnails(0); $manager->persist($emptyConfig); diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index fa31ecda4..91ea7a326 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php @@ -46,6 +46,9 @@ class Configuration implements ConfigurationInterface ->scalarNode('list_mode') ->defaultValue(1) ->end() + ->scalarNode('display_thumbnails') + ->defaultValue(1) + ->end() ->scalarNode('api_limit_mass_actions') ->defaultValue(10) ->end() diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php index 648595a7c..0eabaa075 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php @@ -22,6 +22,7 @@ class WallabagCoreExtension extends Extension $container->setParameter('wallabag_core.cache_lifetime', $config['cache_lifetime']); $container->setParameter('wallabag_core.action_mark_as_read', $config['action_mark_as_read']); $container->setParameter('wallabag_core.list_mode', $config['list_mode']); + $container->setParameter('wallabag_core.display_thumbnails', $config['display_thumbnails']); $container->setParameter('wallabag_core.fetching_error_message', $config['fetching_error_message']); $container->setParameter('wallabag_core.fetching_error_message_title', $config['fetching_error_message_title']); $container->setParameter('wallabag_core.api_limit_mass_actions', $config['api_limit_mass_actions']); diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index 9b47c23a8..854335d0d 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php @@ -117,6 +117,15 @@ class Config */ private $listMode; + /** + * @var int + * + * @ORM\Column(name="display_thumbnails", type="integer", nullable=true) + * + * @Groups({"config_api"}) + */ + private $displayThumbnails; + /** * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="config") */ @@ -362,6 +371,26 @@ class Config return $this; } + /** + * @return bool + */ + public function getDisplayThumbnails(): ?bool + { + return $this->displayThumbnails; + } + + /** + * @param bool $displayThumbnails + * + * @return Config + */ + public function setDisplayThumbnails(bool $displayThumbnails) + { + $this->displayThumbnails = $displayThumbnails; + + return $this; + } + /** * @return Config */ diff --git a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php index ae8714084..8f63551fc 100644 --- a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php +++ b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php @@ -3,6 +3,7 @@ namespace Wallabag\CoreBundle\Form\Type; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\IntegerType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; @@ -29,6 +30,11 @@ class ConfigType extends AbstractType 'label' => 'config.form_settings.items_per_page_label', 'property_path' => 'itemsPerPage', ]) + ->add('display_thumbnails', CheckboxType::class, [ + 'label' => 'config.form_settings.display_thumbnails_label', + 'property_path' => 'displayThumbnails', + 'required' => false, + ]) ->add('reading_speed', IntegerType::class, [ 'label' => 'config.form_settings.reading_speed.label', 'property_path' => 'readingSpeed', diff --git a/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig index 134e623d6..ddee13faa 100644 --- a/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig @@ -38,6 +38,19 @@ +