mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-26 19:11:07 +00:00
Merge pull request #2601 from wallabag/store-http-status
Added http_status in Entry entity
This commit is contained in:
commit
8add306204
23 changed files with 196 additions and 0 deletions
47
app/DoctrineMigrations/Version20161118134328.php
Normal file
47
app/DoctrineMigrations/Version20161118134328.php
Normal file
|
@ -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 VARCHAR(3) DEFAULT NULL');
|
||||
}
|
||||
|
||||
/**
|
||||
* @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');
|
||||
}
|
||||
}
|
|
@ -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
|
||||
--------
|
||||
|
||||
|
|
|
@ -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
|
||||
------------
|
||||
|
||||
|
|
|
@ -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
|
||||
----------------
|
||||
|
||||
|
|
|
@ -180,6 +180,15 @@ class Entry
|
|||
*/
|
||||
private $isPublic;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="http_status", type="text", 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -90,6 +91,21 @@ 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, [
|
||||
'label' => 'entry.filters.archived_label',
|
||||
])
|
||||
|
|
|
@ -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']);
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -178,6 +178,7 @@ entry:
|
|||
preview_picture_label: 'دارای عکس پیشنمایش'
|
||||
preview_picture_help: 'پیشنمایش عکس'
|
||||
language_label: 'زبان'
|
||||
# http_status_label: 'HTTP status'
|
||||
reading_time:
|
||||
label: 'زمان خواندن به دقیقه'
|
||||
from: 'از'
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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ıç'
|
||||
|
|
|
@ -112,6 +112,13 @@
|
|||
</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) }}
|
||||
|
|
|
@ -162,6 +162,14 @@
|
|||
{{ 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>
|
||||
|
|
|
@ -961,4 +961,61 @@ 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]'));
|
||||
|
||||
$crawler = $client->request('GET', '/all/list');
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
|
||||
$data = [
|
||||
'entry_filter[httpStatus]' => 1024,
|
||||
];
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(7, $crawler->filter('div[class=entry]'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue