]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge remote-tracking branch 'origin/master' into 2.1
authorJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 19 Sep 2016 09:23:07 +0000 (11:23 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 19 Sep 2016 09:23:07 +0000 (11:23 +0200)
1  2 
app/config/config.yml
src/Wallabag/CoreBundle/Command/InstallCommand.php
src/Wallabag/CoreBundle/Helper/EntriesExport.php
tests/Wallabag/CoreBundle/Command/InstallCommandTest.php

diff --combined app/config/config.yml
index 4b869c4f36cede65e96b809d7bcab93085e3ab06,2b11937c78f258f6fc895a6408ace3fb726ea8db..b3d713044259d2929ebcad42a7ea024251bb72af
@@@ -30,7 -30,7 +30,7 @@@ framework
      assets: ~
  
  wallabag_core:
-     version: 2.0.7
+     version: 2.0.8
      paypal_url: "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9UBA65LG3FX9Y&lc=gb"
      languages:
          en: 'English'
      language: en
      rss_limit: 50
      reading_speed: 1
 +    cache_lifetime: 10
 +
 +wallabag_user:
 +    registration_enabled: "%fosuser_registration%"
  
  wallabag_import:
      allow_mimetypes: ['application/octet-stream', 'application/json', 'text/plain']
@@@ -65,6 -61,19 +65,6 @@@ twig
      form_themes:
          - "LexikFormFilterBundle:Form:form_div_layout.html.twig"
  
 -# Assetic Configuration
 -assetic:
 -    debug: "%kernel.debug%"
 -    use_controller: false
 -    bundles:        [ ]
 -    #java: /usr/bin/java
 -    filters:
 -        cssrewrite: ~
 -        #closure:
 -        #    jar: "%kernel.root_dir%/Resources/java/compiler.jar"
 -        #yui_css:
 -        #    jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
 -
  # Doctrine Configuration
  doctrine:
      dbal:
@@@ -215,67 -224,3 +215,67 @@@ lexik_maintenance
      response:
          code: 503
          status: "wallabag Service Temporarily Unavailable"
 +
 +old_sound_rabbit_mq:
 +    connections:
 +        default:
 +            host:     "%rabbitmq_host%"
 +            port:     "%rabbitmq_port%"
 +            user:     "%rabbitmq_user%"
 +            password: "%rabbitmq_password%"
 +            vhost:    /
 +            lazy:     true
 +    producers:
 +        import_pocket:
 +            connection: default
 +            exchange_options:
 +                name: 'wallabag.import.pocket'
 +                type: topic
 +        import_readability:
 +            connection: default
 +            exchange_options:
 +                name: 'wallabag.import.readability'
 +                type: topic
 +        import_wallabag_v1:
 +            connection: default
 +            exchange_options:
 +                name: 'wallabag.import.wallabag_v1'
 +                type: topic
 +        import_wallabag_v2:
 +            connection: default
 +            exchange_options:
 +                name: 'wallabag.import.wallabag_v2'
 +                type: topic
 +    consumers:
 +        import_pocket:
 +            connection: default
 +            exchange_options:
 +                name: 'wallabag.import.pocket'
 +                type: topic
 +            queue_options:
 +                name: 'wallabag.import.pocket'
 +            callback: wallabag_import.consumer.amqp.pocket
 +        import_readability:
 +            connection: default
 +            exchange_options:
 +                name: 'wallabag.import.readability'
 +                type: topic
 +            queue_options:
 +                name: 'wallabag.import.readability'
 +            callback: wallabag_import.consumer.amqp.readability
 +        import_wallabag_v1:
 +            connection: default
 +            exchange_options:
 +                name: 'wallabag.import.wallabag_v1'
 +                type: topic
 +            queue_options:
 +                name: 'wallabag.import.wallabag_v1'
 +            callback: wallabag_import.consumer.amqp.wallabag_v1
 +        import_wallabag_v2:
 +            connection: default
 +            exchange_options:
 +                name: 'wallabag.import.wallabag_v2'
 +                type: topic
 +            queue_options:
 +                name: 'wallabag.import.wallabag_v2'
 +            callback: wallabag_import.consumer.amqp.wallabag_v2
index bd7b55f924ed2e60db89b0a4e002125cfa655a2f,035eb865575a038bd8c338c5635178c79bc702ac..3873d2d366762b88241874bb27415696b0b1cca3
@@@ -61,6 -61,7 +61,6 @@@ class InstallCommand extends ContainerA
              ->setupDatabase()
              ->setupAdmin()
              ->setupConfig()
 -            ->setupAsset()
          ;
  
          $output->writeln('<info>Wallabag has been successfully installed.</info>');
  
      protected function checkRequirements()
      {
 -        $this->defaultOutput->writeln('<info><comment>Step 1 of 5.</comment> Checking system requirements.</info>');
 +        $this->defaultOutput->writeln('<info><comment>Step 1 of 4.</comment> Checking system requirements.</info>');
  
-         $fulfilled = true;
+         $rows = [];
  
+         // testing if database driver exists
+         $fulfilled = true;
          $label = '<comment>PDO Driver</comment>';
          $status = '<info>OK!</info>';
          $help = '';
              $help = 'Database driver "'.$this->getContainer()->getParameter('database_driver').'" is not installed.';
          }
  
-         $rows = [];
+         $rows[] = [$label, $status, $help];
+         // testing if connection to the database can be etablished
+         $label = '<comment>Database connection</comment>';
+         $status = '<info>OK!</info>';
+         $help = '';
+         try {
+             $this->getContainer()->get('doctrine')->getManager()->getConnection()->connect();
+         } catch (\Exception $e) {
+             if (false === strpos($e->getMessage(), 'Unknown database')) {
+                 $fulfilled = false;
+                 $status = '<error>ERROR!</error>';
+                 $help = 'Can\'t connect to the database: '.$e->getMessage();
+             }
+         }
          $rows[] = [$label, $status, $help];
  
          foreach ($this->functionExists as $functionRequired) {
  
      protected function setupDatabase()
      {
 -        $this->defaultOutput->writeln('<info><comment>Step 2 of 5.</comment> Setting up database.</info>');
 +        $this->defaultOutput->writeln('<info><comment>Step 2 of 4.</comment> Setting up database.</info>');
  
          // user want to reset everything? Don't care about what is already here
          if (true === $this->defaultInput->getOption('reset')) {
  
      protected function setupAdmin()
      {
 -        $this->defaultOutput->writeln('<info><comment>Step 3 of 5.</comment> Administration setup.</info>');
 +        $this->defaultOutput->writeln('<info><comment>Step 3 of 4.</comment> Administration setup.</info>');
  
          $questionHelper = $this->getHelperSet()->get('question');
          $question = new ConfirmationQuestion('Would you like to create a new admin user (recommended) ? (Y/n)', true);
  
      protected function setupConfig()
      {
 -        $this->defaultOutput->writeln('<info><comment>Step 4 of 5.</comment> Config setup.</info>');
 +        $this->defaultOutput->writeln('<info><comment>Step 4 of 4.</comment> Config setup.</info>');
          $em = $this->getContainer()->get('doctrine.orm.entity_manager');
  
          // cleanup before insert new stuff
          $em->createQuery('DELETE FROM CraueConfigBundle:Setting')->execute();
  
          $settings = [
 +            [
 +                'name' => 'share_public',
 +                'value' => '1',
 +                'section' => 'entry',
 +            ],
              [
                  'name' => 'carrot',
                  'value' => '1',
                  'section' => 'export',
              ],
              [
 -                'name' => 'pocket_consumer_key',
 -                'value' => null,
 +                'name' => 'import_with_redis',
 +                'value' => '0',
 +                'section' => 'import',
 +            ],
 +            [
 +                'name' => 'import_with_rabbitmq',
 +                'value' => '0',
                  'section' => 'import',
              ],
              [
          return $this;
      }
  
 -    protected function setupAsset()
 -    {
 -        $this->defaultOutput->writeln('<info><comment>Step 5 of 5.</comment> Installing assets.</info>');
 -
 -        $this
 -            ->runCommand('assets:install')
 -            ->runCommand('assetic:dump')
 -        ;
 -
 -        $this->defaultOutput->writeln('');
 -
 -        return $this;
 -    }
 -
      /**
       * Run a command.
       *
          }
  
          // custom verification for sqlite, since `getListDatabasesSQL` doesn't work for sqlite
-         if ('sqlite' == $schemaManager->getDatabasePlatform()->getName()) {
+         if ('sqlite' === $schemaManager->getDatabasePlatform()->getName()) {
              $params = $this->getContainer()->get('doctrine.dbal.default_connection')->getParams();
  
              if (isset($params['path']) && file_exists($params['path'])) {
index 7327631926e418a04feb37bbb260026533a43ba2,e91007e1ba7eeccb6781e601a770ebfcb182bd5d..1dfa12c8bf99480e967f40a58be5d4e9fadc4a83
@@@ -163,8 -163,12 +163,12 @@@ class EntriesExpor
                  $book->setSubject($tag['value']);
              }
  
+             // the reader in Kobo Devices doesn't likes special caracters
+             // in filenames, we limit to A-z/0-9
+             $filename = preg_replace('/[^A-Za-z0-9\-]/', '', $entry->getTitle());
              $chapter = $content_start.$entry->getContent().$bookEnd;
-             $book->addChapter($entry->getTitle(), htmlspecialchars($entry->getTitle()).'.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
+             $book->addChapter($entry->getTitle(), htmlspecialchars($filename).'.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
          }
  
          return Response::create(
          $enclosure = '"';
          $handle = fopen('php://memory', 'rb+');
  
 -        fputcsv($handle, ['Title', 'URL', 'Content', 'Tags', 'MIME Type', 'Language'], $delimiter, $enclosure);
 +        fputcsv($handle, ['Title', 'URL', 'Content', 'Tags', 'MIME Type', 'Language', 'Creation date'], $delimiter, $enclosure);
  
          foreach ($this->entries as $entry) {
              fputcsv(
                      implode(', ', $entry->getTags()->toArray()),
                      $entry->getMimetype(),
                      $entry->getLanguage(),
 +                    $entry->getCreatedAt()->format('d/m/Y h:i:s'),
                  ],
                  $delimiter,
                  $enclosure
index 07ff2772e05d4b7f50255975f3d44f4347c8065f,83f5bf2461cbb16d69f3cc90426602801f7782bb..1bfd41d50817966b1d70927c0809d6c75870c8cf
@@@ -33,7 -33,7 +33,7 @@@ class InstallCommandTest extends Wallab
      }
  
      /**
 -     * Ensure next tests will have a clean database
 +     * Ensure next tests will have a clean database.
       */
      public static function tearDownAfterClass()
      {
@@@ -87,6 -87,7 +87,6 @@@
          $this->assertContains('Setting up database.', $tester->getDisplay());
          $this->assertContains('Administration setup.', $tester->getDisplay());
          $this->assertContains('Config setup.', $tester->getDisplay());
 -        $this->assertContains('Installing assets.', $tester->getDisplay());
      }
  
      public function testRunInstallCommandWithReset()
          $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay());
          $this->assertContains('Administration setup.', $tester->getDisplay());
          $this->assertContains('Config setup.', $tester->getDisplay());
 -        $this->assertContains('Installing assets.', $tester->getDisplay());
  
          // we force to reset everything
          $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay());
  
      public function testRunInstallCommandWithDatabaseRemoved()
      {
+         // skipped SQLite check when database is removed because while testing for the connection,
+         // the driver will create the file (so the database) before testing if database exist
+         if ($this->getClient()->getContainer()->get('doctrine')->getConnection()->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver) {
+             $this->markTestSkipped('SQLite spotted: can\'t test with database removed.');
+         }
          $application = new Application($this->getClient()->getKernel());
          $application->add(new DropDatabaseDoctrineCommand());
  
          $this->assertContains('Setting up database.', $tester->getDisplay());
          $this->assertContains('Administration setup.', $tester->getDisplay());
          $this->assertContains('Config setup.', $tester->getDisplay());
 -        $this->assertContains('Installing assets.', $tester->getDisplay());
  
          // the current database doesn't already exist
          $this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay());
          $this->assertContains('Setting up database.', $tester->getDisplay());
          $this->assertContains('Administration setup.', $tester->getDisplay());
          $this->assertContains('Config setup.', $tester->getDisplay());
 -        $this->assertContains('Installing assets.', $tester->getDisplay());
  
          $this->assertContains('Droping schema and creating schema', $tester->getDisplay());
      }
          $this->assertContains('Setting up database.', $tester->getDisplay());
          $this->assertContains('Administration setup.', $tester->getDisplay());
          $this->assertContains('Config setup.', $tester->getDisplay());
 -        $this->assertContains('Installing assets.', $tester->getDisplay());
  
          $this->assertContains('Creating schema', $tester->getDisplay());
      }
          $this->assertContains('Setting up database.', $tester->getDisplay());
          $this->assertContains('Administration setup.', $tester->getDisplay());
          $this->assertContains('Config setup.', $tester->getDisplay());
 -        $this->assertContains('Installing assets.', $tester->getDisplay());
      }
  }