]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Added http_status in Entry entity
authorNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 18 Nov 2016 14:09:21 +0000 (15:09 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 18 Nov 2016 14:09:21 +0000 (15:09 +0100)
23 files changed:
app/DoctrineMigrations/Version20161118134328.php [new file with mode: 0644]
docs/de/user/filters.rst
docs/en/user/filters.rst
docs/fr/user/filters.rst
src/Wallabag/CoreBundle/Entity/Entry.php
src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
src/Wallabag/CoreBundle/Helper/ContentProxy.php
src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php

diff --git a/app/DoctrineMigrations/Version20161118134328.php b/app/DoctrineMigrations/Version20161118134328.php
new file mode 100644 (file)
index 0000000..b5413dd
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Schema\Schema;
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Add http_status in `entry_table`
+ */
+class Version20161118134328 extends AbstractMigration implements ContainerAwareInterface
+{
+    /**
+     * @var ContainerInterface
+     */
+    private $container;
+
+    public function setContainer(ContainerInterface $container = null)
+    {
+        $this->container = $container;
+    }
+
+    private function getTable($tableName)
+    {
+        return $this->container->getParameter('database_table_prefix') . $tableName;
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function up(Schema $schema)
+    {
+        $this->addSql('ALTER TABLE '.$this->getTable('entry').' ADD http_status INT DEFAULT 0');
+    }
+
+    /**
+     * @param Schema $schema
+     */
+    public function down(Schema $schema)
+    {
+        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.');
+
+        $this->addSql('ALTER TABLE '.$this->getTable('entry').' DROP http_status');
+    }
+}
index c9cda6b6926b1dd43958887d0703b1fc68940ce6..94b82b24418e49f2373415f9c44f851b1dc06f8d 100644 (file)
@@ -30,6 +30,11 @@ Sprache
 wallabag (via graby) kann die Artikelsprache erkennen. Es ist einfach für dich, Artikel
 in einer bestimmten Sprache zu filtern.
 
+HTTP status
+-----------
+
+You can retrieve the articles by filtering by their HTTP status code: 200, 404, 500, etc.
+
 Lesezeit
 --------
 
index ad06819bb06c54ae780651bcee02ea6666f8f091..de0da016641b88ced0d4edf4bbc8a5c9f279058e 100644 (file)
@@ -30,6 +30,11 @@ Language
 wallabag (via graby) can detect article language. It's easy to you to retrieve articles
 written in a specific language.
 
+HTTP status
+-----------
+
+You can retrieve the articles by filtering by their HTTP status code: 200, 404, 500, etc.
+
 Reading time
 ------------
 
index 6592f140454cc8da2fddb96e6cc7a4c115edb4e6..b20d0d8633c09ed5defe372b792f8c324e1ed2c1 100644 (file)
@@ -30,6 +30,11 @@ Langage
 wallabag (via graby) peut détecter la langue dans laquelle l'article est écrit.
 C'est ainsi facile pour vous de retrouver des articles écrits dans une langue spécifique.
 
+Statut HTTP
+-----------
+
+Vous pouvez retrouver des articles en filtrant par leur code HTTP : 200, 404, 500, etc.
+
 Temps de lecture
 ----------------
 
index f59c445f3f12bf1215642dcaf1f549cdb9062dcc..31e594bf349f7f1aff92a9829b430e1d57d47a8f 100644 (file)
@@ -180,6 +180,15 @@ class Entry
      */
     private $isPublic;
 
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="http_status", type="integer", nullable=true)
+     *
+     * @Groups({"entries_for_user", "export_all"})
+     */
+    private $httpStatus;
+
     /**
      * @Exclude
      *
@@ -669,4 +678,24 @@ class Entry
     {
         $this->uuid = null;
     }
+
+    /**
+     * @return int
+     */
+    public function getHttpStatus()
+    {
+        return $this->httpStatus;
+    }
+
+    /**
+     * @param int $httpStatus
+     *
+     * @return Entry
+     */
+    public function setHttpStatus($httpStatus)
+    {
+        $this->httpStatus = $httpStatus;
+
+        return $this;
+    }
 }
index 3c597b5db51a44af1619364297776df744c8ef3c..38321d17b05855ea596b02aa5c784370da24031a 100644 (file)
@@ -90,6 +90,9 @@ class EntryFilterType extends AbstractType
                 },
                 'label' => 'entry.filters.domain_label',
             ])
+            ->add('httpStatus', TextFilterType::class, [
+                'label' => 'entry.filters.http_status_label',
+            ])
             ->add('isArchived', CheckboxFilterType::class, [
                 'label' => 'entry.filters.archived_label',
             ])
index 1986ab334f2e6d9dd520a8a8adabc977a45246c1..178910abbfc848a87a9888f839d8a593677ace61 100644 (file)
@@ -66,6 +66,7 @@ class ContentProxy
         $entry->setUrl($content['url'] ?: $url);
         $entry->setTitle($title);
         $entry->setContent($html);
+        $entry->setHttpStatus(isset($content['status']) ? $content['status'] : '');
 
         $entry->setLanguage($content['language']);
         $entry->setMimetype($content['content_type']);
index c24c59653232be995bbce4150240135af38b52b5..c41a2b1a822279ceb8ebedef034be5ed6c0b48bd 100644 (file)
@@ -178,6 +178,7 @@ entry:
         preview_picture_label: 'Har et vist billede'
         preview_picture_help: 'Forhåndsvis billede'
         language_label: 'Sprog'
+        # http_status_label: 'HTTP status'
         reading_time:
             label: 'Læsetid i minutter'
             from: 'fra'
index 561d276e5dd84fc421f27ac75177ded6789a445c..c0d815ad43ddabe1baa73ba47685ab5ebec43cd9 100644 (file)
@@ -178,6 +178,7 @@ entry:
         preview_picture_label: 'Vorschaubild vorhanden'
         preview_picture_help: 'Vorschaubild'
         language_label: 'Sprache'
+        # http_status_label: 'HTTP status'
         reading_time:
             label: 'Lesezeit in Minuten'
             from: 'von'
index ec49368c134d047a3f312176384f0bc81d0e9b04..cceff5c7fd13165557305b0ec4562bb8f6987e60 100644 (file)
@@ -178,6 +178,7 @@ entry:
         preview_picture_label: 'Has a preview picture'
         preview_picture_help: 'Preview picture'
         language_label: 'Language'
+        http_status_label: 'HTTP status'
         reading_time:
             label: 'Reading time in minutes'
             from: 'from'
index 15d0c3cf0496f81aa6c6d5314675b1e25217ee52..358c1999e11073120d54afd0def51dd1ac06464f 100644 (file)
@@ -178,6 +178,7 @@ entry:
         preview_picture_label: 'Hay una foto'
         preview_picture_help: 'Foto de preview'
         language_label: 'Idioma'
+        # http_status_label: 'HTTP status'
         reading_time:
             label: 'Duración de lectura en minutos'
             from: 'de'
index e7fa4f8667792f1bba2e1aa9240800ccf0429b49..0546815ea1f4f1eaea4739aad4da7c3d441c54ab 100644 (file)
@@ -178,6 +178,7 @@ entry:
         preview_picture_label: 'دارای عکس پیش‌نمایش'
         preview_picture_help: 'پیش‌نمایش عکس'
         language_label: 'زبان'
+        # http_status_label: 'HTTP status'
         reading_time:
             label: 'زمان خواندن به دقیقه'
             from: 'از'
index f85a797d19e7c59d9107d8e87548ace936223395..ec90f9af784d003df4f23d313f0abaa5bc5d5fe3 100644 (file)
@@ -178,6 +178,7 @@ entry:
         preview_picture_label: "A une photo"
         preview_picture_help: "Photo"
         language_label: "Langue"
+        http_status_label: 'Statut HTTP'
         reading_time:
             label: "Durée de lecture en minutes"
             from: "de"
index 8a8469d2c7d57d668f329c4ce64b5dfb42dee3be..2c9924aa13a4df5d8e20d9f90c81c7cbe1f93610 100644 (file)
@@ -178,6 +178,7 @@ entry:
         preview_picture_label: "Ha un'immagine di anteprima"
         preview_picture_help: 'Immagine di anteprima'
         language_label: 'Lingua'
+        # http_status_label: 'HTTP status'
         reading_time:
             label: 'Tempo di lettura in minuti'
             from: 'da'
index d37dc724eabd9bc81f3766329b3f349ccbff38a8..4af8b8fccce4310b1a710858a4693b8aba4cbd65 100644 (file)
@@ -178,6 +178,7 @@ entry:
         preview_picture_label: 'A una fotò'
         preview_picture_help: 'Fotò'
         language_label: 'Lenga'
+        # http_status_label: 'HTTP status'
         reading_time:
             label: 'Durada de lectura en minutas'
             from: 'de'
index da95e470edf4c8c42fc9a6bd34e6eba89a49ff82..53c60ad2f4d1eb0e9d4b3d7ccb0242a4288a5d23 100644 (file)
@@ -178,6 +178,7 @@ entry:
         preview_picture_label: 'Posiada podgląd obrazu'
         preview_picture_help: 'Podgląd obrazu'
         language_label: 'Język'
+        # http_status_label: 'HTTP status'
         reading_time:
             label: 'Czas czytania w minutach'
             from: 'od'
index 5d2607af5073fee8f4f1512dda384754c838c2f4..4b02cf360ee92542a62839feca0210bac6bf2de7 100644 (file)
@@ -178,6 +178,7 @@ entry:
         preview_picture_label: 'Possui uma imagem de preview'
         preview_picture_help: 'Imagem de preview'
         language_label: 'Idioma'
+        # http_status_label: 'HTTP status'
         reading_time:
             label: 'Tempo de leitura em minutos'
             from: 'de'
