mirror of
https://github.com/wallabag/wallabag.git
synced 2025-01-03 13:28:41 +00:00
Merge pull request #3024 from wallabag/store-date
Added publication date and author
This commit is contained in:
commit
64f1d8f77a
23 changed files with 243 additions and 17 deletions
65
app/DoctrineMigrations/Version20170405182620.php
Normal file
65
app/DoctrineMigrations/Version20170405182620.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?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 published_at and published_by in `entry` table.
|
||||
*/
|
||||
class Version20170405182620 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)
|
||||
{
|
||||
$entryTable = $schema->getTable($this->getTable('entry'));
|
||||
|
||||
$this->skipIf($entryTable->hasColumn('published_at'), 'It seems that you already played this migration.');
|
||||
|
||||
$entryTable->addColumn('published_at', 'datetime', [
|
||||
'notnull' => false,
|
||||
]);
|
||||
|
||||
$this->skipIf($entryTable->hasColumn('published_by'), 'It seems that you already played this migration.');
|
||||
|
||||
$entryTable->addColumn('published_by', 'text', [
|
||||
'notnull' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
$entryTable = $schema->getTable($this->getTable('entry'));
|
||||
|
||||
$this->skipIf(!$entryTable->hasColumn('published_at'), 'It seems that you already played this migration.');
|
||||
|
||||
$entryTable->dropColumn('published_at');
|
||||
|
||||
$this->skipIf(!$entryTable->hasColumn('published_by'), 'It seems that you already played this migration.');
|
||||
|
||||
$entryTable->dropColumn('published_by');
|
||||
}
|
||||
}
|
|
@ -912,6 +912,14 @@ a.add-to-wallabag-link-after::after {
|
|||
content: "\e953";
|
||||
}
|
||||
|
||||
.icon-pencil2::before {
|
||||
content: "\e906";
|
||||
}
|
||||
|
||||
.icon-users::before {
|
||||
content: "\e972";
|
||||
}
|
||||
|
||||
.icon-time::before {
|
||||
content: "\e952";
|
||||
}
|
||||
|
|
|
@ -121,6 +121,24 @@ class Entry
|
|||
*/
|
||||
private $updatedAt;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="published_at", type="datetime", nullable=true)
|
||||
*
|
||||
* @Groups({"entries_for_user", "export_all"})
|
||||
*/
|
||||
private $publishedAt;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(name="published_by", type="json_array", nullable=true)
|
||||
*
|
||||
* @Groups({"entries_for_user", "export_all"})
|
||||
*/
|
||||
private $publishedBy;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Wallabag\AnnotationBundle\Entity\Annotation", mappedBy="entry", cascade={"persist", "remove"})
|
||||
* @ORM\JoinTable
|
||||
|
@ -676,4 +694,44 @@ class Entry
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Datetime
|
||||
*/
|
||||
public function getPublishedAt()
|
||||
{
|
||||
return $this->publishedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Datetime $publishedAt
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
public function setPublishedAt(\Datetime $publishedAt)
|
||||
{
|
||||
$this->publishedAt = $publishedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPublishedBy()
|
||||
{
|
||||
return $this->publishedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $publishedBy
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
public function setPublishedBy($publishedBy)
|
||||
{
|
||||
$this->publishedBy = $publishedBy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,14 @@ class ContentProxy
|
|||
$entry->setContent($html);
|
||||
$entry->setHttpStatus(isset($content['status']) ? $content['status'] : '');
|
||||
|
||||
if (isset($content['date']) && null !== $content['date'] && '' !== $content['date']) {
|
||||
$entry->setPublishedAt(new \DateTime($content['date']));
|
||||
}
|
||||
|
||||
if (!empty($content['authors'])) {
|
||||
$entry->setPublishedBy($content['authors']);
|
||||
}
|
||||
|
||||
$entry->setLanguage(isset($content['language']) ? $content['language'] : '');
|
||||
$entry->setMimetype(isset($content['content_type']) ? $content['content_type'] : '');
|
||||
$entry->setReadingTime(Utils::getReadingTime($html));
|
||||
|
|
|
@ -224,6 +224,8 @@ entry:
|
|||
original_article: 'original'
|
||||
# annotations_on_the_entry: '{0} No annotations|{1} One annotation|]1,Inf[ %count% annotations'
|
||||
created_at: 'Oprettelsesdato'
|
||||
# published_at: 'Publication date'
|
||||
# published_by: 'Published by'
|
||||
new:
|
||||
page_title: 'Gem ny artikel'
|
||||
placeholder: 'http://website.com'
|
||||
|
|
|
@ -224,6 +224,8 @@ entry:
|
|||
original_article: 'original'
|
||||
annotations_on_the_entry: '{0} Keine Anmerkungen|{1} Eine Anmerkung|]1,Inf[ %count% Anmerkungen'
|
||||
created_at: 'Erstellungsdatum'
|
||||
# published_at: 'Publication date'
|
||||
# published_by: 'Published by'
|
||||
new:
|
||||
page_title: 'Neuen Artikel speichern'
|
||||
placeholder: 'https://website.de'
|
||||
|
|
|
@ -224,6 +224,8 @@ entry:
|
|||
original_article: 'original'
|
||||
annotations_on_the_entry: '{0} No annotations|{1} One annotation|]1,Inf[ %count% annotations'
|
||||
created_at: 'Creation date'
|
||||
published_at: 'Publication date'
|
||||
published_by: 'Published by'
|
||||
new:
|
||||
page_title: 'Save new entry'
|
||||
placeholder: 'http://website.com'
|
||||
|
|
|
@ -224,6 +224,8 @@ entry:
|
|||
original_article: 'original'
|
||||
annotations_on_the_entry: '{0} Sin anotaciones|{1} Una anotación|]1,Inf[ %count% anotaciones'
|
||||
created_at: 'Fecha de creación'
|
||||
# published_at: 'Publication date'
|
||||
# published_by: 'Published by'
|
||||
new:
|
||||
page_title: 'Guardar un nuevo artículo'
|
||||
placeholder: 'http://sitioweb.com'
|
||||
|
|
|
@ -224,6 +224,8 @@ entry:
|
|||
original_article: 'اصلی'
|
||||
annotations_on_the_entry: '{0} بدون حاشیه|{1} یک حاشیه|]1,Inf[ %nbحاشیه% annotations'
|
||||
created_at: 'زمان ساخت'
|
||||
# published_at: 'Publication date'
|
||||
# published_by: 'Published by'
|
||||
new:
|
||||
page_title: 'ذخیرهٔ مقالهٔ تازه'
|
||||
placeholder: 'http://website.com'
|
||||
|
|
|
@ -224,6 +224,8 @@ entry:
|
|||
original_article: "original"
|
||||
annotations_on_the_entry: "{0} Aucune annotation|{1} Une annotation|]1,Inf[ %count% annotations"
|
||||
created_at: "Date de création"
|
||||
published_at: "Date de publication"
|
||||
published_by: "Publié par"
|
||||
new:
|
||||
page_title: "Sauvegarder un nouvel article"
|
||||
placeholder: "http://website.com"
|
||||
|
|
|
@ -224,6 +224,8 @@ entry:
|
|||
original_article: 'originale'
|
||||
annotations_on_the_entry: '{0} Nessuna annotazione|{1} Una annotazione|]1,Inf[ %count% annotazioni'
|
||||
created_at: 'Data di creazione'
|
||||
# published_at: 'Publication date'
|
||||
# published_by: 'Published by'
|
||||
new:
|
||||
page_title: 'Salva un nuovo contenuto'
|
||||
placeholder: 'http://website.com'
|
||||
|
|
|
@ -224,6 +224,8 @@ entry:
|
|||
original_article: 'original'
|
||||
annotations_on_the_entry: "{0} Pas cap d'anotacion|{1} Una anotacion|]1,Inf[ %count% anotacions"
|
||||
created_at: 'Data de creacion'
|
||||
# published_at: 'Publication date'
|
||||
# published_by: 'Published by'
|
||||
new:
|
||||
page_title: 'Enregistrar un novèl article'
|
||||
placeholder: 'http://website.com'
|
||||
|
|
|
@ -224,6 +224,8 @@ entry:
|
|||
original_article: 'oryginalny'
|
||||
annotations_on_the_entry: '{0} Nie ma adnotacji |{1} Jedna adnotacja |]1,Inf[ %count% adnotacji'
|
||||
created_at: 'Czas stworzenia'
|
||||
# published_at: 'Publication date'
|
||||
# published_by: 'Published by'
|
||||
new:
|
||||
page_title: 'Zapisz nowy wpis'
|
||||
placeholder: 'http://website.com'
|
||||
|
|
|
@ -224,6 +224,8 @@ entry:
|
|||
original_article: 'original'
|
||||
annotations_on_the_entry: '{0} Sem anotações|{1} Uma anotação|]1,Inf[ %nbAnnotations% anotações'
|
||||
created_at: 'Data de criação'
|
||||
# published_at: 'Publication date'
|
||||
# published_by: 'Published by'
|
||||
new:
|
||||
page_title: 'Salvar nova entrada'
|
||||
placeholder: 'http://website.com'
|
||||
|
|
|
@ -224,6 +224,8 @@ entry:
|
|||
original_article: 'original'
|
||||
# annotations_on_the_entry: '{0} No annotations|{1} One annotation|]1,Inf[ %count% annotations'
|
||||
created_at: 'Data creării'
|
||||
# published_at: 'Publication date'
|
||||
# published_by: 'Published by'
|
||||
new:
|
||||
page_title: 'Salvează un nou articol'
|
||||
placeholder: 'http://website.com'
|
||||
|
|
|
@ -224,6 +224,8 @@ entry:
|
|||
original_article: 'orijinal'
|
||||
# annotations_on_the_entry: '{0} No annotations|{1} One annotation|]1,Inf[ %count% annotations'
|
||||
created_at: 'Oluşturulma tarihi'
|
||||
# published_at: 'Publication date'
|
||||
# published_by: 'Published by'
|
||||
new:
|
||||
page_title: 'Yeni makaleyi kaydet'
|
||||
placeholder: 'http://website.com'
|
||||
|
|
|
@ -44,9 +44,23 @@
|
|||
|
||||
<div id="article-informations">
|
||||
<i class="tool icon icon-calendar" title="{{ 'entry.view.created_at'|trans }}">
|
||||
{{ entry.createdAt|date('Y-m-d') }}
|
||||
{{ entry.createdAt|date('Y-m-d H:i') }}
|
||||
</i>
|
||||
|
||||
{% if entry.publishedAt is not null %}
|
||||
<i class="tool icon icon-pencil2" title="{{ 'entry.view.published_at'|trans }}">
|
||||
{{ entry.publishedAt|date('Y-m-d H:i') }}
|
||||
</i>
|
||||
{% endif %}
|
||||
|
||||
{% if entry.publishedBy is not empty %}
|
||||
<i class="tool icon icon-users" title="{{ 'entry.view.published_by'|trans }}">
|
||||
{% for author in entry.publishedBy %}
|
||||
{{ author }}{% if not loop.last %}, {% endif %}
|
||||
{% endfor %}
|
||||
</i>
|
||||
{% endif %}
|
||||
|
||||
<i class="tool icon icon-time">
|
||||
{% set readingTime = entry.readingTime / app.user.config.readingSpeed %}
|
||||
{% if readingTime > 0 %}
|
||||
|
|
|
@ -226,8 +226,22 @@
|
|||
</li>
|
||||
<li>
|
||||
<i class="material-icons" title="{{ 'entry.view.created_at'|trans }}">today</i>
|
||||
{{ entry.createdAt|date('Y-m-d') }}
|
||||
{{ entry.createdAt|date('Y-m-d H:i') }}
|
||||
</li>
|
||||
{% if entry.publishedAt is not null %}
|
||||
<li>
|
||||
<i class="material-icons" title="{{ 'entry.view.published_at'|trans }}">create</i>
|
||||
{{ entry.publishedAt|date('Y-m-d H:i') }}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if entry.publishedBy is not empty %}
|
||||
<li>
|
||||
<i class="material-icons" title="{{ 'entry.view.published_by'|trans }}">person</i>
|
||||
{% for author in entry.publishedBy %}
|
||||
{{ author }}{% if not loop.last %}, {% endif %}
|
||||
{% endfor %}
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
<i class="material-icons link">link</i>
|
||||
<a href="{{ entry.url|e }}" target="_blank" title="{{ 'entry.view.original_article'|trans }} : {{ entry.title|striptags }}" class="tool">
|
||||
|
|
|
@ -135,9 +135,44 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
|
||||
|
||||
$author = $content->getPublishedBy();
|
||||
|
||||
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
|
||||
$this->assertEquals($this->url, $content->getUrl());
|
||||
$this->assertContains('Google', $content->getTitle());
|
||||
$this->assertEquals('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s'));
|
||||
$this->assertEquals('Morgane Tual', $author[0]);
|
||||
}
|
||||
|
||||
public function testPostWithMultipleAuthors()
|
||||
{
|
||||
$url = 'http://www.liberation.fr/planete/2017/04/05/donald-trump-et-xi-jinping-tentative-de-flirt-en-floride_1560768';
|
||||
$this->logInAs('admin');
|
||||
$client = $this->getClient();
|
||||
|
||||
$crawler = $client->request('GET', '/new');
|
||||
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||
|
||||
$form = $crawler->filter('form[name=entry]')->form();
|
||||
|
||||
$data = [
|
||||
'entry[url]' => $url,
|
||||
];
|
||||
|
||||
$client->submit($form, $data);
|
||||
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
|
||||
$content = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findByUrlAndUserId($url, $this->getLoggedInUserId());
|
||||
|
||||
$authors = $content->getPublishedBy();
|
||||
$this->assertEquals('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s'));
|
||||
$this->assertEquals('Raphaël Balenieri, correspondant à Pékin', $authors[0]);
|
||||
$this->assertEquals('Frédéric Autran, correspondant à New York', $authors[1]);
|
||||
}
|
||||
|
||||
public function testPostNewOkUrlExist()
|
||||
|
@ -606,7 +641,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(2, $crawler->filter('div[class=entry]'));
|
||||
$this->assertCount(3, $crawler->filter('div[class=entry]'));
|
||||
}
|
||||
|
||||
public function testFilterOnReadingTimeOnlyLower()
|
||||
|
@ -642,7 +677,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(4, $crawler->filter('div[class=entry]'));
|
||||
$this->assertCount(5, $crawler->filter('div[class=entry]'));
|
||||
}
|
||||
|
||||
public function testFilterOnCreationDate()
|
||||
|
@ -661,7 +696,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(5, $crawler->filter('div[class=entry]'));
|
||||
$this->assertCount(6, $crawler->filter('div[class=entry]'));
|
||||
|
||||
$data = [
|
||||
'entry_filter[createdAt][left_date]' => date('d/m/Y'),
|
||||
|
@ -670,7 +705,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(5, $crawler->filter('div[class=entry]'));
|
||||
$this->assertCount(6, $crawler->filter('div[class=entry]'));
|
||||
|
||||
$data = [
|
||||
'entry_filter[createdAt][left_date]' => '01/01/1970',
|
||||
|
@ -774,7 +809,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
$form['entry_filter[previewPicture]']->tick();
|
||||
|
||||
$crawler = $client->submit($form);
|
||||
$this->assertCount(1, $crawler->filter('div[class=entry]'));
|
||||
$this->assertCount(2, $crawler->filter('div[class=entry]'));
|
||||
}
|
||||
|
||||
public function testFilterOnLanguage()
|
||||
|
@ -789,7 +824,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
];
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
$this->assertCount(2, $crawler->filter('div[class=entry]'));
|
||||
$this->assertCount(3, $crawler->filter('div[class=entry]'));
|
||||
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
$data = [
|
||||
|
@ -1014,7 +1049,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(1, $crawler->filter('div[class=entry]'));
|
||||
$this->assertCount(2, $crawler->filter('div[class=entry]'));
|
||||
|
||||
$crawler = $client->request('GET', '/all/list');
|
||||
$form = $crawler->filter('button[id=submit-filter]')->form();
|
||||
|
@ -1025,7 +1060,7 @@ class EntryControllerTest extends WallabagCoreTestCase
|
|||
|
||||
$crawler = $client->submit($form, $data);
|
||||
|
||||
$this->assertCount(7, $crawler->filter('div[class=entry]'));
|
||||
$this->assertCount(8, $crawler->filter('div[class=entry]'));
|
||||
}
|
||||
|
||||
public function testSearch()
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue