From: Jeremy Benoist Date: Thu, 4 Feb 2016 16:46:02 +0000 (+0100) Subject: Merge pull request #1642 from wallabag/v2-escape-preview X-Git-Tag: 2.0.0-beta.1~55 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=27c837dcd1640a7f5f0ed197e882eefd53ba8273;hp=0796532460b90cb3ef7ecbf86db6d0adc07c88b4;p=github%2Fwallabag%2Fwallabag.git Merge pull request #1642 from wallabag/v2-escape-preview Unescape content for Material card --- diff --git a/app/AppKernel.php b/app/AppKernel.php index 7e76a9e9..82d3aa38 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/.gitkeep b/app/DoctrineMigrations/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml new file mode 100644 index 00000000..6d86eab6 --- /dev/null +++ b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml @@ -0,0 +1,19 @@ +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 +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: Shaarli URL, 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 00000000..cdd56acd --- /dev/null +++ b/app/Resources/CraueConfigBundle/translations/CraueConfigBundle.fr.yml @@ -0,0 +1,19 @@ +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 +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 Shaarli 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 00000000..f44db420 --- /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 %} +
+
+
+ {{ form_start(form, {'attr': {'class': 'craue_config_settings_modify'}}) }} + {{ form_errors(form) }} + +
+
+ +
+ + {% for section in sections | craue_sortSections %} +
+ {% 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 %} +
+ {% endfor %} +
+ + + + {{ form_rest(form) }} + {{ form_end(form) }} +
+
+
+{% endblock %} diff --git a/app/config/config.yml b/app/config/config.yml index a6cfc67d..7dac4d3b 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -28,11 +28,17 @@ framework: assets: ~ wallabag_core: + 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' 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'] @@ -42,29 +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% - 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" @@ -185,7 +168,7 @@ fos_user: user_class: Wallabag\UserBundle\Entity\User registration: confirmation: - enabled: true + enabled: %fosuser_confirmation% from_email: address: %from_email% sender_name: wallabag diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index ac4a4cc8..7c7413fb 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -37,43 +37,11 @@ parameters: # A secret key that's used to generate certain security-related tokens secret: ovmpmAWXRCabNlMgzlzFXDYmCFfzGv - # wallabag misc - app.version: 2.0.0-alpha + # two factor stuff 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 our issues list and open a new if necessary + # fosuser stuff + fosuser_confirmation: true - 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' - - # 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/routing.yml b/app/config/routing.yml index 84b98d23..c491d35d 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 a99a7d80..7c10889f 100644 --- a/app/config/security.yml +++ b/app/config/security.yml @@ -57,4 +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: ^/settings, roles: ROLE_SUPER_ADMIN } - { path: ^/, roles: ROLE_USER } diff --git a/app/config/tests/parameters.yml.dist.mysql b/app/config/tests/parameters.yml.dist.mysql index 3b9262bb..1951f021 100644 --- a/app/config/tests/parameters.yml.dist.mysql +++ b/app/config/tests/parameters.yml.dist.mysql @@ -27,43 +27,11 @@ 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 - # 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 our issues list and open a new if necessary + # fosuser stuff + fosuser_confirmation: true - 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' - - # 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 a5aef028..36ad6cde 100644 --- a/app/config/tests/parameters.yml.dist.pgsql +++ b/app/config/tests/parameters.yml.dist.pgsql @@ -27,43 +27,11 @@ 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 - # 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 our issues list and open a new if necessary + # fosuser stuff + fosuser_confirmation: true - 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' - - # 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 cdafb1b1..6564014a 100644 --- a/app/config/tests/parameters.yml.dist.sqlite +++ b/app/config/tests/parameters.yml.dist.sqlite @@ -27,43 +27,11 @@ 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 - # 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 our issues list and open a new if necessary + # fosuser stuff + fosuser_confirmation: true - 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' - - # 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/composer.json b/composer.json index d84e1f8b..497b8012 100644 --- a/composer.json +++ b/composer.json @@ -54,8 +54,8 @@ "pagerfanta/pagerfanta": "~1.0.3", "lexik/form-filter-bundle": "~5.0", "j0k3r/graby": "~1.0", - "friendsofsymfony/user-bundle": "dev-master", - "friendsofsymfony/oauth-server-bundle": "^1.5@dev", + "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", "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/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 63032dbb..e6a06eea 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 { @@ -204,13 +205,122 @@ 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); + // 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' => '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, + '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/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index b01aaa7f..b7799746 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->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); @@ -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/RssController.php b/src/Wallabag/CoreBundle/Controller/RssController.php index 2b7ef598..a4f7a200 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( diff --git a/src/Wallabag/CoreBundle/Controller/StaticController.php b/src/Wallabag/CoreBundle/Controller/StaticController.php index 9ada371b..5b7bd56e 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/DataFixtures/ORM/LoadSettingData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php new file mode 100644 index 00000000..5e89c2a9 --- /dev/null +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php @@ -0,0 +1,133 @@ + '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' => '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, + '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; + } +} diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index 32acd1f1..bc405fdc 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php @@ -17,6 +17,22 @@ 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() + ->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 9ff9b732..9b4703e4 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php @@ -13,7 +13,14 @@ 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']); + $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 31a80d6e..965a40b6 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 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 7d24d488..a8796fe4 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: @@ -76,17 +76,17 @@ 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 } 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 20f4352b..cc814cc4 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/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig index 9e515a17..1742b4aa 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 %}
- {{ warning_message | raw }} + You're trying wallabag v2, which is in alpha version. If you find a bug, please have a look to our issues list and open a new if necessary
- {% endif %} 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 c23d0e27..27a88287 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 @@
  • {% if entry.isArchived == 0 %}{% trans %}Mark as read{% endtrans %}{% else %}{% trans %}Mark as unread{% endtrans %}{% endif %}
  • {% trans %}Toggle favorite{% endtrans %}
  • {% trans %}Delete{% endtrans %}
  • - {% if share_twitter %}
  • {% endif %} - {% if share_mail %}
  • {% endif %} - {% if share_shaarli %}
  • {% trans %}shaarli{% endtrans %}
  • {% endif %} - {% if share_diaspora %}
  • {% trans %}diaspora{% endtrans %}
  • {% endif %} - {# {% if flattr %}{% if flattr.status == flattrable %}
  • {% trans %}flattr{% endtrans %}
  • {% elseif flattr.status == flattred %}
  • Carrot
  • {% endif %} - {% if show_printlink %}
  • {% trans %}Print{% endtrans %}
  • {% endif %} - {% if export_epub %}
  • EPUB
  • {% endif %} - {% if export_mobi %}
  • MOBI
  • {% endif %} - {% if export_pdf %}
  • PDF
  • {% endif %} + {% if craue_setting('share_twitter') %}
  • {% endif %} + {% if craue_setting('share_mail') %}
  • {% endif %} + {% if craue_setting('share_shaarli') %}
  • {% trans %}shaarli{% endtrans %}
  • {% endif %} + {% if craue_setting('share_diaspora') %}
  • {% trans %}diaspora{% endtrans %}
  • {% endif %} + {% if craue_setting('carrot') %}
  • Carrot
  • {% endif %} + {% if craue_setting('show_printlink') %}
  • {% trans %}Print{% endtrans %}
  • {% endif %} + {% if craue_setting('export_epub') %}
  • EPUB
  • {% endif %} + {% if craue_setting('export_mobi') %}
  • MOBI
  • {% endif %} + {% if craue_setting('export_pdf') %}
  • PDF
  • {% endif %}
  • {% trans %}Does this article appear wrong?{% endtrans %}
  • 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 3aead497..b630070c 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 @@
  • {% trans %}config{% endtrans %}
  • + {% if is_granted('ROLE_SUPER_ADMIN') %} +
  • {% trans %}internal settings{% endtrans %}
  • + {% endif %}
  • {% trans %}import{% endtrans %}
  • {% trans %}howto{% endtrans %}
  • {% trans %}about{% endtrans %}
  • 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 8743dc1d..1cae90a4 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 @@
    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 0c35de2d..8ad24fbf 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 @@ -101,13 +101,13 @@ {% endif %}

    {% trans %}Export{% endtrans %}

    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 31963ae8..dad96187 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 @@
    @@ -114,13 +113,13 @@
    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 a8b6dc3f..dff9e612 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 @@
  • {% trans %}all{% endtrans %}
  • {% trans %}tags{% endtrans %}
  • {% trans %}config{% endtrans %}
  • + {% if is_granted('ROLE_SUPER_ADMIN') %} +
  • {% trans %}internal settings{% endtrans %}
  • + {% endif %}
  • {% trans %}import{% endtrans %}
  • {% trans %}howto{% endtrans %}
  • {% trans %}logout{% endtrans %}
  • diff --git a/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php b/src/Wallabag/CoreBundle/Tests/Command/InstallCommandTest.php index 7d75e2b7..a79d7b90 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/CoreBundle/Tests/Controller/SettingsControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SettingsControllerTest.php new file mode 100644 index 00000000..fd698b3e --- /dev/null +++ b/src/Wallabag/CoreBundle/Tests/Controller/SettingsControllerTest.php @@ -0,0 +1,32 @@ +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()); + } +} diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php index 7aee302f..1c1b4fa8 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/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index 617d5514..22932238 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 { @@ -24,12 +25,12 @@ class PocketImport implements ImportInterface private $importedEntries = 0; protected $accessToken; - 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 6a11892e..e0942b1a 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/Resources/views/Pocket/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig index 643ad775..e0e36f38 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 @@
    + {% if not has_consumer_key %} +
    + {% trans %}Pocket import isn't configured. You need to define pocket_consumer_key.{% endtrans %} +
    + {% endif %} +
    {{ import.description|trans }}

    {% 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 %}

    diff --git a/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/PocketImportTest.php index 76225fe4..25359d56 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 6b108dd3..d8403491 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. @@ -47,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 */ @@ -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'); } /** @@ -80,7 +80,7 @@ class AuthCodeMailer implements AuthCodeMailerInterface */ public function sendAuthCode(TwoFactorInterface $user) { - $template = $this->twig->loadTemplate('@WallabagUserBundle/Resources/views/TwoFactor/email_auth_code.html.twig'); + $template = $this->twig->loadTemplate('WallabagUserBundle:TwoFactor:email_auth_code.html.twig'); $subject = $template->renderBlock('subject', array()); $bodyHtml = $template->renderBlock('body_html', [ diff --git a/src/Wallabag/UserBundle/Resources/config/services.yml b/src/Wallabag/UserBundle/Resources/config/services.yml index 8321473a..9a589332 100644 --- a/src/Wallabag/UserBundle/Resources/config/services.yml +++ b/src/Wallabag/UserBundle/Resources/config/services.yml @@ -11,8 +11,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 diff --git a/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php b/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php index e3f43a7e..b95e195e 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() { @@ -42,7 +43,15 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase {% block body_text %}text body {{ support_url }}{% endblock %} TWIG; - $this->twig = new \Twig_Environment(new \Twig_Loader_Array(array('@WallabagUserBundle/Resources/views/TwoFactor/email_auth_code.html.twig' => $twigTemplate))); + $this->twig = new \Twig_Environment(new \Twig_Loader_Array(array('WallabagUserBundle: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);