index 6b51d9ceb01ad25c8128d2caac309201ad2863f8..a8f5aad3cccf4a091d32ec600d1b152bd25944c5 100644 (file)
@@ -178,6 +178,7 @@ entry:
         preview_picture_label: 'Are o imagine de previzualizare'
         preview_picture_help: 'Previzualizare imagine'
         language_label: 'Limbă'
+        # http_status_label: 'HTTP status'
         reading_time:
             label: 'Timp de citire în minute'
             from: 'de la'
index 9c392433608bfb10c0ccb5c6252c76ced56f318c..7cc0a54eefd9048bc898eeb7189a748d665d1206 100644 (file)
@@ -178,6 +178,7 @@ entry:
         preview_picture_label: 'Resim önizlemesi varsa'
         preview_picture_help: 'Resim önizlemesi'
         language_label: 'Dil'
+        # http_status_label: 'HTTP status'
         reading_time:
             label: 'Dakika cinsinden okuma süresi'
             from: 'başlangıç'
index 5d657c7e7cb9a8bed158a52d9d01da3e7eb70ea5..86c1c5ec1dfaa031cc84a4cb68780fff9850f1e5 100644 (file)
                 </div>
             </div>
 
+            <div id="filter-http-status" class="filter-group">
+                {{ form_label(form.httpStatus) }}
+                <div class="input-field ">
+                    {{ form_widget(form.httpStatus) }}
+                </div>
+            </div>
+
             <div id="filter-reading-time" class="filter-group">
                 <div class="">
                     {{ form_label(form.readingTime) }}
index 1225e68060d29934fac9e93c675b43f9b896eb96..a0205ffb610375f0e17bff1bb8857a5050979b28 100644 (file)
                     {{ form_widget(form.language) }}
                 </div>
 
+                <div class="col s12">
+                    {{ form_label(form.httpStatus) }}
+                </div>
+
+                <div class="input-field col s12">
+                    {{ form_widget(form.httpStatus) }}
+                </div>
+
                 <div class="col s12">
                     {{ form_label(form.readingTime) }}
                 </div>
index bf4e0543f87fdf1d6adcf5a9b6c86f91435d335d..771903fe0dd810e8bd4454089312d5b822fcfef3 100644 (file)
@@ -961,4 +961,50 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->assertEquals(302, $client->getResponse()->getStatusCode());
         $this->assertContains('/view/'.$content->getId(), $client->getResponse()->headers->get('location'));
     }
+
+    public function testFilterOnHttpStatus()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/new');
+        $form = $crawler->filter('form[name=entry]')->form();
+
+        $data = [
+            'entry[url]' => 'http://www.lemonde.fr/incorrect-url/',
+        ];
+
+        $client->submit($form, $data);
+
+        $crawler = $client->request('GET', '/all/list');
+        $form = $crawler->filter('button[id=submit-filter]')->form();
+
+        $data = [
+            'entry_filter[httpStatus]' => 404,
+        ];
+
+        $crawler = $client->submit($form, $data);
+
+        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+
+        $crawler = $client->request('GET', '/new');
+        $form = $crawler->filter('form[name=entry]')->form();
+
+        $data = [
+            'entry[url]' => 'http://www.nextinpact.com/news/101235-wallabag-alternative-libre-a-pocket-creuse-petit-a-petit-son-nid.htm',
+        ];
+
+        $client->submit($form, $data);
+
+        $crawler = $client->request('GET', '/all/list');
+        $form = $crawler->filter('button[id=submit-filter]')->form();
+
+        $data = [
+            'entry_filter[httpStatus]' => 200,
+        ];
+
+        $crawler = $client->submit($form, $data);
+
+        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+    }
 }
index 5d772602a209e1b19be646372c62d9b905ceb6e7..33b3ff2a53d4e6d58f64a242caf9831a12fe40cc 100644 (file)
@@ -97,6 +97,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
                 'url' => '',
                 'content_type' => '',
                 'language' => '',
+                'status' => '',
                 'open_graph' => [
                     'og_title' => 'my title',
                     'og_description' => 'desc',
@@ -111,6 +112,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals('<p>Unable to retrieve readable content.</p><p><i>But we found a short description: </i></p>desc', $entry->getContent());
         $this->assertEmpty($entry->getPreviewPicture());
         $this->assertEmpty($entry->getLanguage());
+        $this->assertEmpty($entry->getHttpStatus());
         $this->assertEmpty($entry->getMimetype());
         $this->assertEquals(0.0, $entry->getReadingTime());
         $this->assertEquals('domain.io', $entry->getDomainName());
@@ -135,6 +137,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
                 'url' => 'http://1.1.1.1',
                 'content_type' => 'text/html',
                 'language' => 'fr',
+                'status' => '200',
                 'open_graph' => [
                     'og_title' => 'my OG title',
                     'og_description' => 'OG desc',
@@ -151,6 +154,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
         $this->assertEquals('text/html', $entry->getMimetype());
         $this->assertEquals('fr', $entry->getLanguage());
+        $this->assertEquals('200', $entry->getHttpStatus());
         $this->assertEquals(4.0, $entry->getReadingTime());
         $this->assertEquals('1.1.1.1', $entry->getDomainName());
     }