From bc78968764c741019a6b866ad434678cdbecbba4 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist <jeremy.benoist@gmail.com> Date: Wed, 20 Jan 2016 19:54:57 +0100 Subject: [PATCH 01/13] Move default configuration out of parameters These default configuration value shouldn't be in parameters.yml. --- app/config/config.yml | 4 ++++ app/config/parameters.yml.dist | 7 ------- app/config/tests/parameters.yml.dist.mysql | 7 ------- app/config/tests/parameters.yml.dist.pgsql | 7 ------- app/config/tests/parameters.yml.dist.sqlite | 7 ------- src/Wallabag/CoreBundle/Command/InstallCommand.php | 8 ++++---- .../CoreBundle/Controller/ConfigController.php | 8 ++++---- .../CoreBundle/DependencyInjection/Configuration.php | 12 ++++++++++++ .../DependencyInjection/WallabagCoreExtension.php | 5 +++++ .../CoreBundle/Resources/config/services.yml | 8 ++++---- 10 files changed, 33 insertions(+), 40 deletions(-) diff --git a/app/config/config.yml b/app/config/config.yml index a6cfc67d6..943365e87 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -33,6 +33,10 @@ wallabag_core: fr: 'Français' de: 'Deutsch' tr: 'Türkçe' + items_on_page: 12 + theme: material + language: en + rss_limit: 50 wallabag_import: allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain'] diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index e4fcbd743..f9555676e 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -68,12 +68,5 @@ parameters: wallabag_url: http://v2.wallabag.org wallabag_support_url: 'https://www.wallabag.org/pages/support.html' - # default user config - items_on_page: 12 - theme: material - language: en - from_email: no-reply@wallabag.org - rss_limit: 50 - # pocket import pocket_consumer_key: xxxxxxxx diff --git a/app/config/tests/parameters.yml.dist.mysql b/app/config/tests/parameters.yml.dist.mysql index f902f2395..e0e92760b 100644 --- a/app/config/tests/parameters.yml.dist.mysql +++ b/app/config/tests/parameters.yml.dist.mysql @@ -58,12 +58,5 @@ parameters: wallabag_url: http://v2.wallabag.org wallabag_support_url: 'https://www.wallabag.org/pages/support.html' - # default user config - items_on_page: 12 - theme: material - language: en_US - from_email: no-reply@wallabag.org - rss_limit: 50 - # pocket import pocket_consumer_key: xxxxxxxx diff --git a/app/config/tests/parameters.yml.dist.pgsql b/app/config/tests/parameters.yml.dist.pgsql index 76685b141..e6e7636c1 100644 --- a/app/config/tests/parameters.yml.dist.pgsql +++ b/app/config/tests/parameters.yml.dist.pgsql @@ -58,12 +58,5 @@ parameters: wallabag_url: http://v2.wallabag.org wallabag_support_url: 'https://www.wallabag.org/pages/support.html' - # default user config - items_on_page: 12 - theme: material - language: en_US - from_email: no-reply@wallabag.org - rss_limit: 50 - # pocket import pocket_consumer_key: xxxxxxxx diff --git a/app/config/tests/parameters.yml.dist.sqlite b/app/config/tests/parameters.yml.dist.sqlite index cdafb1b1b..c47392a38 100644 --- a/app/config/tests/parameters.yml.dist.sqlite +++ b/app/config/tests/parameters.yml.dist.sqlite @@ -58,12 +58,5 @@ parameters: wallabag_url: http://v2.wallabag.org wallabag_support_url: 'https://www.wallabag.org/pages/support.html' - # default user config - items_on_page: 12 - theme: material - language: en_US - from_email: no-reply@wallabag.org - rss_limit: 50 - # pocket import pocket_consumer_key: xxxxxxxx diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index da099a19b..7a7e3a643 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -205,10 +205,10 @@ class InstallCommand extends ContainerAwareCommand $em->persist($user); $config = new Config($user); - $config->setTheme($this->getContainer()->getParameter('theme')); - $config->setItemsPerPage($this->getContainer()->getParameter('items_on_page')); - $config->setRssLimit($this->getContainer()->getParameter('rss_limit')); - $config->setLanguage($this->getContainer()->getParameter('language')); + $config->setTheme($this->getContainer()->getParameter('wallabag_core.theme')); + $config->setItemsPerPage($this->getContainer()->getParameter('wallabag_core.items_on_page')); + $config->setRssLimit($this->getContainer()->getParameter('wallabag_core.rss_limit')); + $config->setLanguage($this->getContainer()->getParameter('wallabag_core.language')); $em->persist($config); diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 6c375909c..4ece64312 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -133,10 +133,10 @@ class ConfigController extends Controller $userManager->updateUser($newUser, true); $config = new Config($newUser); - $config->setTheme($this->container->getParameter('theme')); - $config->setItemsPerPage($this->container->getParameter('items_on_page')); - $config->setRssLimit($this->container->getParameter('rss_limit')); - $config->setLanguage($this->container->getParameter('language')); + $config->setTheme($this->container->getParameter('wallabag_core.theme')); + $config->setItemsPerPage($this->container->getParameter('wallabag_core.items_on_page')); + $config->setRssLimit($this->container->getParameter('wallabag_core.rss_limit')); + $config->setLanguage($this->container->getParameter('wallabag_core.language')); $em->persist($config); diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index 32acd1f17..4d5a63f86 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php @@ -17,6 +17,18 @@ class Configuration implements ConfigurationInterface ->arrayNode('languages') ->prototype('scalar')->end() ->end() + ->integerNode('items_on_page') + ->defaultValue(12) + ->end() + ->scalarNode('theme') + ->defaultValue('material') + ->end() + ->scalarNode('language') + ->defaultValue('en') + ->end() + ->integerNode('rss_limit') + ->defaultValue(50) + ->end() ->end() ; diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php index 9ff9b732f..73bbffe11 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php @@ -13,7 +13,12 @@ class WallabagCoreExtension extends Extension { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); + $container->setParameter('wallabag_core.languages', $config['languages']); + $container->setParameter('wallabag_core.items_on_page', $config['items_on_page']); + $container->setParameter('wallabag_core.theme', $config['theme']); + $container->setParameter('wallabag_core.language', $config['language']); + $container->setParameter('wallabag_core.rss_limit', $config['rss_limit']); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index 25d71cba0..6a1afcc00 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml @@ -76,10 +76,10 @@ services: class: Wallabag\CoreBundle\EventListener\RegistrationConfirmedListener arguments: - "@doctrine.orm.entity_manager" - - %theme% - - %items_on_page% - - %rss_limit% - - %language% + - %wallabag_core.theme% + - %wallabag_core.items_on_page% + - %wallabag_core.rss_limit% + - %wallabag_core.language% tags: - { name: kernel.event_subscriber } From 26975877d76a99f6a3153d3d3b4fc6c9f32687bc Mon Sep 17 00:00:00 2001 From: Jeremy Benoist <jeremy.benoist@gmail.com> Date: Wed, 20 Jan 2016 20:00:12 +0100 Subject: [PATCH 02/13] Always include warning message We'll remove it later, on the stable release --- app/config/config.yml | 1 - app/config/parameters.yml.dist | 4 ---- app/config/tests/parameters.yml.dist.mysql | 4 ---- app/config/tests/parameters.yml.dist.pgsql | 4 ---- app/config/tests/parameters.yml.dist.sqlite | 4 ---- .../CoreBundle/Resources/views/base.html.twig | 4 +--- .../views/themes/material/Config/index.html.twig | 16 ++++++++-------- 7 files changed, 9 insertions(+), 28 deletions(-) diff --git a/app/config/config.yml b/app/config/config.yml index 943365e87..58e1dd666 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -67,7 +67,6 @@ twig: export_xml: %export_xml% version: %app.version% twofactor_auth: %twofactor_auth% - warning_message: %warning_message% paypal_url: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9UBA65LG3FX9Y&lc=gb" form_themes: - "LexikFormFilterBundle:Form:form_div_layout.html.twig" diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index f9555676e..52d26cb4d 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -42,10 +42,6 @@ parameters: twofactor_auth: true twofactor_sender: no-reply@wallabag.org - # message to display at the bottom of the page - warning_message: > - You're trying wallabag v2, which is in alpha version. If you find a bug, please have a look to <a href="https://github.com/wallabag/wallabag/issues">our issues list</a> and <a href="https://github.com/wallabag/wallabag/issues/new">open a new if necessary</a> - download_pictures: false # if true, pictures will be stored into data/assets for each article # Entry view diff --git a/app/config/tests/parameters.yml.dist.mysql b/app/config/tests/parameters.yml.dist.mysql index e0e92760b..073f6c27e 100644 --- a/app/config/tests/parameters.yml.dist.mysql +++ b/app/config/tests/parameters.yml.dist.mysql @@ -32,10 +32,6 @@ parameters: twofactor_auth: true twofactor_sender: no-reply@wallabag.org - # message to display at the bottom of the page - warning_message: > - You're trying wallabag v2, which is in alpha version. If you find a bug, please have a look to <a href="https://github.com/wallabag/wallabag/issues">our issues list</a> and <a href="https://github.com/wallabag/wallabag/issues/new">open a new if necessary</a> - download_pictures: false # if true, pictures will be stored into data/assets for each article # Entry view diff --git a/app/config/tests/parameters.yml.dist.pgsql b/app/config/tests/parameters.yml.dist.pgsql index e6e7636c1..24a1818a8 100644 --- a/app/config/tests/parameters.yml.dist.pgsql +++ b/app/config/tests/parameters.yml.dist.pgsql @@ -32,10 +32,6 @@ parameters: twofactor_auth: true twofactor_sender: no-reply@wallabag.org - # message to display at the bottom of the page - warning_message: > - You're trying wallabag v2, which is in alpha version. If you find a bug, please have a look to <a href="https://github.com/wallabag/wallabag/issues">our issues list</a> and <a href="https://github.com/wallabag/wallabag/issues/new">open a new if necessary</a> - download_pictures: false # if true, pictures will be stored into data/assets for each article # Entry view diff --git a/app/config/tests/parameters.yml.dist.sqlite b/app/config/tests/parameters.yml.dist.sqlite index c47392a38..c739f89b0 100644 --- a/app/config/tests/parameters.yml.dist.sqlite +++ b/app/config/tests/parameters.yml.dist.sqlite @@ -32,10 +32,6 @@ parameters: twofactor_auth: true twofactor_sender: no-reply@wallabag.org - # message to display at the bottom of the page - warning_message: > - You're trying wallabag v2, which is in alpha version. If you find a bug, please have a look to <a href="https://github.com/wallabag/wallabag/issues">our issues list</a> and <a href="https://github.com/wallabag/wallabag/issues/new">open a new if necessary</a> - download_pictures: false # if true, pictures will be stored into data/assets for each article # Entry view diff --git a/src/Wallabag/CoreBundle/Resources/views/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig index 9e515a178..1742b4aa6 100644 --- a/src/Wallabag/CoreBundle/Resources/views/base.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig @@ -68,10 +68,8 @@ {% block footer %}{% endblock %} - {% if warning_message %} <div id="warning_message"> - {{ warning_message | raw }} + You're trying wallabag v2, which is in alpha version. If you find a bug, please have a look to <a href="https://github.com/wallabag/wallabag/issues">our issues list</a> and <a href="https://github.com/wallabag/wallabag/issues/new">open a new if necessary</a> </div> - {% endif %} </body> </html> 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 8743dc1dd..1cae90a41 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 @@ -11,14 +11,14 @@ <div class="row"> <div class="div_tabs col s12"> <ul class="tabs"> - <li class="tab col s3"><a class="active" href="#set1">{% trans %}Settings{% endtrans %}</a></li> - <li class="tab col s3"><a href="#set2">{% trans %}RSS{% endtrans %}</a></li> - <li class="tab col s3"><a href="#set3">{% trans %}User information{% endtrans %}</a></li> - <li class="tab col s3"><a href="#set4">{% trans %}Password{% endtrans %}</a></li> - <li class="tab col s3"><a href="#set5">{% trans %}Tagging rules{% endtrans %}</a></li> - {% if is_granted('ROLE_SUPER_ADMIN') %} - <li class="tab col s3"><a href="#set6">{% trans %}Add a user{% endtrans %}</a></li> - {% endif %} + <li class="tab col s3"><a class="active" href="#set1">{% trans %}Settings{% endtrans %}</a></li> + <li class="tab col s3"><a href="#set2">{% trans %}RSS{% endtrans %}</a></li> + <li class="tab col s3"><a href="#set3">{% trans %}User information{% endtrans %}</a></li> + <li class="tab col s3"><a href="#set4">{% trans %}Password{% endtrans %}</a></li> + <li class="tab col s3"><a href="#set5">{% trans %}Tagging rules{% endtrans %}</a></li> + {% if is_granted('ROLE_SUPER_ADMIN') %} + <li class="tab col s3"><a href="#set6">{% trans %}Add a user{% endtrans %}</a></li> + {% endif %} </ul> </div> From 63e40f2d7c4074aff0be587c828eb511a6b7c878 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist <jeremy.benoist@gmail.com> Date: Thu, 21 Jan 2016 08:53:09 +0100 Subject: [PATCH 03/13] Add CraueConfig for internal settings --- app/AppKernel.php | 1 + .../Version20160120200534_settings.php | 51 +++++++++++++++++++ .../translations/CraueConfigBundle.en.yml | 15 ++++++ .../translations/CraueConfigBundle.fr.yml | 15 ++++++ .../views/Settings/modify.html.twig | 43 ++++++++++++++++ app/config/config.yml | 24 +-------- app/config/parameters.yml.dist | 28 +--------- app/config/routing.yml | 9 +++- app/config/security.yml | 1 + app/config/tests/parameters.yml.dist.mysql | 28 +--------- app/config/tests/parameters.yml.dist.pgsql | 28 +--------- app/config/tests/parameters.yml.dist.sqlite | 28 +--------- composer.json | 5 +- .../Controller/ConfigController.php | 1 + .../Controller/StaticController.php | 5 +- .../DependencyInjection/Configuration.php | 4 ++ .../WallabagCoreExtension.php | 2 + .../CoreBundle/Helper/EntriesExport.php | 7 +-- .../CoreBundle/Resources/config/services.yml | 4 +- .../Resources/translations/messages.fr.yml | 1 + .../views/themes/baggy/Entry/entry.html.twig | 19 ++++--- .../views/themes/baggy/layout.html.twig | 3 ++ .../themes/material/Entry/entry.html.twig | 25 +++++---- .../views/themes/material/layout.html.twig | 3 ++ .../ImportBundle/Import/PocketImport.php | 5 +- .../Resources/config/services.yml | 2 +- .../Tests/Import/PocketImportTest.php | 11 +++- .../UserBundle/Mailer/AuthCodeMailer.php | 10 ++-- .../UserBundle/Resources/config/services.yml | 3 +- 29 files changed, 208 insertions(+), 173 deletions(-) create mode 100644 app/DoctrineMigrations/Version20160120200534_settings.php create mode 100644 app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml create mode 100644 app/Resources/CraueConfigBundle/translations/CraueConfigBundle.fr.yml create mode 100644 app/Resources/CraueConfigBundle/views/Settings/modify.html.twig diff --git a/app/AppKernel.php b/app/AppKernel.php index 7e76a9e90..82d3aa38e 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -33,6 +33,7 @@ class AppKernel extends Kernel new KPhoen\RulerZBundle\KPhoenRulerZBundle(), new Wallabag\ImportBundle\WallabagImportBundle(), new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), + new Craue\ConfigBundle\CraueConfigBundle(), ]; if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { diff --git a/app/DoctrineMigrations/Version20160120200534_settings.php b/app/DoctrineMigrations/Version20160120200534_settings.php new file mode 100644 index 000000000..34809ff9d --- /dev/null +++ b/app/DoctrineMigrations/Version20160120200534_settings.php @@ -0,0 +1,51 @@ +<?php + +namespace Application\Migrations; + +use Doctrine\DBAL\Migrations\AbstractMigration; +use Doctrine\DBAL\Schema\Schema; + +/** + * Auto-generated Migration: Please modify to your needs! + */ +class Version20160120200534_settings extends AbstractMigration +{ + /** + * @param Schema $schema + */ + public function up(Schema $schema) + { + // this up() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('CREATE TABLE craue_config_setting (name VARCHAR(255) NOT NULL, value VARCHAR(255) DEFAULT NULL, section VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_B95BA9425E237E06 (name), PRIMARY KEY(name)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); + $this->addSql("INSERT INTO `craue_config_setting` (`name`, `value`, `section`) VALUES + ('download_pictures', '1', 'entry'), + ('carrot', '1', 'entry'), + ('share_diaspora', '1', 'entry'), + ('diaspora_url', 'http://diasporapod.com', 'entry'), + ('share_shaarli', '1', 'entry'), + ('shaarli_url', 'http://myshaarli.com', 'entry'), + ('share_mail', '1', 'entry'), + ('share_twitter', '1', 'entry'), + ('export_epub', '1', 'export'), + ('export_mobi', '1', 'export'), + ('export_pdf', '1', 'export'), + ('pocket_consumer_key', NULL, 'import'), + ('show_printlink', '1', 'entry'), + ('wallabag_support_url', 'https://www.wallabag.org/pages/support.html', 'misc'), + ('wallabag_url', 'http://v2.wallabag.org', 'misc')" + ); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('DROP TABLE craue_config_setting'); + } +} diff --git a/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml new file mode 100644 index 000000000..ea90460e0 --- /dev/null +++ b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml @@ -0,0 +1,15 @@ +download_pictures: Download pictures on your server +carrot: Enable share to Carrot +diaspora_url: Diaspora URL, if the service is enabled +export_epub: Enable ePub export +export_mobi: Enable .mobi export +export_pdf: Enable PDF export +pocket_consumer_key: Consumer key for Pocket to import contents (https://getpocket.com/developer/docs/authentication) +shaarli_url: URL de Shaarli, if the service is enabled +share_diaspora: Enable share to Diaspora +share_mail: Enable share by email +share_shaarli: Enable share to Shaarli +share_twitter: Enable share to Twitter +show_printlink: Display a link to print content +wallabag_support_url: Support URL for wallabag +wallabag_url: URL of *your* wallabag instance diff --git a/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.fr.yml b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.fr.yml new file mode 100644 index 000000000..196000457 --- /dev/null +++ b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.fr.yml @@ -0,0 +1,15 @@ +download_pictures: Télécharger les images sur le serveur +carrot: Activer le partage vers Carrot +diaspora_url: URL de Diaspora, si le service Diaspora est activé +export_epub: Activer l'export ePub +export_mobi: Activer l'export .mobi +export_pdf: Activer l'export PDF +pocket_consumer_key: Clé d'authentification Pocket pour importer les données (https://getpocket.com/developer/docs/authentication) +shaarli_url: URL de Shaarli, si le service Diaspora est activé +share_diaspora: Activer le partage vers Diaspora +share_mail: Activer le partage par email +share_shaarli: Activer le partage vers Shaarli +share_twitter: Activer le partage vers Twitter +show_printlink: Afficher un lien pour imprimer +wallabag_support_url: URL de support de wallabag +wallabag_url: URL de *votre* instance de wallabag diff --git a/app/Resources/CraueConfigBundle/views/Settings/modify.html.twig b/app/Resources/CraueConfigBundle/views/Settings/modify.html.twig new file mode 100644 index 000000000..f44db420f --- /dev/null +++ b/app/Resources/CraueConfigBundle/views/Settings/modify.html.twig @@ -0,0 +1,43 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{% trans %}internal settings{% endtrans %}{% endblock %} + +{% block content %} + <div class="row"> + <div class="col s12"> + <div class="card-panel settings"> + {{ form_start(form, {'attr': {'class': 'craue_config_settings_modify'}}) }} + {{ form_errors(form) }} + + <div class="row"> + <div class="div_tabs col s12"> + <ul class="tabs"> + {% for section in sections | craue_sortSections %} + <li class="tab col s3"><a href="#set-{{ section }}">{{ section | trans({}, 'CraueConfigBundle') }}</a></li> + {% endfor %} + </ul> + </div> + + {% for section in sections | craue_sortSections %} + <div id="set-{{ section }}" class="col s12"> + {% for setting in form.settings if setting.section.vars.value == section %} + {{ form_row(setting.name) }} + {{ form_row(setting.section) }} + {{ form_row(setting.value, { + 'label': setting.name.vars.value | trans({}, 'CraueConfigBundle'), + }) }} + {% endfor %} + </div> + {% endfor %} + </div> + + <button class="btn waves-effect waves-light" type="submit" name="action"> + {{ 'modify_settings' | trans({}, 'CraueConfigBundle') }} + </button> + + {{ form_rest(form) }} + {{ form_end(form) }} + </div> + </div> + </div> +{% endblock %} diff --git a/app/config/config.yml b/app/config/config.yml index 58e1dd666..3c278ea63 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -28,6 +28,8 @@ framework: assets: ~ wallabag_core: + version: 2.0.0-alpha.1 + paypal_url: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9UBA65LG3FX9Y&lc=gb" languages: en: 'English' fr: 'Français' @@ -46,28 +48,6 @@ wallabag_import: twig: debug: "%kernel.debug%" strict_variables: "%kernel.debug%" - globals: - share_twitter: %share_twitter% - share_mail: %share_mail% - share_shaarli: %share_shaarli% - shaarli_url: %shaarli_url% - share_diaspora: %share_diaspora% - diaspora_url: %diaspora_url% - flattr: %flattr% - flattrable: 1 - flattred: 2 - carrot: %carrot% - show_printlink: %show_printlink% - export_epub: %export_epub% - export_mobi: %export_mobi% - export_pdf: %export_pdf% - export_csv: %export_csv% - export_json: %export_json% - export_txt: %export_txt% - export_xml: %export_xml% - version: %app.version% - twofactor_auth: %twofactor_auth% - paypal_url: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9UBA65LG3FX9Y&lc=gb" form_themes: - "LexikFormFilterBundle:Form:form_div_layout.html.twig" diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index 52d26cb4d..3eeedb780 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -37,32 +37,6 @@ parameters: # A secret key that's used to generate certain security-related tokens secret: ThisTokenIsNotSoSecretChangeIt - # wallabag misc - app.version: 2.0.0-alpha + # two factor stuff twofactor_auth: true twofactor_sender: no-reply@wallabag.org - - download_pictures: false # if true, pictures will be stored into data/assets for each article - - # Entry view - share_twitter: true - share_mail: true - share_shaarli: true - shaarli_url: http://myshaarli.com - share_diaspora: true - diaspora_url: http://diasporapod.com - flattr: true - carrot: true - show_printlink: true - export_epub: true - export_mobi: true - export_pdf: true - export_csv: true - export_json: true - export_txt: true - export_xml: true - wallabag_url: http://v2.wallabag.org - wallabag_support_url: 'https://www.wallabag.org/pages/support.html' - - # pocket import - pocket_consumer_key: xxxxxxxx diff --git a/app/config/routing.yml b/app/config/routing.yml index 84b98d232..c491d35dc 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -22,7 +22,9 @@ rest : homepage: path: "/{page}" - defaults: { _controller: WallabagCoreBundle:Entry:showUnread, page : 1 } + defaults: + _controller: WallabagCoreBundle:Entry:showUnread + page : 1 requirements: page: \d+ @@ -31,3 +33,8 @@ fos_user: fos_oauth_server_token: resource: "@FOSOAuthServerBundle/Resources/config/routing/token.xml" + +craue_config_settings_modify: + path: /settings + defaults: + _controller: CraueConfigBundle:Settings:modify diff --git a/app/config/security.yml b/app/config/security.yml index a99a7d80d..6f20490b8 100644 --- a/app/config/security.yml +++ b/app/config/security.yml @@ -58,3 +58,4 @@ security: - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: /(unread|starred|archive).xml$, roles: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/, roles: ROLE_USER } + - { path: ^/settings, roles: ROLE_SUPER_ADMIN } diff --git a/app/config/tests/parameters.yml.dist.mysql b/app/config/tests/parameters.yml.dist.mysql index 073f6c27e..3244fd3a2 100644 --- a/app/config/tests/parameters.yml.dist.mysql +++ b/app/config/tests/parameters.yml.dist.mysql @@ -27,32 +27,6 @@ parameters: # A secret key that's used to generate certain security-related tokens secret: ThisTokenIsNotSoSecretChangeIt - # wallabag misc - app.version: 2.0.0-alpha + # two factor stuff twofactor_auth: true twofactor_sender: no-reply@wallabag.org - - download_pictures: false # if true, pictures will be stored into data/assets for each article - - # Entry view - share_twitter: true - share_mail: true - share_shaarli: true - shaarli_url: http://myshaarli.com - share_diaspora: true - diaspora_url: http://diasporapod.com - flattr: true - carrot: true - show_printlink: true - export_epub: true - export_mobi: true - export_pdf: true - export_csv: true - export_json: true - export_txt: true - export_xml: true - wallabag_url: http://v2.wallabag.org - wallabag_support_url: 'https://www.wallabag.org/pages/support.html' - - # pocket import - pocket_consumer_key: xxxxxxxx diff --git a/app/config/tests/parameters.yml.dist.pgsql b/app/config/tests/parameters.yml.dist.pgsql index 24a1818a8..cee344734 100644 --- a/app/config/tests/parameters.yml.dist.pgsql +++ b/app/config/tests/parameters.yml.dist.pgsql @@ -27,32 +27,6 @@ parameters: # A secret key that's used to generate certain security-related tokens secret: ThisTokenIsNotSoSecretChangeIt - # wallabag misc - app.version: 2.0.0-alpha + # two factor stuff twofactor_auth: true twofactor_sender: no-reply@wallabag.org - - download_pictures: false # if true, pictures will be stored into data/assets for each article - - # Entry view - share_twitter: true - share_mail: true - share_shaarli: true - shaarli_url: http://myshaarli.com - share_diaspora: true - diaspora_url: http://diasporapod.com - flattr: true - carrot: true - show_printlink: true - export_epub: true - export_mobi: true - export_pdf: true - export_csv: true - export_json: true - export_txt: true - export_xml: true - wallabag_url: http://v2.wallabag.org - wallabag_support_url: 'https://www.wallabag.org/pages/support.html' - - # pocket import - pocket_consumer_key: xxxxxxxx diff --git a/app/config/tests/parameters.yml.dist.sqlite b/app/config/tests/parameters.yml.dist.sqlite index c739f89b0..a1535bc97 100644 --- a/app/config/tests/parameters.yml.dist.sqlite +++ b/app/config/tests/parameters.yml.dist.sqlite @@ -27,32 +27,6 @@ parameters: # A secret key that's used to generate certain security-related tokens secret: ThisTokenIsNotSoSecretChangeIt - # wallabag misc - app.version: 2.0.0-alpha + # two factor stuff twofactor_auth: true twofactor_sender: no-reply@wallabag.org - - download_pictures: false # if true, pictures will be stored into data/assets for each article - - # Entry view - share_twitter: true - share_mail: true - share_shaarli: true - shaarli_url: http://myshaarli.com - share_diaspora: true - diaspora_url: http://diasporapod.com - flattr: true - carrot: true - show_printlink: true - export_epub: true - export_mobi: true - export_pdf: true - export_csv: true - export_json: true - export_txt: true - export_xml: true - wallabag_url: http://v2.wallabag.org - wallabag_support_url: 'https://www.wallabag.org/pages/support.html' - - # pocket import - pocket_consumer_key: xxxxxxxx diff --git a/composer.json b/composer.json index d84e1f8b8..1c07c2092 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "lexik/form-filter-bundle": "~5.0", "j0k3r/graby": "~1.0", "friendsofsymfony/user-bundle": "dev-master", - "friendsofsymfony/oauth-server-bundle": "^1.5@dev", + "friendsofsymfony/oauth-server-bundle": "^1.5", "stof/doctrine-extensions-bundle": "^1.2@dev", "scheb/two-factor-bundle": "~2.0", "grandt/phpepub": "~4.0", @@ -63,7 +63,8 @@ "kphoen/rulerz-bundle": "~0.10", "guzzlehttp/guzzle": "^5.2.0", "doctrine/doctrine-migrations-bundle": "^1.0", - "paragonie/random_compat": "~1.0" + "paragonie/random_compat": "~1.0", + "craue/config-bundle": "~1.4" }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "~2.2", diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 4ece64312..c7513f796 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -163,6 +163,7 @@ class ConfigController extends Controller 'username' => $user->getUsername(), 'token' => $config->getRssToken(), ), + 'twofactor_auth' => $this->getParameter('twofactor_auth'), )); } diff --git a/src/Wallabag/CoreBundle/Controller/StaticController.php b/src/Wallabag/CoreBundle/Controller/StaticController.php index 9ada371b1..5b7bd56ed 100644 --- a/src/Wallabag/CoreBundle/Controller/StaticController.php +++ b/src/Wallabag/CoreBundle/Controller/StaticController.php @@ -25,7 +25,10 @@ class StaticController extends Controller { return $this->render( 'WallabagCoreBundle:Static:about.html.twig', - array() + array( + 'version' => $this->getParameter('wallabag_core.version'), + 'paypal_url' => $this->getParameter('wallabag_core.paypal_url'), + ) ); } diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index 4d5a63f86..bc405fdca 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php @@ -29,6 +29,10 @@ class Configuration implements ConfigurationInterface ->integerNode('rss_limit') ->defaultValue(50) ->end() + ->scalarNode('version') + ->end() + ->scalarNode('paypal_url') + ->end() ->end() ; diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php index 73bbffe11..9b4703e43 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php @@ -19,6 +19,8 @@ class WallabagCoreExtension extends Extension $container->setParameter('wallabag_core.theme', $config['theme']); $container->setParameter('wallabag_core.language', $config['language']); $container->setParameter('wallabag_core.rss_limit', $config['rss_limit']); + $container->setParameter('wallabag_core.version', $config['version']); + $container->setParameter('wallabag_core.paypal_url', $config['paypal_url']); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 31a80d6e3..965a40b6a 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -8,6 +8,7 @@ use JMS\Serializer\SerializerBuilder; use PHPePub\Core\EPub; use PHPePub\Core\Structure\OPF\DublinCore; use Symfony\Component\HttpFoundation\Response; +use Craue\ConfigBundle\Util\Config; /** * This class doesn't have unit test BUT it's fully covered by a functional test with ExportControllerTest. @@ -27,12 +28,12 @@ class EntriesExport </div'; /** - * @param string $wallabagUrl Wallabag instance url + * @param Config $craueConfig CraueConfig instance to get wallabag instance url from database * @param string $logoPath Path to the logo FROM THE BUNDLE SCOPE */ - public function __construct($wallabagUrl, $logoPath) + public function __construct(Config $craueConfig, $logoPath) { - $this->wallabagUrl = $wallabagUrl; + $this->wallabagUrl = $craueConfig->get('wallabag_url'); $this->logoPath = $logoPath; } diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index 6a1afcc00..813f8a961 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml @@ -3,7 +3,7 @@ services: class: Wallabag\CoreBundle\Helper\DetectActiveTheme arguments: - "@security.token_storage" - - %theme% # default theme from parameters.yml + - %wallabag_core.theme% # custom form type wallabag_core.form.type.config: @@ -86,7 +86,7 @@ services: wallabag_core.helper.entries_export: class: Wallabag\CoreBundle\Helper\EntriesExport arguments: - - %wallabag_url% + - "@craue_config" - src/Wallabag/CoreBundle/Resources/public/themes/_global/img/appicon/apple-touch-icon-152.png wallabag.operator.array.matches: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 20f4352b0..cc814cc4d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -13,6 +13,7 @@ archive: 'Lus' all: 'Tous les articles' tags: 'Tags' config: 'Configuration' +internal settings: 'Configuration interne' import: 'Importer' howto: 'Aide' logout: 'Déconnexion' diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig index c23d0e272..27a88287b 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig @@ -11,16 +11,15 @@ <li><a title="{% if entry.isArchived == 0 %}{% trans %}Mark as read{% endtrans %}{% else %}{% trans %}Mark as unread{% endtrans %}{% endif %}" class="tool icon icon-check {% if entry.isArchived == 0 %}archive-off{% else %}archive{% endif %}" href="{{ path('archive_entry', { 'id': entry.id }) }}"><span>{% if entry.isArchived == 0 %}{% trans %}Mark as read{% endtrans %}{% else %}{% trans %}Mark as unread{% endtrans %}{% endif %}</span></a></li> <li><a title="{% trans %}Favorite{% endtrans %}" class="tool icon icon-star {% if entry.isStarred == 0 %}fav-off{% else %}fav{% endif %}" href="{{ path('star_entry', { 'id': entry.id }) }}"><span>{% trans %}Toggle favorite{% endtrans %}</span></a></li> <li><a title="{% trans %}Delete{% endtrans %}" class="tool delete icon icon-trash" href="{{ path('delete_entry', { 'id': entry.id }) }}"><span>{% trans %}Delete{% endtrans %}</span></a></li> - {% if share_twitter %}<li><a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@wallabagapp" target="_blank" class="tool twitter icon icon-twitter" title="{% trans %}Tweet{% endtrans %}"><span>{% trans %}Tweet{% endtrans %}</span></a></li>{% endif %} - {% if share_mail %}<li><a href="mailto:?subject={{ entry.title|url_encode }}&body={{ entry.url|url_encode }}%20via%20@wallabagapp" class="tool email icon icon-mail" title="{% trans %}Email{% endtrans %}"><span>{% trans %}Email{% endtrans %}</span></a></li>{% endif %} - {% if share_shaarli %}<li><a href="{{ shaarli_url }}/index.php?post={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}" target="_blank" class="tool shaarli" title="{% trans %}shaarli{% endtrans %}"><span>{% trans %}shaarli{% endtrans %}</span></a></li>{% endif %} - {% if share_diaspora %}<li><a href="{{ diaspora_url }}/bookmarklet?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}¬es=&v=1&noui=1&jump=doclose" target="_blank" class="tool diaspora icon-image icon-image--diaspora" title="{% trans %}diaspora{% endtrans %}"><span>{% trans %}diaspora{% endtrans %}</span></a></li>{% endif %} - {# {% if flattr %}{% if flattr.status == flattrable %}<li><a href="http://flattr.com/submit/auto?url={{ entry.url }}" class="tool flattr icon icon-flattr" target="_blank" title="{% trans %}flattr{% endtrans %}"><span>{% trans %}flattr{% endtrans %}</span></a></li>{% elseif flattr.status == flattred %}<li><a href="{{ flattr.flattrItemURL }}" class="tool flattr icon icon-flattr" target="_blank" title="{% trans %}flattr{% endtrans %}><span>{% trans %}flattr{% endtrans %}</span> ({{ flattr.numFlattrs }})</a></li>{% endif %}{% endif %} #} - {% if carrot %}<li><a href="https://secure.carrot.org/GiveAndGetBack.do?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}" class="tool carrot icon-image icon-image--carrot" target="_blank" title="{% trans %}carrot{% endtrans %}"><span>Carrot</span></a></li>{% endif %} - {% if show_printlink %}<li><a title="{% trans %}Print{% endtrans %}" class="tool icon icon-print" href="javascript: window.print();"><span>{% trans %}Print{% endtrans %}</span></a></li>{% endif %} - {% if export_epub %}<li><a href="?epub&method=id&value={{ entry.id }}" title="Generate ePub file">EPUB</a></li>{% endif %} - {% if export_mobi %}<li><a href="?mobi&method=id&value={{ entry.id }}" title="Generate Mobi file">MOBI</a></li>{% endif %} - {% if export_pdf %}<li><a href="?pdf&method=id&value={{ entry.id }}" title="Generate PDF file">PDF</a></li>{% endif %} + {% if craue_setting('share_twitter') %}<li><a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@wallabagapp" target="_blank" class="tool twitter icon icon-twitter" title="{% trans %}Tweet{% endtrans %}"><span>{% trans %}Tweet{% endtrans %}</span></a></li>{% endif %} + {% if craue_setting('share_mail') %}<li><a href="mailto:?subject={{ entry.title|url_encode }}&body={{ entry.url|url_encode }}%20via%20@wallabagapp" class="tool email icon icon-mail" title="{% trans %}Email{% endtrans %}"><span>{% trans %}Email{% endtrans %}</span></a></li>{% endif %} + {% if craue_setting('share_shaarli') %}<li><a href="{{ craue_setting('shaarli_url') }}/index.php?post={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}" target="_blank" class="tool shaarli" title="{% trans %}shaarli{% endtrans %}"><span>{% trans %}shaarli{% endtrans %}</span></a></li>{% endif %} + {% if craue_setting('share_diaspora') %}<li><a href="{{ craue_setting('diaspora_url') }}/bookmarklet?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}¬es=&v=1&noui=1&jump=doclose" target="_blank" class="tool diaspora icon-image icon-image--diaspora" title="{% trans %}diaspora{% endtrans %}"><span>{% trans %}diaspora{% endtrans %}</span></a></li>{% endif %} + {% if craue_setting('carrot') %}<li><a href="https://secure.carrot.org/GiveAndGetBack.do?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}" class="tool carrot icon-image icon-image--carrot" target="_blank" title="{% trans %}carrot{% endtrans %}"><span>Carrot</span></a></li>{% endif %} + {% if craue_setting('show_printlink') %}<li><a title="{% trans %}Print{% endtrans %}" class="tool icon icon-print" href="javascript: window.print();"><span>{% trans %}Print{% endtrans %}</span></a></li>{% endif %} + {% if craue_setting('export_epub') %}<li><a href="?epub&method=id&value={{ entry.id }}" title="Generate ePub file">EPUB</a></li>{% endif %} + {% if craue_setting('export_mobi') %}<li><a href="?mobi&method=id&value={{ entry.id }}" title="Generate Mobi file">MOBI</a></li>{% endif %} + {% if craue_setting('export_pdf') %}<li><a href="?pdf&method=id&value={{ entry.id }}" title="Generate PDF file">PDF</a></li>{% endif %} <li><a href="mailto:hello@wallabag.org?subject=Wrong%20display%20in%20wallabag&body={{ entry.url|url_encode }}" title="{% trans %}Does this article appear wrong?{% endtrans %}" class="tool bad-display icon icon-delete"><span>{% trans %}Does this article appear wrong?{% endtrans %}</span></a></li> </ul> </div> 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 3aead4975..b630070ca 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig @@ -51,6 +51,9 @@ </div> </li> <li><a href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li> + {% if is_granted('ROLE_SUPER_ADMIN') %} + <li><a href="{{ path('craue_config_settings_modify') }}">{% trans %}internal settings{% endtrans %}</a></li> + {% endif %} <li><a href="{{ path('import') }}">{% trans %}import{% endtrans %}</a></li> <li><a href="{{ path('howto') }}">{% trans %}howto{% endtrans %}</a></li> <li><a href="{{ path('about') }}">{% trans %}about{% endtrans %}</a></li> diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig index 31963ae82..dad96187c 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig @@ -97,12 +97,11 @@ </a> <div class="collapsible-body"> <ul> - {% if share_twitter %}<li><a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@wallabagapp" target="_blank" class="tool twitter icon icon-twitter" title="{% trans %}twitter{% endtrans %}"><span>{% trans %}twitter{% endtrans %}</span></a></li>{% endif %} - {% if share_shaarli %}<li><a href="{{ shaarli_url }}/index.php?post={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}" target="_blank" class="tool shaarli" title="{% trans %}shaarli{% endtrans %}"><span>{% trans %}shaarli{% endtrans %}</span></a></li>{% endif %} - {% if share_diaspora %}<li><a href="{{ diaspora_url }}/bookmarklet?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}¬es=&v=1&noui=1&jump=doclose" target="_blank" class="tool diaspora icon-image icon-image--diaspora" title="{% trans %}diaspora*{% endtrans %}"><span>{% trans %}diaspora*{% endtrans %}</span></a></li>{% endif %} - {# {% if flattr %}{% if flattr.status == flattrable %}<li><a href="http://flattr.com/submit/auto?url={{ entry.url }}" class="tool flattr icon icon-flattr" target="_blank" title="{% trans %}flattr{% endtrans %}"><span>{% trans %}flattr{% endtrans %}</span></a></li>{% elseif flattr.status == flattred %}<li><a href="{{ flattr.flattrItemURL }}" class="tool flattr icon icon-flattr" target="_blank" title="{% trans %}flattr{% endtrans %}><span>{% trans %}flattr{% endtrans %}</span> ({{ flattr.numFlattrs }})</a></li>{% endif %}{% endif %} #} - {% if carrot %}<li><a href="https://secure.carrot.org/GiveAndGetBack.do?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}" class="tool carrot icon-image icon-image--carrot" target="_blank" title="{% trans %}carrot{% endtrans %}"><span>Carrot</span></a></li>{% endif %} - {% if share_mail %}<li><a href="mailto:?subject={{ entry.title|url_encode }}&body={{ entry.url|url_encode }}%20via%20@wallabagapp" class="tool email icon icon-mail" title="{% trans %}Email{% endtrans %}"><span>{% trans %}Email{% endtrans %}</span></a></li>{% endif %} + {% if craue_setting('share_twitter') %}<li><a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@wallabagapp" target="_blank" class="tool twitter icon icon-twitter" title="{% trans %}twitter{% endtrans %}"><span>{% trans %}twitter{% endtrans %}</span></a></li>{% endif %} + {% if craue_setting('share_shaarli') %}<li><a href="{{ craue_setting('shaarli_url') }}/index.php?post={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}" target="_blank" class="tool shaarli" title="{% trans %}shaarli{% endtrans %}"><span>{% trans %}shaarli{% endtrans %}</span></a></li>{% endif %} + {% if craue_setting('share_diaspora') %}<li><a href="{{ craue_setting('diaspora_url') }}/bookmarklet?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}¬es=&v=1&noui=1&jump=doclose" target="_blank" class="tool diaspora icon-image icon-image--diaspora" title="{% trans %}diaspora*{% endtrans %}"><span>{% trans %}diaspora*{% endtrans %}</span></a></li>{% endif %} + {% if craue_setting('carrot') %}<li><a href="https://secure.carrot.org/GiveAndGetBack.do?url={{ entry.url|url_encode }}&title={{ entry.title|url_encode }}" class="tool carrot icon-image icon-image--carrot" target="_blank" title="{% trans %}carrot{% endtrans %}"><span>Carrot</span></a></li>{% endif %} + {% if craue_setting('share_mail') %}<li><a href="mailto:?subject={{ entry.title|url_encode }}&body={{ entry.url|url_encode }}%20via%20@wallabagapp" class="tool email icon icon-mail" title="{% trans %}Email{% endtrans %}"><span>{% trans %}Email{% endtrans %}</span></a></li>{% endif %} </ul> </div> </li> @@ -114,13 +113,13 @@ </a> <div class="collapsible-body"> <ul> - {% if export_epub %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'epub' }) }}" title="Generate ePub file">EPUB</a></li>{% endif %} - {% if export_mobi %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'mobi' }) }}" title="Generate Mobi file">MOBI</a></li>{% endif %} - {% if export_pdf %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'pdf' }) }}" title="Generate PDF file">PDF</a></li>{% endif %} - {% if export_csv %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'csv' }) }}" title="Generate CSV file">CSV</a></li>{% endif %} - {% if export_json %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'json' }) }}" title="Generate JSON file">JSON</a></li>{% endif %} - {% if export_txt %}<li><del><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'txt' }) }}" title="Generate TXT file">TXT</a></del></li>{% endif %} - {% if export_xml %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'xml' }) }}" title="Generate XML file">XML</a></li>{% endif %} + {% if craue_setting('export_epub') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'epub' }) }}" title="Generate ePub file">EPUB</a></li>{% endif %} + {% if craue_setting('export_mobi') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'mobi' }) }}" title="Generate Mobi file">MOBI</a></li>{% endif %} + {% if craue_setting('export_pdf') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'pdf' }) }}" title="Generate PDF file">PDF</a></li>{% endif %} + {% if craue_setting('export_csv') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'csv' }) }}" title="Generate CSV file">CSV</a></li>{% endif %} + {% if craue_setting('export_json') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'json' }) }}" title="Generate JSON file">JSON</a></li>{% endif %} + {% if craue_setting('export_txt') %}<li><del><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'txt' }) }}" title="Generate TXT file">TXT</a></del></li>{% endif %} + {% if craue_setting('export_xml') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'xml' }) }}" title="Generate XML file">XML</a></li>{% endif %} </ul> </div> </li> 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 a8b6dc3f6..dff9e6127 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig @@ -45,6 +45,9 @@ <li class="bold border-bottom {% if currentRoute == 'all' %}active{% endif %}"><a class="waves-effect" href="{{ path('all') }}">{% trans %}all{% endtrans %}</a></li> <li class="bold border-bottom {% if currentRoute == 'tags' %}active{% endif %}"><a class="waves-effect" href="{{ path('tag') }}">{% trans %}tags{% endtrans %}</a></li> <li class="bold {% if currentRoute == 'config' %}active{% endif %}"><a class="waves-effect" href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li> + {% if is_granted('ROLE_SUPER_ADMIN') %} + <li class="bold border-bottom {% if currentRoute == 'craue_config_settings_modify' %}active{% endif %}"><a class="waves-effect" href="{{ path('craue_config_settings_modify') }}">{% trans %}internal settings{% endtrans %}</a></li> + {% endif %} <li class="bold {% if currentRoute == 'import' %}active{% endif %}"><a class="waves-effect" href="{{ path('import') }}">{% trans %}import{% endtrans %}</a></li> <li class="bold {% if currentRoute == 'howto' %}active{% endif %}"><a class="waves-effect" href="{{ path('howto') }}">{% trans %}howto{% endtrans %}</a></li> <li class="bold"><a class="waves-effect" class="icon icon-power" href="{{ path('fos_user_security_logout') }}" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li> diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index 72b9047c8..0463a7399 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php @@ -11,6 +11,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Helper\ContentProxy; +use Craue\ConfigBundle\Util\Config; class PocketImport implements ImportInterface { @@ -25,12 +26,12 @@ class PocketImport implements ImportInterface protected $accessToken; private $translator; - public function __construct(TokenStorageInterface $tokenStorage, EntityManager $em, ContentProxy $contentProxy, $consumerKey) + public function __construct(TokenStorageInterface $tokenStorage, EntityManager $em, ContentProxy $contentProxy, Config $craueConfig) { $this->user = $tokenStorage->getToken()->getUser(); $this->em = $em; $this->contentProxy = $contentProxy; - $this->consumerKey = $consumerKey; + $this->consumerKey = $craueConfig->get('pocket_consumer_key'); $this->logger = new NullLogger(); } diff --git a/src/Wallabag/ImportBundle/Resources/config/services.yml b/src/Wallabag/ImportBundle/Resources/config/services.yml index e4dde1003..dc5368080 100644 --- a/src/Wallabag/ImportBundle/Resources/config/services.yml +++ b/src/Wallabag/ImportBundle/Resources/config/services.yml @@ -17,7 +17,7 @@ services: - "@security.token_storage" - "@doctrine.orm.entity_manager" - "@wallabag_core.content_proxy" - - %pocket_consumer_key% + - "@craue_config" calls: - [ setClient, [ "@wallabag_import.pocket.client" ] ] - [ setLogger, [ "@logger" ]] diff --git a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php index 76225fe4f..25359d56b 100644 --- a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php +++ b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php @@ -55,11 +55,20 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); + $config = $this->getMockBuilder('Craue\ConfigBundle\Util\Config') + ->disableOriginalConstructor() + ->getMock(); + + $config->expects($this->any()) + ->method('get') + ->with('pocket_consumer_key') + ->willReturn($consumerKey); + $pocket = new PocketImportMock( $this->tokenStorage, $this->em, $this->contentProxy, - $consumerKey + $config ); $this->logHandler = new TestHandler(); diff --git a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php index 6b108dd3e..4ab6051b6 100644 --- a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php +++ b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php @@ -4,6 +4,7 @@ namespace Wallabag\UserBundle\Mailer; use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface; use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface; +use Craue\ConfigBundle\Util\Config; /** * Custom mailer for TwoFactorBundle email. @@ -60,17 +61,16 @@ class AuthCodeMailer implements AuthCodeMailerInterface * @param \Twig_Environment $twig * @param string $senderEmail * @param string $senderName - * @param string $supportUrl - * @param string $wallabagUrl + * @param Config $craueConfig Craue\Config instance to get wallabag support url from database */ - public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig, $senderEmail, $senderName, $supportUrl, $wallabagUrl) + public function __construct(\Swift_Mailer $mailer, \Twig_Environment $twig, $senderEmail, $senderName, Config $craueConfig) { $this->mailer = $mailer; $this->twig = $twig; $this->senderEmail = $senderEmail; $this->senderName = $senderName; - $this->supportUrl = $supportUrl; - $this->wallabagUrl = $wallabagUrl; + $this->supportUrl = $craueConfig->get('wallabag_support_url'); + $this->wallabagUrl = $craueConfig->get('wallabag_url'); } /** diff --git a/src/Wallabag/UserBundle/Resources/config/services.yml b/src/Wallabag/UserBundle/Resources/config/services.yml index bf9e036ae..d79d8fa2b 100644 --- a/src/Wallabag/UserBundle/Resources/config/services.yml +++ b/src/Wallabag/UserBundle/Resources/config/services.yml @@ -6,8 +6,7 @@ services: - "@twig" - "%scheb_two_factor.email.sender_email%" - "%scheb_two_factor.email.sender_name%" - - "%wallabag_support_url%" - - "%wallabag_url%" + - "@craue_config" wallabag_user.password_resetting: class: Wallabag\UserBundle\EventListener\PasswordResettingListener From 1e3ed714707878caa603ffdc262e64abb6ddfb5c Mon Sep 17 00:00:00 2001 From: Jeremy Benoist <jeremy.benoist@gmail.com> Date: Thu, 21 Jan 2016 10:59:21 +0100 Subject: [PATCH 04/13] Add warning message for PocketImport Warn user if pocket_consumer_key isn't defined --- src/Wallabag/ImportBundle/Controller/PocketController.php | 1 + .../ImportBundle/Resources/views/Pocket/index.html.twig | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php index 7aee302f5..1c1b4fa88 100644 --- a/src/Wallabag/ImportBundle/Controller/PocketController.php +++ b/src/Wallabag/ImportBundle/Controller/PocketController.php @@ -15,6 +15,7 @@ class PocketController extends Controller { return $this->render('WallabagImportBundle:Pocket:index.html.twig', [ 'import' => $this->get('wallabag_import.pocket.import'), + 'has_consumer_key' => '' == trim($this->get('craue_config')->get('pocket_consumer_key')) ? false : true, ]); } diff --git a/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig index 643ad7754..e0e36f387 100644 --- a/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig +++ b/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig @@ -5,6 +5,12 @@ <div class="row"> <div class="col s12"> <div class="card-panel settings"> + {% if not has_consumer_key %} + <div class="card-panel red darken-1"> + {% trans %}Pocket import isn't configured. You need to define pocket_consumer_key.{% endtrans %} + </div> + {% endif %} + <blockquote>{{ import.description|trans }}</blockquote> <p>{% trans %}You can import your data from your Pocket account. You just have to click on the below button and authorize the application to connect to getpocket.com.{% endtrans %}</p> <form method="post" action="{{ path('import_pocket_auth') }}"> From 278b221e6545c5990e9d79a4c6bb4491b22a7a85 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist <jeremy.benoist@gmail.com> Date: Thu, 21 Jan 2016 12:21:11 +0100 Subject: [PATCH 05/13] We don't need migration yet --- app/DoctrineMigrations/.gitkeep | 0 .../Version20160120200534_settings.php | 51 ------------------- 2 files changed, 51 deletions(-) create mode 100644 app/DoctrineMigrations/.gitkeep delete mode 100644 app/DoctrineMigrations/Version20160120200534_settings.php diff --git a/app/DoctrineMigrations/.gitkeep b/app/DoctrineMigrations/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/app/DoctrineMigrations/Version20160120200534_settings.php b/app/DoctrineMigrations/Version20160120200534_settings.php deleted file mode 100644 index 34809ff9d..000000000 --- a/app/DoctrineMigrations/Version20160120200534_settings.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -namespace Application\Migrations; - -use Doctrine\DBAL\Migrations\AbstractMigration; -use Doctrine\DBAL\Schema\Schema; - -/** - * Auto-generated Migration: Please modify to your needs! - */ -class Version20160120200534_settings extends AbstractMigration -{ - /** - * @param Schema $schema - */ - public function up(Schema $schema) - { - // this up() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); - - $this->addSql('CREATE TABLE craue_config_setting (name VARCHAR(255) NOT NULL, value VARCHAR(255) DEFAULT NULL, section VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_B95BA9425E237E06 (name), PRIMARY KEY(name)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); - $this->addSql("INSERT INTO `craue_config_setting` (`name`, `value`, `section`) VALUES - ('download_pictures', '1', 'entry'), - ('carrot', '1', 'entry'), - ('share_diaspora', '1', 'entry'), - ('diaspora_url', 'http://diasporapod.com', 'entry'), - ('share_shaarli', '1', 'entry'), - ('shaarli_url', 'http://myshaarli.com', 'entry'), - ('share_mail', '1', 'entry'), - ('share_twitter', '1', 'entry'), - ('export_epub', '1', 'export'), - ('export_mobi', '1', 'export'), - ('export_pdf', '1', 'export'), - ('pocket_consumer_key', NULL, 'import'), - ('show_printlink', '1', 'entry'), - ('wallabag_support_url', 'https://www.wallabag.org/pages/support.html', 'misc'), - ('wallabag_url', 'http://v2.wallabag.org', 'misc')" - ); - } - - /** - * @param Schema $schema - */ - public function down(Schema $schema) - { - // this down() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); - - $this->addSql('DROP TABLE craue_config_setting'); - } -} From d6ba77e888064dcf5757fb008426eb8bfcd6dd4c Mon Sep 17 00:00:00 2001 From: Jeremy Benoist <jeremy.benoist@gmail.com> Date: Thu, 21 Jan 2016 12:23:45 +0100 Subject: [PATCH 06/13] Create internal setting on install & fixtures --- .../CoreBundle/Command/InstallCommand.php | 90 ++++++++++++++ .../DataFixtures/ORM/LoadSettingData.php | 113 ++++++++++++++++++ 2 files changed, 203 insertions(+) create mode 100644 src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 7a7e3a643..f6c85cf97 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -12,6 +12,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; use Wallabag\CoreBundle\Entity\Config; +use Craue\ConfigBundle\Entity\Setting; class InstallCommand extends ContainerAwareCommand { @@ -212,6 +213,95 @@ class InstallCommand extends ContainerAwareCommand $em->persist($config); + // cleanup before insert new stuff + $em->createQuery('DELETE FROM CraueConfigBundle:Setting')->execute(); + + $settings = [ + [ + 'name' => 'download_pictures', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'carrot', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'share_diaspora', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'diaspora_url', + 'value' => 'http://diasporapod.com', + 'section' => 'entry', + ], + [ + 'name' => 'share_shaarli', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'shaarli_url', + 'value' => 'http://myshaarli.com', + 'section' => 'entry', + ], + [ + 'name' => 'share_mail', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'share_twitter', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'export_epub', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_mobi', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_pdf', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'pocket_consumer_key', + 'value' => NULL, + 'section' => 'import', + ], + [ + 'name' => 'show_printlink', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'wallabag_support_url', + 'value' => 'https://www.wallabag.org/pages/support.html', + 'section' => 'misc', + ], + [ + 'name' => 'wallabag_url', + 'value' => 'http://v2.wallabag.org', + 'section' => 'misc', + ], + ]; + + foreach ($settings as $setting) { + $newSetting = new Setting(); + $newSetting->setName($setting['name']); + $newSetting->setValue($setting['value']); + $newSetting->setSection($setting['section']); + $em->persist($newSetting); + } + $em->flush(); $this->defaultOutput->writeln(''); diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php new file mode 100644 index 000000000..863d28f50 --- /dev/null +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php @@ -0,0 +1,113 @@ +<?php + +namespace Wallabag\CoreBundle\DataFixtures\ORM; + +use Doctrine\Common\DataFixtures\AbstractFixture; +use Doctrine\Common\DataFixtures\OrderedFixtureInterface; +use Doctrine\Common\Persistence\ObjectManager; +use Craue\ConfigBundle\Entity\Setting; + +class LoadSettingData extends AbstractFixture implements OrderedFixtureInterface +{ + /** + * {@inheritdoc} + */ + public function load(ObjectManager $manager) + { + $settings = [ + [ + 'name' => 'download_pictures', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'carrot', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'share_diaspora', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'diaspora_url', + 'value' => 'http://diasporapod.com', + 'section' => 'entry', + ], + [ + 'name' => 'share_shaarli', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'shaarli_url', + 'value' => 'http://myshaarli.com', + 'section' => 'entry', + ], + [ + 'name' => 'share_mail', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'share_twitter', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'export_epub', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_mobi', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_pdf', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'pocket_consumer_key', + 'value' => NULL, + 'section' => 'import', + ], + [ + 'name' => 'show_printlink', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'wallabag_support_url', + 'value' => 'https://www.wallabag.org/pages/support.html', + 'section' => 'misc', + ], + [ + 'name' => 'wallabag_url', + 'value' => 'http://v2.wallabag.org', + 'section' => 'misc', + ], + ]; + + foreach ($settings as $setting) { + $newSetting = new Setting(); + $newSetting->setName($setting['name']); + $newSetting->setValue($setting['value']); + $newSetting->setSection($setting['section']); + $manager->persist($newSetting); + } + + $manager->flush(); + } + + /** + * {@inheritdoc} + */ + public function getOrder() + { + return 50; + } +} From 67c99849ae03d41e94b144321d627e8c6ddd5fa3 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist <jeremy.benoist@gmail.com> Date: Thu, 21 Jan 2016 12:24:27 +0100 Subject: [PATCH 07/13] Use alias to get container parameters --- src/Wallabag/CoreBundle/Controller/ConfigController.php | 8 ++++---- src/Wallabag/CoreBundle/Controller/RssController.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index c7513f796..25e698206 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -133,10 +133,10 @@ class ConfigController extends Controller $userManager->updateUser($newUser, true); $config = new Config($newUser); - $config->setTheme($this->container->getParameter('wallabag_core.theme')); - $config->setItemsPerPage($this->container->getParameter('wallabag_core.items_on_page')); - $config->setRssLimit($this->container->getParameter('wallabag_core.rss_limit')); - $config->setLanguage($this->container->getParameter('wallabag_core.language')); + $config->setTheme($this->getParameter('wallabag_core.theme')); + $config->setItemsPerPage($this->getParameter('wallabag_core.items_on_page')); + $config->setRssLimit($this->getParameter('wallabag_core.rss_limit')); + $config->setLanguage($this->getParameter('wallabag_core.language')); $em->persist($config); diff --git a/src/Wallabag/CoreBundle/Controller/RssController.php b/src/Wallabag/CoreBundle/Controller/RssController.php index 2b7ef5985..a4f7a200e 100644 --- a/src/Wallabag/CoreBundle/Controller/RssController.php +++ b/src/Wallabag/CoreBundle/Controller/RssController.php @@ -84,7 +84,7 @@ class RssController extends Controller $pagerAdapter = new DoctrineORMAdapter($qb->getQuery()); $entries = new Pagerfanta($pagerAdapter); - $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit'); + $perPage = $user->getConfig()->getRssLimit() ?: $this->getParameter('wallabag_core.rss_limit'); $entries->setMaxPerPage($perPage); return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array( From 2a58606983bd6091866a9f38149a87c25900decd Mon Sep 17 00:00:00 2001 From: Jeremy Benoist <jeremy.benoist@gmail.com> Date: Thu, 21 Jan 2016 12:24:35 +0100 Subject: [PATCH 08/13] Fix tests --- .../CoreBundle/Tests/Command/InstallCommandTest.php | 1 + .../UserBundle/Tests/Mailer/AuthCodeMailerTest.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php b/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php index 7d75e2b7b..a79d7b906 100644 --- a/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php +++ b/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php @@ -81,6 +81,7 @@ class InstallCommandTest extends WallabagCoreTestCase $this->assertContains('Step 1 of 4. Checking system requirements.', $tester->getDisplay()); $this->assertContains('Step 2 of 4. Setting up database.', $tester->getDisplay()); + $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay()); $this->assertContains('Step 3 of 4. Administration setup.', $tester->getDisplay()); $this->assertContains('Step 4 of 4. Installing assets.', $tester->getDisplay()); diff --git a/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php b/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php index e3f43a7e7..562a1ed2b 100644 --- a/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php +++ b/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php @@ -26,6 +26,7 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase protected $mailer; protected $spool; protected $twig; + protected $config; protected function setUp() { @@ -43,6 +44,14 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase TWIG; $this->twig = new \Twig_Environment(new \Twig_Loader_Array(array('@WallabagUserBundle/Resources/views/TwoFactor/email_auth_code.html.twig' => $twigTemplate))); + + $this->config = $this->getMockBuilder('Craue\ConfigBundle\Util\Config') + ->disableOriginalConstructor() + ->getMock(); + + $this->config->expects($this->any()) + ->method('get') + ->willReturn('http://0.0.0.0/support'); } public function testSendEmail() @@ -58,8 +67,7 @@ TWIG; $this->twig, 'nobody@test.io', 'wallabag test', - 'http://0.0.0.0/support', - 'http://0.0.0.0' + $this->config ); $authCodeMailer->sendAuthCode($user); From 1c7d66645b312ee41a392c1d154f49fb6a6ec389 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist <jeremy.benoist@gmail.com> Date: Thu, 21 Jan 2016 12:29:35 +0100 Subject: [PATCH 09/13] CS --- src/Wallabag/CoreBundle/Command/InstallCommand.php | 2 +- src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php | 2 +- src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index f6c85cf97..096f306f6 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -274,7 +274,7 @@ class InstallCommand extends ContainerAwareCommand ], [ 'name' => 'pocket_consumer_key', - 'value' => NULL, + 'value' => null, 'section' => 'import', ], [ diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php index 863d28f50..8e3c7b59f 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php @@ -72,7 +72,7 @@ class LoadSettingData extends AbstractFixture implements OrderedFixtureInterface ], [ 'name' => 'pocket_consumer_key', - 'value' => NULL, + 'value' => null, 'section' => 'import', ], [ diff --git a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php index 4ab6051b6..98017f43a 100644 --- a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php +++ b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php @@ -48,7 +48,7 @@ class AuthCodeMailer implements AuthCodeMailerInterface private $supportUrl; /** - * Url for the wallabag instance. + * Url for the wallabag instance (only used for image in the HTML email template) * * @var string */ From 07c9b1c98a104a88f6bd0c97b54a8783444a2ac4 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist <jeremy.benoist@gmail.com> Date: Fri, 22 Jan 2016 18:48:04 +0100 Subject: [PATCH 10/13] Fix permission to settings page --- app/config/security.yml | 2 +- .../Controller/SettingsControllerTest.php | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/Wallabag/CoreBundle/Tests/Controller/SettingsControllerTest.php diff --git a/app/config/security.yml b/app/config/security.yml index 6f20490b8..7c10889ff 100644 --- a/app/config/security.yml +++ b/app/config/security.yml @@ -57,5 +57,5 @@ security: - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: /(unread|starred|archive).xml$, roles: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: ^/, roles: ROLE_USER } - { path: ^/settings, roles: ROLE_SUPER_ADMIN } + - { path: ^/, roles: ROLE_USER } diff --git a/src/Wallabag/CoreBundle/Tests/Controller/SettingsControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SettingsControllerTest.php new file mode 100644 index 000000000..354aedbac --- /dev/null +++ b/src/Wallabag/CoreBundle/Tests/Controller/SettingsControllerTest.php @@ -0,0 +1,32 @@ +<?php + +namespace Wallabag\CoreBundle\Tests\Controller; + +use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; + +/** + * The controller `SettingsController` does not exist. + * This test cover security against the internal settings page managed by CraueConfigBundle + */ +class SettingsControllerTest extends WallabagCoreTestCase +{ + public function testSettingsWithAdmin() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/settings'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + } + + public function testSettingsWithNormalUser() + { + $this->logInAs('bob'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/settings'); + + $this->assertEquals(403, $client->getResponse()->getStatusCode()); + } +} From a74a6ca2b164447f2675a13840f862c2c4c672fd Mon Sep 17 00:00:00 2001 From: Jeremy Benoist <jeremy.benoist@gmail.com> Date: Sun, 31 Jan 2016 14:54:30 +0100 Subject: [PATCH 11/13] Add new export config --- .../translations/CraueConfigBundle.en.yml | 4 ++++ .../translations/CraueConfigBundle.fr.yml | 4 ++++ app/config/config.yml | 2 +- .../CoreBundle/Command/InstallCommand.php | 20 +++++++++++++++++++ .../DataFixtures/ORM/LoadSettingData.php | 20 +++++++++++++++++++ .../themes/material/Entry/entries.html.twig | 14 ++++++------- 6 files changed, 56 insertions(+), 8 deletions(-) diff --git a/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml index ea90460e0..b5385dc39 100644 --- a/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml +++ b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml @@ -4,6 +4,10 @@ diaspora_url: Diaspora URL, if the service is enabled export_epub: Enable ePub export export_mobi: Enable .mobi export export_pdf: Enable PDF export +export_csv: Enable CSV export +export_json: Enable JSON export +export_txt: Enable TXT export +export_xml: Enable XML export pocket_consumer_key: Consumer key for Pocket to import contents (https://getpocket.com/developer/docs/authentication) shaarli_url: URL de Shaarli, if the service is enabled share_diaspora: Enable share to Diaspora diff --git a/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.fr.yml b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.fr.yml index 196000457..0efe14f43 100644 --- a/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.fr.yml +++ b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.fr.yml @@ -4,6 +4,10 @@ diaspora_url: URL de Diaspora, si le service Diaspora est activé export_epub: Activer l'export ePub export_mobi: Activer l'export .mobi export_pdf: Activer l'export PDF +export_csv: Activer l'export CSV +export_json: Activer l'export JSON +export_txt: Activer l'export TXT +export_xml: Activer l'export XML pocket_consumer_key: Clé d'authentification Pocket pour importer les données (https://getpocket.com/developer/docs/authentication) shaarli_url: URL de Shaarli, si le service Diaspora est activé share_diaspora: Activer le partage vers Diaspora diff --git a/app/config/config.yml b/app/config/config.yml index 3c278ea63..dc6bccee0 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -28,7 +28,7 @@ framework: assets: ~ wallabag_core: - version: 2.0.0-alpha.1 + version: 2.0.0-alpha.2 paypal_url: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9UBA65LG3FX9Y&lc=gb" languages: en: 'English' diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 096f306f6..937926925 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -272,6 +272,26 @@ class InstallCommand extends ContainerAwareCommand 'value' => '1', 'section' => 'export', ], + [ + 'name' => 'export_csv', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_json', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_txt', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_xml', + 'value' => '1', + 'section' => 'export', + ], [ 'name' => 'pocket_consumer_key', 'value' => null, diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php index 8e3c7b59f..5e89c2a98 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php @@ -70,6 +70,26 @@ class LoadSettingData extends AbstractFixture implements OrderedFixtureInterface 'value' => '1', 'section' => 'export', ], + [ + 'name' => 'export_csv', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_json', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_txt', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_xml', + 'value' => '1', + 'section' => 'export', + ], [ 'name' => 'pocket_consumer_key', 'value' => null, diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig index 6de800b94..c86b8d888 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig @@ -99,13 +99,13 @@ {% endif %} <h4 class="center">{% trans %}Export{% endtrans %}</h4> <ul> - {% if export_epub %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'epub' }) }}">{% trans %}EPUB{% endtrans %}</a></li>{% endif %} - {% if export_mobi %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'mobi' }) }}">{% trans %}MOBI{% endtrans %}</a></li>{% endif %} - {% if export_pdf %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'pdf' }) }}">{% trans %}PDF{% endtrans %}</a></li>{% endif %} - {% if export_xml %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'xml' }) }}">{% trans %}XML{% endtrans %}</a></li>{% endif %} - {% if export_csv %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'json' }) }}">{% trans %}JSON{% endtrans %}</a></li>{% endif %} - {% if export_json %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'csv' }) }}">{% trans %}CSV{% endtrans %}</a></li>{% endif %} - {% if export_txt %}<li class="bold"><del><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'txt' }) }}">{% trans %}TXT{% endtrans %}</a></del></li>{% endif %} + {% if craue_setting('export_epub') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'epub' }) }}">{% trans %}EPUB{% endtrans %}</a></li>{% endif %} + {% if craue_setting('export_mobi') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'mobi' }) }}">{% trans %}MOBI{% endtrans %}</a></li>{% endif %} + {% if craue_setting('export_pdf') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'pdf' }) }}">{% trans %}PDF{% endtrans %}</a></li>{% endif %} + {% if craue_setting('export_xml') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'xml' }) }}">{% trans %}XML{% endtrans %}</a></li>{% endif %} + {% if craue_setting('export_csv') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'json' }) }}">{% trans %}JSON{% endtrans %}</a></li>{% endif %} + {% if craue_setting('export_json') %}<li class="bold"><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'csv' }) }}">{% trans %}CSV{% endtrans %}</a></li>{% endif %} + {% if craue_setting('export_txt') %}<li class="bold"><del><a class="waves-effect" href="{{ path('export_entries', { 'category': currentRoute, 'format': 'txt' }) }}">{% trans %}TXT{% endtrans %}</a></del></li>{% endif %} </ul> </div> From 48e3007b7f5b542ebd8dda07a7a206f3bce69d7a Mon Sep 17 00:00:00 2001 From: Jeremy Benoist <jeremy.benoist@gmail.com> Date: Sun, 31 Jan 2016 15:12:18 +0100 Subject: [PATCH 12/13] Fix from_email & fos_user --- app/config/parameters.yml.dist | 2 ++ app/config/tests/parameters.yml.dist.mysql | 2 ++ app/config/tests/parameters.yml.dist.pgsql | 2 ++ app/config/tests/parameters.yml.dist.sqlite | 2 ++ composer.json | 2 +- src/Wallabag/UserBundle/Resources/config/services.yml | 5 +++++ 6 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index 3eeedb780..57cae9a06 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -40,3 +40,5 @@ parameters: # two factor stuff twofactor_auth: true twofactor_sender: no-reply@wallabag.org + + from_email: no-reply@wallabag.org diff --git a/app/config/tests/parameters.yml.dist.mysql b/app/config/tests/parameters.yml.dist.mysql index 3244fd3a2..2823a4243 100644 --- a/app/config/tests/parameters.yml.dist.mysql +++ b/app/config/tests/parameters.yml.dist.mysql @@ -30,3 +30,5 @@ parameters: # two factor stuff twofactor_auth: true twofactor_sender: no-reply@wallabag.org + + from_email: no-reply@wallabag.org diff --git a/app/config/tests/parameters.yml.dist.pgsql b/app/config/tests/parameters.yml.dist.pgsql index cee344734..5b55cb643 100644 --- a/app/config/tests/parameters.yml.dist.pgsql +++ b/app/config/tests/parameters.yml.dist.pgsql @@ -30,3 +30,5 @@ parameters: # two factor stuff twofactor_auth: true twofactor_sender: no-reply@wallabag.org + + from_email: no-reply@wallabag.org diff --git a/app/config/tests/parameters.yml.dist.sqlite b/app/config/tests/parameters.yml.dist.sqlite index a1535bc97..01589d282 100644 --- a/app/config/tests/parameters.yml.dist.sqlite +++ b/app/config/tests/parameters.yml.dist.sqlite @@ -30,3 +30,5 @@ parameters: # two factor stuff twofactor_auth: true twofactor_sender: no-reply@wallabag.org + + from_email: no-reply@wallabag.org diff --git a/composer.json b/composer.json index 1c07c2092..497b80121 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,7 @@ "pagerfanta/pagerfanta": "~1.0.3", "lexik/form-filter-bundle": "~5.0", "j0k3r/graby": "~1.0", - "friendsofsymfony/user-bundle": "dev-master", + "friendsofsymfony/user-bundle": "~2.0@dev", "friendsofsymfony/oauth-server-bundle": "^1.5", "stof/doctrine-extensions-bundle": "^1.2@dev", "scheb/two-factor-bundle": "~2.0", diff --git a/src/Wallabag/UserBundle/Resources/config/services.yml b/src/Wallabag/UserBundle/Resources/config/services.yml index d79d8fa2b..9a5893320 100644 --- a/src/Wallabag/UserBundle/Resources/config/services.yml +++ b/src/Wallabag/UserBundle/Resources/config/services.yml @@ -1,4 +1,9 @@ services: + # might be fixed in the symfony release + # https://github.com/FriendsOfSymfony/FOSUserBundle/issues/2048 + fos_user.doctrine_registry: + alias: doctrine + wallabag_user.auth_code_mailer: class: Wallabag\UserBundle\Mailer\AuthCodeMailer arguments: From 79b9e49d9464e9a67f6ee66fbf6f6c541b1a29f4 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist <j0k3r@users.noreply.github.com> Date: Mon, 1 Feb 2016 13:42:27 +0100 Subject: [PATCH 13/13] Fix Shaarli url traduction --- .../CraueConfigBundle/translations/CraueConfigBundle.fr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.fr.yml b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.fr.yml index 0efe14f43..cdd56acdd 100644 --- a/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.fr.yml +++ b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.fr.yml @@ -9,7 +9,7 @@ export_json: Activer l'export JSON export_txt: Activer l'export TXT export_xml: Activer l'export XML pocket_consumer_key: Clé d'authentification Pocket pour importer les données (https://getpocket.com/developer/docs/authentication) -shaarli_url: URL de Shaarli, si le service Diaspora est activé +shaarli_url: URL de Shaarli, si le service Shaarli est activé share_diaspora: Activer le partage vers Diaspora share_mail: Activer le partage par email share_shaarli: Activer le partage vers Shaarli