Added author of article

This commit is contained in:
Nicolas Lœuillet 2017-04-06 09:36:20 +02:00
parent 5e9009ce86
commit 7b0b3622ab
20 changed files with 79 additions and 6 deletions

View file

@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Add published_at in `entry` table.
* Add published_at and published_by in `entry` table.
*/
class Version20170405182620 extends AbstractMigration implements ContainerAwareInterface
{
@ -39,6 +39,10 @@ class Version20170405182620 extends AbstractMigration implements ContainerAwareI
$entryTable->addColumn('published_at', 'datetime', [
'notnull' => false,
]);
$entryTable->addColumn('published_by', 'text', [
'notnull' => false,
]);
}
/**
@ -51,5 +55,6 @@ class Version20170405182620 extends AbstractMigration implements ContainerAwareI
$this->skipIf(!$entryTable->hasColumn('published_at'), 'It seems that you already played this migration.');
$entryTable->dropColumn('published_at');
$entryTable->dropColumn('published_by');
}
}

View file

@ -916,6 +916,10 @@ a.add-to-wallabag-link-after::after {
content: "\e906";
}
.icon-users::before {
content: "\e972";
}
.icon-time::before {
content: "\e952";
}

View file

@ -130,6 +130,15 @@ class Entry
*/
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
@ -730,4 +739,24 @@ class Entry
return $this;
}
/**
* @return string
*/
public function getPublishedBy()
{
return $this->publishedBy;
}
/**
* @param string $publishedBy
*
* @return Entry
*/
public function setPublishedBy($publishedBy)
{
$this->publishedBy = $publishedBy;
return $this;
}
}

View file

@ -79,10 +79,14 @@ class ContentProxy
$entry->setContent($html);
$entry->setHttpStatus(isset($content['status']) ? $content['status'] : '');
if (isset($content['date']) && null !== $content['date']) {
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));

View file

@ -225,6 +225,7 @@ entry:
# 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'

View file

@ -225,6 +225,7 @@ entry:
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'

View file

@ -225,6 +225,7 @@ entry:
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'

View file

@ -225,6 +225,7 @@ entry:
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'

View file

@ -225,6 +225,7 @@ entry:
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'

View file

@ -225,6 +225,7 @@ entry:
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"

View file

@ -225,6 +225,7 @@ entry:
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'

View file

@ -225,6 +225,7 @@ entry:
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'

View file

@ -225,6 +225,7 @@ entry:
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'

View file

@ -225,6 +225,7 @@ entry:
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'

View file

@ -225,6 +225,7 @@ entry:
# 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'

View file

@ -225,6 +225,7 @@ entry:
# 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'

View file

@ -47,12 +47,20 @@
{{ entry.createdAt|date('Y-m-d H:i') }}
</i>
{% if entry.publishedAt is not null %}
{% 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 %}

View file

@ -228,12 +228,20 @@
<i class="material-icons" title="{{ 'entry.view.created_at'|trans }}">today</i>
{{ entry.createdAt|date('Y-m-d H:i') }}
</li>
{% if entry.publishedAt is not null %}
{% 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">

View file

@ -135,10 +135,13 @@ 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());
$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 testPostNewOkUrlExist()

File diff suppressed because one or more lines are too long