From 10b3509757c704943aa9cdd69c1d02bedfa937a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 18 Nov 2016 15:09:21 +0100 Subject: Added http_status in Entry entity --- src/Wallabag/CoreBundle/Entity/Entry.php | 29 ++++++++++++++++++++++ .../CoreBundle/Form/Type/EntryFilterType.php | 3 +++ src/Wallabag/CoreBundle/Helper/ContentProxy.php | 1 + .../Resources/translations/messages.da.yml | 1 + .../Resources/translations/messages.de.yml | 1 + .../Resources/translations/messages.en.yml | 1 + .../Resources/translations/messages.es.yml | 1 + .../Resources/translations/messages.fa.yml | 1 + .../Resources/translations/messages.fr.yml | 1 + .../Resources/translations/messages.it.yml | 1 + .../Resources/translations/messages.oc.yml | 1 + .../Resources/translations/messages.pl.yml | 1 + .../Resources/translations/messages.pt.yml | 1 + .../Resources/translations/messages.ro.yml | 1 + .../Resources/translations/messages.tr.yml | 1 + .../views/themes/baggy/Entry/entries.html.twig | 7 ++++++ .../views/themes/material/Entry/entries.html.twig | 8 ++++++ 17 files changed, 60 insertions(+) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index f59c445f..31e594bf 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -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; + } } diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index 3c597b5d..38321d17 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php @@ -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', ]) diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index 1986ab33..178910ab 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php @@ -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']); diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index c24c5965..c41a2b1a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -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' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index 561d276e..c0d815ad 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -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' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index ec49368c..cceff5c7 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -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' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 15d0c3cf..358c1999 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -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' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index e7fa4f86..0546815e 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -178,6 +178,7 @@ entry: preview_picture_label: 'دارای عکس پیش‌نمایش' preview_picture_help: 'پیش‌نمایش عکس' language_label: 'زبان' + # http_status_label: 'HTTP status' reading_time: label: 'زمان خواندن به دقیقه' from: 'از' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index f85a797d..ec90f9af 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -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" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 8a8469d2..2c9924aa 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -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' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index d37dc724..4af8b8fc 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -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' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index da95e470..53c60ad2 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -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' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml index 5d2607af..4b02cf36 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml @@ -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' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 6b51d9ce..a8f5aad3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -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' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 9c392433..7cc0a54e 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -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ıç' diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig index 5d657c7e..86c1c5ec 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig @@ -112,6 +112,13 @@ +
+ {{ form_label(form.httpStatus) }} +
+ {{ form_widget(form.httpStatus) }} +
+
+
{{ form_label(form.readingTime) }} 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 1225e680..a0205ffb 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 @@ -162,6 +162,14 @@ {{ form_widget(form.language) }}
+
+ {{ form_label(form.httpStatus) }} +
+ +
+ {{ form_widget(form.httpStatus) }} +
+
{{ form_label(form.readingTime) }}
-- cgit v1.2.3 From e10e6ab34e62129d57fc69d7b9b69b08c20e6f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 18 Nov 2016 15:55:16 +0100 Subject: Replace http status with a string I don't want to have 0 if we don't fetch status code, I think it's better to have an empty string, mainly for filters --- src/Wallabag/CoreBundle/Entity/Entry.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 31e594bf..3cf9ac1a 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -181,9 +181,9 @@ class Entry private $isPublic; /** - * @var int + * @var string * - * @ORM\Column(name="http_status", type="integer", nullable=true) + * @ORM\Column(name="http_status", type="text", nullable=true) * * @Groups({"entries_for_user", "export_all"}) */ -- cgit v1.2.3 From d215273c65ed7aecf0a1f887c91752eaf41d191b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 18 Nov 2016 23:05:02 +0100 Subject: Check if status code is OK --- src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index 38321d17..8e2883f7 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php @@ -11,6 +11,7 @@ use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType; use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; @@ -91,6 +92,18 @@ class EntryFilterType extends AbstractType 'label' => 'entry.filters.domain_label', ]) ->add('httpStatus', TextFilterType::class, [ + 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { + $value = $values['value']; + if (false === array_key_exists($value, Response::$statusTexts)) { + return; + } + + $paramName = sprintf('%s', str_replace('.', '_', $field)); + $expression = $filterQuery->getExpr()->eq($field, ':'.$paramName); + $parameters = array($paramName => $value); + + return $filterQuery->createCondition($expression, $parameters); + }, 'label' => 'entry.filters.http_status_label', ]) ->add('isArchived', CheckboxFilterType::class, [ -- cgit v1.2.3