diff --git a/app/DoctrineMigrations/Version20171105202000.php b/app/DoctrineMigrations/Version20171105202000.php new file mode 100644 index 000000000..3769045fe --- /dev/null +++ b/app/DoctrineMigrations/Version20171105202000.php @@ -0,0 +1,55 @@ +container = $container; + } + + /** + * @param Schema $schema + */ + public function up(Schema $schema) + { + $entryTable = $schema->getTable($this->getTable('entry')); + + $this->skipIf($entryTable->hasColumn('origin_url'), 'It seems that you already played this migration.'); + + $entryTable->addColumn('origin_url', 'text', [ + 'notnull' => false, + ]); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $entryTable = $schema->getTable($this->getTable('entry')); + + $this->skipIf(!$entryTable->hasColumn('origin_url'), 'It seems that you already played this migration.'); + + $entryTable->dropColumn('origin_url'); + } + + private function getTable($tableName) + { + return $this->container->getParameter('database_table_prefix') . $tableName; + } +} diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index 6f161a081..7d820c7e6 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php @@ -309,6 +309,7 @@ class EntryRestController extends WallabagRestController * {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"}, * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"}, * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"}, + * {"name"="origin_url", "dataType"="string", "required"=false, "format"="http://www.test.com/article.html", "description"="Origin url for the entry (from where you found it)."}, * } * ) * @@ -368,6 +369,10 @@ class EntryRestController extends WallabagRestController $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $data['tags']); } + if (!empty($data['origin_url'])) { + $entry->setOriginUrl($data['origin_url']); + } + if (null !== $data['isPublic']) { if (true === (bool) $data['isPublic'] && null === $entry->getUid()) { $entry->generateUid(); @@ -404,6 +409,7 @@ class EntryRestController extends WallabagRestController * {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"}, * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"}, * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"}, + * {"name"="origin_url", "dataType"="string", "required"=false, "format"="http://www.test.com/article.html", "description"="Origin url for the entry (from where you found it)."}, * } * ) * @@ -480,6 +486,10 @@ class EntryRestController extends WallabagRestController } } + if (!empty($data['origin_url'])) { + $entry->setOriginUrl($data['origin_url']); + } + $em = $this->getDoctrine()->getManager(); $em->persist($entry); $em->flush(); @@ -778,6 +788,7 @@ class EntryRestController extends WallabagRestController 'picture' => $request->request->get('preview_picture'), 'publishedAt' => $request->request->get('published_at'), 'authors' => $request->request->get('authors', ''), + 'origin_url' => $request->request->get('origin_url', ''), ]; } diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php index fedad0099..0e1510a29 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php @@ -37,6 +37,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface $entry2->setMimetype('text/html'); $entry2->setTitle('test title entry2'); $entry2->setContent('This is my content /o/'); + $entry2->setOriginUrl('ftp://oneftp.tld'); $entry2->setLanguage('fr'); $manager->persist($entry2); diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index cfb8db752..2b1f2e050 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -245,6 +245,15 @@ class Entry */ private $tags; + /** + * @var string + * + * @ORM\Column(name="origin_url", type="text", nullable=true) + * + * @Groups({"entries_for_user", "export_all"}) + */ + private $originUrl; + /* * @param User $user */ @@ -831,4 +840,28 @@ class Entry return $this; } + + /** + * Set origin url. + * + * @param string $originUrl + * + * @return Entry + */ + public function setOriginUrl($originUrl) + { + $this->originUrl = $originUrl; + + return $this; + } + + /** + * Get origin url. + * + * @return string + */ + public function getOriginUrl() + { + return $this->originUrl; + } } diff --git a/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php b/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php index 1627cc445..083559286 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php @@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\Extension\Core\Type\UrlType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -17,11 +18,16 @@ class EditEntryType extends AbstractType 'required' => true, 'label' => 'entry.edit.title_label', ]) - ->add('url', TextType::class, [ + ->add('url', UrlType::class, [ 'disabled' => true, 'required' => false, 'label' => 'entry.edit.url_label', ]) + ->add('origin_url', UrlType::class, [ + 'required' => false, + 'property_path' => 'originUrl', + 'label' => 'entry.edit.origin_url_label', + ]) ->add('save', SubmitType::class, [ 'label' => 'entry.edit.save_label', ]) diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index d0a38f7e3..27dbb3885 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -233,6 +233,7 @@ entry: created_at: 'Oprettelsesdato' # published_at: 'Publication date' # published_by: 'Published by' + # provided_by: 'Provided by' new: page_title: 'Gem ny artikel' placeholder: 'http://website.com' @@ -244,6 +245,7 @@ entry: # page_title: 'Edit an entry' # title_label: 'Title' url_label: 'Url' + # origin_url_label: 'Origin url (from where you found that entry)' save_label: 'Gem' public: # shared_by_wallabag: "This article has been shared by %username% with wallabag" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index 158762a97..d47986e5b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -233,6 +233,7 @@ entry: created_at: 'Erstellungsdatum' published_at: 'Erscheinungsdatum' published_by: 'Veröffentlicht von' + # provided_by: 'Provided by' new: page_title: 'Neuen Artikel speichern' placeholder: 'https://website.de' @@ -244,6 +245,7 @@ entry: page_title: 'Eintrag bearbeiten' title_label: 'Titel' url_label: 'URL' + # origin_url_label: 'Origin url (from where you found that entry)' save_label: 'Speichern' public: shared_by_wallabag: 'Dieser Artikel wurde von %username% mittels wallabag geteilt' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index de3e11fe2..bbaecb24a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -233,6 +233,7 @@ entry: created_at: 'Creation date' published_at: 'Publication date' published_by: 'Published by' + provided_by: 'Provided by' new: page_title: 'Save new entry' placeholder: 'http://website.com' @@ -244,6 +245,7 @@ entry: page_title: 'Edit an entry' title_label: 'Title' url_label: 'Url' + origin_url_label: 'Origin url (from where you found that entry)' save_label: 'Save' public: shared_by_wallabag: "This article has been shared by %username% with wallabag" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 6dfc1525e..e3b625f7a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -233,6 +233,7 @@ entry: created_at: 'Fecha de creación' # published_at: 'Publication date' # published_by: 'Published by' + # provided_by: 'Provided by' new: page_title: 'Guardar un nuevo artículo' placeholder: 'http://sitioweb.com' @@ -244,6 +245,7 @@ entry: page_title: 'Editar un artículo' title_label: 'Título' url_label: 'URL' + # origin_url_label: 'Origin url (from where you found that entry)' save_label: 'Guardar' public: shared_by_wallabag: "Este artículo se ha compartido con wallabag" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index ffc48933a..c03cca464 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -233,6 +233,7 @@ entry: created_at: 'زمان ساخت' # published_at: 'Publication date' # published_by: 'Published by' + # provided_by: 'Provided by' new: page_title: 'ذخیرهٔ مقالهٔ تازه' placeholder: 'http://website.com' @@ -244,6 +245,7 @@ entry: page_title: 'ویرایش مقاله' title_label: 'عنوان' url_label: 'نشانی' + # origin_url_label: 'Origin url (from where you found that entry)' save_label: 'ذخیره' public: # shared_by_wallabag: "This article has been shared by %username% with wallabag" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index c9d95e2bc..b0037ad27 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -233,6 +233,7 @@ entry: created_at: "Date de création" published_at: "Date de publication" published_by: "Publié par" + provided_by: "Fourni par" new: page_title: "Sauvegarder un nouvel article" placeholder: "http://website.com" @@ -244,6 +245,7 @@ entry: page_title: "Éditer un article" title_label: "Titre" url_label: "Adresse" + origin_url_label: "Adresse d'origine (d'où vous avez trouvé cet article)" save_label: "Enregistrer" public: shared_by_wallabag: "Cet article a été partagé par %username% avec wallabag" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index c53266ca3..56cf341bd 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -233,6 +233,7 @@ entry: created_at: 'Data di creazione' published_at: 'Data di pubblicazione' published_by: 'Pubblicato da' + # provided_by: 'Provided by' new: page_title: 'Salva un nuovo contenuto' placeholder: 'http://website.com' @@ -244,6 +245,7 @@ entry: page_title: 'Modifica voce' title_label: 'Titolo' url_label: 'Url' + # origin_url_label: 'Origin url (from where you found that entry)' save_label: 'Salva' public: shared_by_wallabag: "Questo articolo è stato condiviso da %username% con wallabag" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 3ae64c49f..1b5b221fa 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -233,6 +233,7 @@ entry: created_at: 'Data de creacion' published_at: 'Data de publicacion' published_by: 'Publicat per' + # provided_by: 'Provided by' new: page_title: 'Enregistrar un novèl article' placeholder: 'http://website.com' @@ -244,6 +245,7 @@ entry: page_title: 'Modificar un article' title_label: 'Títol' url_label: 'Url' + # origin_url_label: 'Origin url (from where you found that entry)' save_label: 'Enregistrar' public: shared_by_wallabag: "Aqueste article es estat partejat per wallabag" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index e642c5307..88f35738d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -233,6 +233,7 @@ entry: created_at: 'Czas stworzenia' published_at: 'Data publikacji' published_by: 'Opublikowane przez' + # provided_by: 'Provided by' new: page_title: 'Zapisz nowy wpis' placeholder: 'http://website.com' @@ -244,6 +245,7 @@ entry: page_title: 'Edytuj wpis' title_label: 'Tytuł' url_label: 'Adres URL' + # origin_url_label: 'Origin url (from where you found that entry)' save_label: 'Zapisz' public: shared_by_wallabag: "Ten artykuł został udostępniony przez wallabag" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml index 9b3fea6b0..3987cec3d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml @@ -233,6 +233,7 @@ entry: created_at: 'Data de criação' # published_at: 'Publication date' # published_by: 'Published by' + # provided_by: 'Provided by' new: page_title: 'Salvar nova entrada' placeholder: 'http://website.com' @@ -244,6 +245,7 @@ entry: page_title: 'Editar uma entrada' title_label: 'Título' url_label: 'Url' + # origin_url_label: 'Origin url (from where you found that entry)' save_label: 'Salvar' public: shared_by_wallabag: "Este artigo foi compartilhado pelo wallabag" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 673ca183a..4d2fd5693 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -233,6 +233,7 @@ entry: created_at: 'Data creării' # published_at: 'Publication date' # published_by: 'Published by' + # provided_by: 'Provided by' new: page_title: 'Salvează un nou articol' placeholder: 'http://website.com' @@ -244,6 +245,7 @@ entry: # page_title: 'Edit an entry' # title_label: 'Title' url_label: 'Url' + # origin_url_label: 'Origin url (from where you found that entry)' save_label: 'Salvează' public: # shared_by_wallabag: "This article has been shared by %username% with wallabag" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml index eceecabfb..a560e58df 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml @@ -223,6 +223,7 @@ entry: original_article: 'оригинал' annotations_on_the_entry: '{0} Нет аннотации|{1} Одна аннотация|]1,Inf[ %count% аннотаций' created_at: 'Дата создания' + # provided_by: 'Provided by' new: page_title: 'Сохранить новую запись' placeholder: 'http://website.com' @@ -234,6 +235,7 @@ entry: page_title: 'Изменить запись' title_label: 'Название' url_label: 'Ссылка' + # origin_url_label: 'Origin url (from where you found that entry)' is_public_label: 'Публичная' save_label: 'Сохранить' public: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 563bc50b0..0fd6e9890 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -231,6 +231,7 @@ entry: created_at: 'Oluşturulma tarihi' # published_at: 'Publication date' # published_by: 'Published by' + # provided_by: 'Provided by' new: page_title: 'Yeni makaleyi kaydet' placeholder: 'http://website.com' @@ -242,6 +243,7 @@ entry: page_title: 'Makaleyi düzenle' title_label: 'Başlık' url_label: 'Url' + # origin_url_label: 'Origin url (from where you found that entry)' save_label: 'Kaydet' public: # shared_by_wallabag: "This article has been shared by %username% with wallabag" diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig index f8723189b..0c7cbaa6e 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig @@ -71,6 +71,14 @@ comment {{ 'entry.view.annotations_on_the_entry'|transchoice(entry.annotations | length) }} + + {% if entry.originUrl is not empty %} + launch + + {{ entry.originUrl|striptags|removeSchemeAndWww|truncate(32) }} + + {% endif %} +