aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/DoctrineMigrations/Version20171008195606.php1
-rw-r--r--app/DoctrineMigrations/Version20171105202000.php55
-rw-r--r--composer.json56
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php11
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php1
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php33
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/EditEntryType.php8
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.da.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.de.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.en.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.es.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.it.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig8
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/edit.html.twig5
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig10
-rw-r--r--src/Wallabag/CoreBundle/Twig/WallabagExtension.php8
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php128
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php40
-rw-r--r--tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php27
27 files changed, 385 insertions, 32 deletions
diff --git a/app/DoctrineMigrations/Version20171008195606.php b/app/DoctrineMigrations/Version20171008195606.php
index c190f4ed..f09726c8 100644
--- a/app/DoctrineMigrations/Version20171008195606.php
+++ b/app/DoctrineMigrations/Version20171008195606.php
@@ -31,6 +31,7 @@ class Version20171008195606 extends AbstractMigration implements ContainerAwareI
31 31
32 switch ($this->connection->getDatabasePlatform()->getName()) { 32 switch ($this->connection->getDatabasePlatform()->getName()) {
33 case 'mysql': 33 case 'mysql':
34 $this->addSql('UPDATE ' . $this->getTable('entry') . ' SET reading_time = 0 WHERE reading_time IS NULL;');
34 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE reading_time reading_time INT(11) NOT NULL;'); 35 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE reading_time reading_time INT(11) NOT NULL;');
35 break; 36 break;
36 case 'postgresql': 37 case 'postgresql':
diff --git a/app/DoctrineMigrations/Version20171105202000.php b/app/DoctrineMigrations/Version20171105202000.php
new file mode 100644
index 00000000..3769045f
--- /dev/null
+++ b/app/DoctrineMigrations/Version20171105202000.php
@@ -0,0 +1,55 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Add origin_url column.
12 */
13class Version20171105202000 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 /**
26 * @param Schema $schema
27 */
28 public function up(Schema $schema)
29 {
30 $entryTable = $schema->getTable($this->getTable('entry'));
31
32 $this->skipIf($entryTable->hasColumn('origin_url'), 'It seems that you already played this migration.');
33
34 $entryTable->addColumn('origin_url', 'text', [
35 'notnull' => false,
36 ]);
37 }
38
39 /**
40 * @param Schema $schema
41 */
42 public function down(Schema $schema)
43 {
44 $entryTable = $schema->getTable($this->getTable('entry'));
45
46 $this->skipIf(!$entryTable->hasColumn('origin_url'), 'It seems that you already played this migration.');
47
48 $entryTable->dropColumn('origin_url');
49 }
50
51 private function getTable($tableName)
52 {
53 return $this->container->getParameter('database_table_prefix') . $tableName;
54 }
55}
diff --git a/composer.json b/composer.json
index ae7108f0..23c7cdc2 100644
--- a/composer.json
+++ b/composer.json
@@ -43,46 +43,46 @@
43 "ext-iconv": "*", 43 "ext-iconv": "*",
44 "ext-tokenizer": "*", 44 "ext-tokenizer": "*",
45 "ext-pdo": "*", 45 "ext-pdo": "*",
46 "symfony/symfony": "3.3.*", 46 "symfony/symfony": "~3.3.13",
47 "doctrine/orm": "^2.5", 47 "doctrine/orm": "^2.5.12",
48 "doctrine/doctrine-bundle": "^1.6", 48 "doctrine/doctrine-bundle": "^1.8.0",
49 "doctrine/doctrine-cache-bundle": "^1.2", 49 "doctrine/doctrine-cache-bundle": "^1.3.2",
50 "twig/extensions": "~1.0", 50 "twig/extensions": "^1.5.1",
51 "symfony/swiftmailer-bundle": "^2.3", 51 "symfony/swiftmailer-bundle": "^2.6.7",
52 "symfony/monolog-bundle": "^3.0", 52 "symfony/monolog-bundle": "^3.1.2",
53 "sensio/distribution-bundle": "^5.0", 53 "sensio/distribution-bundle": "^5.0.21",
54 "sensio/framework-extra-bundle": "^3.0", 54 "sensio/framework-extra-bundle": "^3.0.28",
55 "incenteev/composer-parameter-handler": "^2.0", 55 "incenteev/composer-parameter-handler": "^2.1.2",
56 "nelmio/cors-bundle": "~1.4", 56 "nelmio/cors-bundle": "~1.5",
57 "friendsofsymfony/rest-bundle": "~2.1", 57 "friendsofsymfony/rest-bundle": "~2.1",
58 "jms/serializer-bundle": "~2.2", 58 "jms/serializer-bundle": "~2.2",
59 "nelmio/api-doc-bundle": "~2.7", 59 "nelmio/api-doc-bundle": "^2.13.2",
60 "mgargano/simplehtmldom": "~1.5", 60 "mgargano/simplehtmldom": "~1.5",
61 "wallabag/tcpdf": "^6.2", 61 "wallabag/tcpdf": "^6.2.15",
62 "simplepie/simplepie": "~1.5", 62 "simplepie/simplepie": "~1.5",
63 "willdurand/hateoas-bundle": "~1.0", 63 "willdurand/hateoas-bundle": "~1.3",
64 "liip/theme-bundle": "~1.1", 64 "liip/theme-bundle": "^1.4.6",
65 "lexik/form-filter-bundle": "~5.0", 65 "lexik/form-filter-bundle": "^5.0.4",
66 "j0k3r/graby": "^1.0", 66 "j0k3r/graby": "^1.0",
67 "friendsofsymfony/user-bundle": "^2.0", 67 "friendsofsymfony/user-bundle": "^2.0.1",
68 "friendsofsymfony/oauth-server-bundle": "^1.5", 68 "friendsofsymfony/oauth-server-bundle": "^1.5.2",
69 "stof/doctrine-extensions-bundle": "^1.2", 69 "stof/doctrine-extensions-bundle": "^1.2",
70 "scheb/two-factor-bundle": "~2.0", 70 "scheb/two-factor-bundle": "^2.14.0",
71 "grandt/phpepub": "~4.0", 71 "grandt/phpepub": "^4.0.7",
72 "wallabag/php-mobi": "~1.0.0", 72 "wallabag/php-mobi": "~1.0.0",
73 "kphoen/rulerz-bundle": "~0.13", 73 "kphoen/rulerz-bundle": "~0.13",
74 "guzzlehttp/guzzle": "^5.3.1", 74 "guzzlehttp/guzzle": "^5.3.1",
75 "doctrine/doctrine-migrations-bundle": "^1.0", 75 "doctrine/doctrine-migrations-bundle": "^1.3",
76 "paragonie/random_compat": "~2.0", 76 "paragonie/random_compat": "^2.0.11",
77 "craue/config-bundle": "~2.0", 77 "craue/config-bundle": "~2.0",
78 "mnapoli/piwik-twig-extension": "^1.0", 78 "mnapoli/piwik-twig-extension": "^1.0",
79 "ocramius/proxy-manager": "1.*", 79 "ocramius/proxy-manager": "^1.0.2",
80 "white-october/pagerfanta-bundle": "^1.0", 80 "white-october/pagerfanta-bundle": "^1.1.0",
81 "php-amqplib/rabbitmq-bundle": "^1.8", 81 "php-amqplib/rabbitmq-bundle": "^1.14",
82 "predis/predis": "^1.0", 82 "predis/predis": "^1.1.1",
83 "javibravo/simpleue": "^2.0", 83 "javibravo/simpleue": "^2.0",
84 "symfony/dom-crawler": "^3.1", 84 "symfony/dom-crawler": "^3.3.13",
85 "friendsofsymfony/jsrouting-bundle": "^1.6", 85 "friendsofsymfony/jsrouting-bundle": "^1.6.3",
86 "bdunogier/guzzle-site-authenticator": "^1.0.0@dev", 86 "bdunogier/guzzle-site-authenticator": "^1.0.0@dev",
87 "defuse/php-encryption": "^2.1", 87 "defuse/php-encryption": "^2.1",
88 "html2text/html2text": "^4.1" 88 "html2text/html2text": "^4.1"
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index 6f161a08..7d820c7e 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -309,6 +309,7 @@ class EntryRestController extends WallabagRestController
309 * {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"}, 309 * {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"},
310 * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"}, 310 * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"},
311 * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"}, 311 * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"},
312 * {"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)."},
312 * } 313 * }
313 * ) 314 * )
314 * 315 *
@@ -368,6 +369,10 @@ class EntryRestController extends WallabagRestController
368 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $data['tags']); 369 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $data['tags']);
369 } 370 }
370 371
372 if (!empty($data['origin_url'])) {
373 $entry->setOriginUrl($data['origin_url']);
374 }
375
371 if (null !== $data['isPublic']) { 376 if (null !== $data['isPublic']) {
372 if (true === (bool) $data['isPublic'] && null === $entry->getUid()) { 377 if (true === (bool) $data['isPublic'] && null === $entry->getUid()) {
373 $entry->generateUid(); 378 $entry->generateUid();
@@ -404,6 +409,7 @@ class EntryRestController extends WallabagRestController
404 * {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"}, 409 * {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"},
405 * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"}, 410 * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"},
406 * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"}, 411 * {"name"="public", "dataType"="integer", "required"=false, "format"="1 or 0", "description"="will generate a public link for the entry"},
412 * {"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)."},
407 * } 413 * }
408 * ) 414 * )
409 * 415 *
@@ -480,6 +486,10 @@ class EntryRestController extends WallabagRestController
480 } 486 }
481 } 487 }
482 488
489 if (!empty($data['origin_url'])) {
490 $entry->setOriginUrl($data['origin_url']);
491 }
492
483 $em = $this->getDoctrine()->getManager(); 493 $em = $this->getDoctrine()->getManager();
484 $em->persist($entry); 494 $em->persist($entry);
485 $em->flush(); 495 $em->flush();
@@ -778,6 +788,7 @@ class EntryRestController extends WallabagRestController
778 'picture' => $request->request->get('preview_picture'), 788 'picture' => $request->request->get('preview_picture'),
779 'publishedAt' => $request->request->get('published_at'), 789 'publishedAt' => $request->request->get('published_at'),
780 'authors' => $request->request->get('authors', ''), 790 'authors' => $request->request->get('authors', ''),
791 'origin_url' => $request->request->get('origin_url', ''),
781 ]; 792 ];
782 } 793 }
783 794
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php
index fedad009..0e1510a2 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
37 $entry2->setMimetype('text/html'); 37 $entry2->setMimetype('text/html');
38 $entry2->setTitle('test title entry2'); 38 $entry2->setTitle('test title entry2');
39 $entry2->setContent('This is my content /o/'); 39 $entry2->setContent('This is my content /o/');
40 $entry2->setOriginUrl('ftp://oneftp.tld');
40 $entry2->setLanguage('fr'); 41 $entry2->setLanguage('fr');
41 42
42 $manager->persist($entry2); 43 $manager->persist($entry2);
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index cfb8db75..2b1f2e05 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -245,6 +245,15 @@ class Entry
245 */ 245 */
246 private $tags; 246 private $tags;
247 247
248 /**
249 * @var string
250 *
251 * @ORM\Column(name="origin_url", type="text", nullable=true)
252 *
253 * @Groups({"entries_for_user", "export_all"})
254 */
255 private $originUrl;
256
248 /* 257 /*
249 * @param User $user 258 * @param User $user
250 */ 259 */
@@ -831,4 +840,28 @@ class Entry
831 840
832 return $this; 841 return $this;
833 } 842 }
843
844 /**
845 * Set origin url.
846 *
847 * @param string $originUrl
848 *
849 * @return Entry
850 */
851 public function setOriginUrl($originUrl)
852 {
853 $this->originUrl = $originUrl;
854
855 return $this;
856 }
857
858 /**
859 * Get origin url.
860 *
861 * @return string
862 */
863 public function getOriginUrl()
864 {
865 return $this->originUrl;
866 }
834} 867}
diff --git a/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php b/src/Wallabag/CoreBundle/Form/Type/EditEntryType.php
index 1627cc44..08355928 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;
5use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\Extension\Core\Type\SubmitType; 6use Symfony\Component\Form\Extension\Core\Type\SubmitType;
7use Symfony\Component\Form\Extension\Core\Type\TextType; 7use Symfony\Component\Form\Extension\Core\Type\TextType;
8use Symfony\Component\Form\Extension\Core\Type\UrlType;
8use Symfony\Component\Form\FormBuilderInterface; 9use Symfony\Component\Form\FormBuilderInterface;
9use Symfony\Component\OptionsResolver\OptionsResolver; 10use Symfony\Component\OptionsResolver\OptionsResolver;
10 11
@@ -17,11 +18,16 @@ class EditEntryType extends AbstractType
17 'required' => true, 18 'required' => true,
18 'label' => 'entry.edit.title_label', 19 'label' => 'entry.edit.title_label',
19 ]) 20 ])
20 ->add('url', TextType::class, [ 21 ->add('url', UrlType::class, [
21 'disabled' => true, 22 'disabled' => true,
22 'required' => false, 23 'required' => false,
23 'label' => 'entry.edit.url_label', 24 'label' => 'entry.edit.url_label',
24 ]) 25 ])
26 ->add('origin_url', UrlType::class, [
27 'required' => false,
28 'property_path' => 'originUrl',
29 'label' => 'entry.edit.origin_url_label',
30 ])
25 ->add('save', SubmitType::class, [ 31 ->add('save', SubmitType::class, [
26 'label' => 'entry.edit.save_label', 32 'label' => 'entry.edit.save_label',
27 ]) 33 ])
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
index d0a38f7e..27dbb388 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
@@ -233,6 +233,7 @@ entry:
233 created_at: 'Oprettelsesdato' 233 created_at: 'Oprettelsesdato'
234 # published_at: 'Publication date' 234 # published_at: 'Publication date'
235 # published_by: 'Published by' 235 # published_by: 'Published by'
236 # provided_by: 'Provided by'
236 new: 237 new:
237 page_title: 'Gem ny artikel' 238 page_title: 'Gem ny artikel'
238 placeholder: 'http://website.com' 239 placeholder: 'http://website.com'
@@ -244,6 +245,7 @@ entry:
244 # page_title: 'Edit an entry' 245 # page_title: 'Edit an entry'
245 # title_label: 'Title' 246 # title_label: 'Title'
246 url_label: 'Url' 247 url_label: 'Url'
248 # origin_url_label: 'Origin url (from where you found that entry)'
247 save_label: 'Gem' 249 save_label: 'Gem'
248 public: 250 public:
249 # shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>" 251 # shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>"
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
index 158762a9..d47986e5 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
@@ -233,6 +233,7 @@ entry:
233 created_at: 'Erstellungsdatum' 233 created_at: 'Erstellungsdatum'
234 published_at: 'Erscheinungsdatum' 234 published_at: 'Erscheinungsdatum'
235 published_by: 'Veröffentlicht von' 235 published_by: 'Veröffentlicht von'
236 # provided_by: 'Provided by'
236 new: 237 new:
237 page_title: 'Neuen Artikel speichern' 238 page_title: 'Neuen Artikel speichern'
238 placeholder: 'https://website.de' 239 placeholder: 'https://website.de'
@@ -244,6 +245,7 @@ entry:
244 page_title: 'Eintrag bearbeiten' 245 page_title: 'Eintrag bearbeiten'
245 title_label: 'Titel' 246 title_label: 'Titel'
246 url_label: 'URL' 247 url_label: 'URL'
248 # origin_url_label: 'Origin url (from where you found that entry)'
247 save_label: 'Speichern' 249 save_label: 'Speichern'
248 public: 250 public:
249 shared_by_wallabag: 'Dieser Artikel wurde von %username% mittels <a href="%wallabag_instance%">wallabag</a> geteilt' 251 shared_by_wallabag: 'Dieser Artikel wurde von %username% mittels <a href="%wallabag_instance%">wallabag</a> geteilt'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
index de3e11fe..bbaecb24 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
@@ -233,6 +233,7 @@ entry:
233 created_at: 'Creation date' 233 created_at: 'Creation date'
234 published_at: 'Publication date' 234 published_at: 'Publication date'
235 published_by: 'Published by' 235 published_by: 'Published by'
236 provided_by: 'Provided by'
236 new: 237 new:
237 page_title: 'Save new entry' 238 page_title: 'Save new entry'
238 placeholder: 'http://website.com' 239 placeholder: 'http://website.com'
@@ -244,6 +245,7 @@ entry:
244 page_title: 'Edit an entry' 245 page_title: 'Edit an entry'
245 title_label: 'Title' 246 title_label: 'Title'
246 url_label: 'Url' 247 url_label: 'Url'
248 origin_url_label: 'Origin url (from where you found that entry)'
247 save_label: 'Save' 249 save_label: 'Save'
248 public: 250 public:
249 shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>" 251 shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>"
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
index 6dfc1525..e3b625f7 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
@@ -233,6 +233,7 @@ entry:
233 created_at: 'Fecha de creación' 233 created_at: 'Fecha de creación'
234 # published_at: 'Publication date' 234 # published_at: 'Publication date'
235 # published_by: 'Published by' 235 # published_by: 'Published by'
236 # provided_by: 'Provided by'
236 new: 237 new:
237 page_title: 'Guardar un nuevo artículo' 238 page_title: 'Guardar un nuevo artículo'
238 placeholder: 'http://sitioweb.com' 239 placeholder: 'http://sitioweb.com'
@@ -244,6 +245,7 @@ entry:
244 page_title: 'Editar un artículo' 245 page_title: 'Editar un artículo'
245 title_label: 'Título' 246 title_label: 'Título'
246 url_label: 'URL' 247 url_label: 'URL'
248 # origin_url_label: 'Origin url (from where you found that entry)'
247 save_label: 'Guardar' 249 save_label: 'Guardar'
248 public: 250 public:
249 shared_by_wallabag: "Este artículo se ha compartido con <a href='%wallabag_instance%'>wallabag</a>" 251 shared_by_wallabag: "Este artículo se ha compartido con <a href='%wallabag_instance%'>wallabag</a>"
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
index ffc48933..c03cca46 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
@@ -233,6 +233,7 @@ entry:
233 created_at: 'زمان ساخت' 233 created_at: 'زمان ساخت'
234 # published_at: 'Publication date' 234 # published_at: 'Publication date'
235 # published_by: 'Published by' 235 # published_by: 'Published by'
236 # provided_by: 'Provided by'
236 new: 237 new:
237 page_title: 'ذخیرهٔ مقالهٔ تازه' 238 page_title: 'ذخیرهٔ مقالهٔ تازه'
238 placeholder: 'http://website.com' 239 placeholder: 'http://website.com'
@@ -244,6 +245,7 @@ entry:
244 page_title: 'ویرایش مقاله' 245 page_title: 'ویرایش مقاله'
245 title_label: 'عنوان' 246 title_label: 'عنوان'
246 url_label: 'نشانی' 247 url_label: 'نشانی'
248 # origin_url_label: 'Origin url (from where you found that entry)'
247 save_label: 'ذخیره' 249 save_label: 'ذخیره'
248 public: 250 public:
249 # shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>" 251 # shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>"
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index c9d95e2b..b0037ad2 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -233,6 +233,7 @@ entry:
233 created_at: "Date de création" 233 created_at: "Date de création"
234 published_at: "Date de publication" 234 published_at: "Date de publication"
235 published_by: "Publié par" 235 published_by: "Publié par"
236 provided_by: "Fourni par"
236 new: 237 new:
237 page_title: "Sauvegarder un nouvel article" 238 page_title: "Sauvegarder un nouvel article"
238 placeholder: "http://website.com" 239 placeholder: "http://website.com"
@@ -244,6 +245,7 @@ entry:
244 page_title: "Éditer un article" 245 page_title: "Éditer un article"
245 title_label: "Titre" 246 title_label: "Titre"
246 url_label: "Adresse" 247 url_label: "Adresse"
248 origin_url_label: "Adresse d'origine (d'où vous avez trouvé cet article)"
247 save_label: "Enregistrer" 249 save_label: "Enregistrer"
248 public: 250 public:
249 shared_by_wallabag: "Cet article a été partagé par %username% avec <a href=\"%wallabag_instance%\">wallabag</a>" 251 shared_by_wallabag: "Cet article a été partagé par %username% avec <a href=\"%wallabag_instance%\">wallabag</a>"
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
index c53266ca..56cf341b 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
@@ -233,6 +233,7 @@ entry:
233 created_at: 'Data di creazione' 233 created_at: 'Data di creazione'
234 published_at: 'Data di pubblicazione' 234 published_at: 'Data di pubblicazione'
235 published_by: 'Pubblicato da' 235 published_by: 'Pubblicato da'
236 # provided_by: 'Provided by'
236 new: 237 new:
237 page_title: 'Salva un nuovo contenuto' 238 page_title: 'Salva un nuovo contenuto'
238 placeholder: 'http://website.com' 239 placeholder: 'http://website.com'
@@ -244,6 +245,7 @@ entry:
244 page_title: 'Modifica voce' 245 page_title: 'Modifica voce'
245 title_label: 'Titolo' 246 title_label: 'Titolo'
246 url_label: 'Url' 247 url_label: 'Url'
248 # origin_url_label: 'Origin url (from where you found that entry)'
247 save_label: 'Salva' 249 save_label: 'Salva'
248 public: 250 public:
249 shared_by_wallabag: "Questo articolo è stato condiviso da %username% con <a href='%wallabag_instance%'>wallabag</a>" 251 shared_by_wallabag: "Questo articolo è stato condiviso da %username% con <a href='%wallabag_instance%'>wallabag</a>"
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
index 3ae64c49..1b5b221f 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
@@ -233,6 +233,7 @@ entry:
233 created_at: 'Data de creacion' 233 created_at: 'Data de creacion'
234 published_at: 'Data de publicacion' 234 published_at: 'Data de publicacion'
235 published_by: 'Publicat per' 235 published_by: 'Publicat per'
236 # provided_by: 'Provided by'
236 new: 237 new:
237 page_title: 'Enregistrar un novèl article' 238 page_title: 'Enregistrar un novèl article'
238 placeholder: 'http://website.com' 239 placeholder: 'http://website.com'
@@ -244,6 +245,7 @@ entry:
244 page_title: 'Modificar un article' 245 page_title: 'Modificar un article'
245 title_label: 'Títol' 246 title_label: 'Títol'
246 url_label: 'Url' 247 url_label: 'Url'
248 # origin_url_label: 'Origin url (from where you found that entry)'
247 save_label: 'Enregistrar' 249 save_label: 'Enregistrar'
248 public: 250 public:
249 shared_by_wallabag: "Aqueste article es estat partejat per <a href='%wallabag_instance%'>wallabag</a>" 251 shared_by_wallabag: "Aqueste article es estat partejat per <a href='%wallabag_instance%'>wallabag</a>"
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
index e642c530..88f35738 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
@@ -233,6 +233,7 @@ entry:
233 created_at: 'Czas stworzenia' 233 created_at: 'Czas stworzenia'
234 published_at: 'Data publikacji' 234 published_at: 'Data publikacji'
235 published_by: 'Opublikowane przez' 235 published_by: 'Opublikowane przez'
236 # provided_by: 'Provided by'
236 new: 237 new:
237 page_title: 'Zapisz nowy wpis' 238 page_title: 'Zapisz nowy wpis'
238 placeholder: 'http://website.com' 239 placeholder: 'http://website.com'
@@ -244,6 +245,7 @@ entry:
244 page_title: 'Edytuj wpis' 245 page_title: 'Edytuj wpis'
245 title_label: 'Tytuł' 246 title_label: 'Tytuł'
246 url_label: 'Adres URL' 247 url_label: 'Adres URL'
248 # origin_url_label: 'Origin url (from where you found that entry)'
247 save_label: 'Zapisz' 249 save_label: 'Zapisz'
248 public: 250 public:
249 shared_by_wallabag: "Ten artykuł został udostępniony przez <a href='%wallabag_instance%'>wallabag</a>" 251 shared_by_wallabag: "Ten artykuł został udostępniony przez <a href='%wallabag_instance%'>wallabag</a>"
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
index 9b3fea6b..3987cec3 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
@@ -233,6 +233,7 @@ entry:
233 created_at: 'Data de criação' 233 created_at: 'Data de criação'
234 # published_at: 'Publication date' 234 # published_at: 'Publication date'
235 # published_by: 'Published by' 235 # published_by: 'Published by'
236 # provided_by: 'Provided by'
236 new: 237 new:
237 page_title: 'Salvar nova entrada' 238 page_title: 'Salvar nova entrada'
238 placeholder: 'http://website.com' 239 placeholder: 'http://website.com'
@@ -244,6 +245,7 @@ entry:
244 page_title: 'Editar uma entrada' 245 page_title: 'Editar uma entrada'
245 title_label: 'Título' 246 title_label: 'Título'
246 url_label: 'Url' 247 url_label: 'Url'
248 # origin_url_label: 'Origin url (from where you found that entry)'
247 save_label: 'Salvar' 249 save_label: 'Salvar'
248 public: 250 public:
249 shared_by_wallabag: "Este artigo foi compartilhado pelo <a href='%wallabag_instance%'>wallabag</a>" 251 shared_by_wallabag: "Este artigo foi compartilhado pelo <a href='%wallabag_instance%'>wallabag</a>"
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
index 673ca183..4d2fd569 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
@@ -233,6 +233,7 @@ entry:
233 created_at: 'Data creării' 233 created_at: 'Data creării'
234 # published_at: 'Publication date' 234 # published_at: 'Publication date'
235 # published_by: 'Published by' 235 # published_by: 'Published by'
236 # provided_by: 'Provided by'
236 new: 237 new:
237 page_title: 'Salvează un nou articol' 238 page_title: 'Salvează un nou articol'
238 placeholder: 'http://website.com' 239 placeholder: 'http://website.com'
@@ -244,6 +245,7 @@ entry:
244 # page_title: 'Edit an entry' 245 # page_title: 'Edit an entry'
245 # title_label: 'Title' 246 # title_label: 'Title'
246 url_label: 'Url' 247 url_label: 'Url'
248 # origin_url_label: 'Origin url (from where you found that entry)'
247 save_label: 'Salvează' 249 save_label: 'Salvează'
248 public: 250 public:
249 # shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>" 251 # shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>"
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
index eceecabf..a560e58d 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
@@ -223,6 +223,7 @@ entry:
223 original_article: 'оригинал' 223 original_article: 'оригинал'
224 annotations_on_the_entry: '{0} Нет аннотации|{1} Одна аннотация|]1,Inf[ %count% аннотаций' 224 annotations_on_the_entry: '{0} Нет аннотации|{1} Одна аннотация|]1,Inf[ %count% аннотаций'
225 created_at: 'Дата создания' 225 created_at: 'Дата создания'
226 # provided_by: 'Provided by'
226 new: 227 new:
227 page_title: 'Сохранить новую запись' 228 page_title: 'Сохранить новую запись'
228 placeholder: 'http://website.com' 229 placeholder: 'http://website.com'
@@ -234,6 +235,7 @@ entry:
234 page_title: 'Изменить запись' 235 page_title: 'Изменить запись'
235 title_label: 'Название' 236 title_label: 'Название'
236 url_label: 'Ссылка' 237 url_label: 'Ссылка'
238 # origin_url_label: 'Origin url (from where you found that entry)'
237 is_public_label: 'Публичная' 239 is_public_label: 'Публичная'
238 save_label: 'Сохранить' 240 save_label: 'Сохранить'
239 public: 241 public:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
index 563bc50b..0fd6e989 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
@@ -231,6 +231,7 @@ entry:
231 created_at: 'Oluşturulma tarihi' 231 created_at: 'Oluşturulma tarihi'
232 # published_at: 'Publication date' 232 # published_at: 'Publication date'
233 # published_by: 'Published by' 233 # published_by: 'Published by'
234 # provided_by: 'Provided by'
234 new: 235 new:
235 page_title: 'Yeni makaleyi kaydet' 236 page_title: 'Yeni makaleyi kaydet'
236 placeholder: 'http://website.com' 237 placeholder: 'http://website.com'
@@ -242,6 +243,7 @@ entry:
242 page_title: 'Makaleyi düzenle' 243 page_title: 'Makaleyi düzenle'
243 title_label: 'Başlık' 244 title_label: 'Başlık'
244 url_label: 'Url' 245 url_label: 'Url'
246 # origin_url_label: 'Origin url (from where you found that entry)'
245 save_label: 'Kaydet' 247 save_label: 'Kaydet'
246 public: 248 public:
247 # shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>" 249 # shared_by_wallabag: "This article has been shared by %username% with <a href='%wallabag_instance%'>wallabag</a>"
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 f8723189..0c7cbaa6 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 @@
71 </i> 71 </i>
72 72
73 <span class="tool link"><i class="material-icons link">comment</i> {{ 'entry.view.annotations_on_the_entry'|transchoice(entry.annotations | length) }}</span> 73 <span class="tool link"><i class="material-icons link">comment</i> {{ 'entry.view.annotations_on_the_entry'|transchoice(entry.annotations | length) }}</span>
74
75 {% if entry.originUrl is not empty %}
76 <i class="material-icons" title="{{ 'entry.view.provided_by'|trans }}">launch</i>
77 <a href="{{ entry.originUrl|e }}" target="_blank" class="tool">
78 {{ entry.originUrl|striptags|removeSchemeAndWww|truncate(32) }}
79 </a>
80 {% endif %}
81
74 <aside class="tags"> 82 <aside class="tags">
75 <div class="card-entry-tags"> 83 <div class="card-entry-tags">
76 {% for tag in entry.tags %} 84 {% for tag in entry.tags %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/edit.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/edit.html.twig
index b9537975..ed225957 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/edit.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/edit.html.twig
@@ -27,6 +27,11 @@
27 {{ form_label(form.url) }} 27 {{ form_label(form.url) }}
28 {{ form_widget(form.url) }} 28 {{ form_widget(form.url) }}
29 </div> 29 </div>
30
31 <div class="input-field s12">
32 {{ form_label(form.origin_url) }}
33 {{ form_widget(form.origin_url) }}
34 </div>
30 <br> 35 <br>
31 36
32 {{ form_widget(form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }} 37 {{ form_widget(form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
index 4cff7bf2..019569f7 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
@@ -125,7 +125,7 @@
125 {% endif %} 125 {% endif %}
126 {% if craue_setting('share_shaarli') %} 126 {% if craue_setting('share_shaarli') %}
127 <li> 127 <li>
128 <a href="{{ craue_setting('shaarli_url') }}/index.php?post={{ entry.url|url_encode }}&amp;title={{ entry.title|striptags|url_encode }}&amp;tags={{ entry.tags|join(',')|striptags|url_encode }}" target="_blank" title="shaarli" class="tool icon-image shaarli"> 128 <a href="{{ craue_setting('shaarli_url') }}/index.php?post={{ entry.url|url_encode }}&amp;title={{ entry.title|striptags|url_encode }}&amp;tags={{ entry.tags|join(',')|striptags|url_encode }}&amp;lf_original_url={{ entry.originUrl|url_encode }}" target="_blank" title="shaarli" class="tool icon-image shaarli">
129 <span>shaarli</span> 129 <span>shaarli</span>
130 </a> 130 </a>
131 </li> 131 </li>
@@ -249,6 +249,14 @@
249 <i class="material-icons link">comment</i> 249 <i class="material-icons link">comment</i>
250 {{ 'entry.view.annotations_on_the_entry'|transchoice(entry.annotations | length) }} 250 {{ 'entry.view.annotations_on_the_entry'|transchoice(entry.annotations | length) }}
251 </li> 251 </li>
252 {% if entry.originUrl is not empty %}
253 <li>
254 <i class="material-icons" title="{{ 'entry.view.provided_by'|trans }}">launch</i>
255 <a href="{{ entry.originUrl|e }}" target="_blank" class="tool">
256 {{ entry.originUrl|striptags|removeSchemeAndWww|truncate(32) }}
257 </a>
258 </li>
259 {% endif %}
252 </ul> 260 </ul>
253 <ul class="tags"> 261 <ul class="tags">
254 {% for tag in entry.tags %} 262 {% for tag in entry.tags %}
diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
index 351172c4..8992117e 100644
--- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
+++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
@@ -28,6 +28,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
28 { 28 {
29 return [ 29 return [
30 new \Twig_SimpleFilter('removeWww', [$this, 'removeWww']), 30 new \Twig_SimpleFilter('removeWww', [$this, 'removeWww']),
31 new \Twig_SimpleFilter('removeSchemeAndWww', [$this, 'removeSchemeAndWww']),
31 ]; 32 ];
32 } 33 }
33 34
@@ -45,6 +46,13 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
45 return preg_replace('/^www\./i', '', $url); 46 return preg_replace('/^www\./i', '', $url);
46 } 47 }
47 48
49 public function removeSchemeAndWww($url)
50 {
51 return $this->removeWww(
52 preg_replace('@^https?://@i', '', $url)
53 );
54 }
55
48 /** 56 /**
49 * Return number of entries depending of the type (unread, archive, starred or all). 57 * Return number of entries depending of the type (unread, archive, starred or all).
50 * 58 *
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index 8a65f512..b0d4c4e1 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -36,6 +36,25 @@ class EntryRestControllerTest extends WallabagApiTestCase
36 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type')); 36 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
37 } 37 }
38 38
39 public function testGetOneEntryWithOriginUrl()
40 {
41 $entry = $this->client->getContainer()
42 ->get('doctrine.orm.entity_manager')
43 ->getRepository('WallabagCoreBundle:Entry')
44 ->findOneBy(['user' => 1, 'url' => 'http://0.0.0.0/entry2']);
45
46 if (!$entry) {
47 $this->markTestSkipped('No content found in db.');
48 }
49
50 $this->client->request('GET', '/api/entries/' . $entry->getId() . '.json');
51 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
52
53 $content = json_decode($this->client->getResponse()->getContent(), true);
54
55 $this->assertSame($entry->getOriginUrl(), $content['origin_url']);
56 }
57
39 public function testExportEntry() 58 public function testExportEntry()
40 { 59 {
41 $entry = $this->client->getContainer() 60 $entry = $this->client->getContainer()
@@ -421,6 +440,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
421 $this->assertSame('New title for my article', $content['title']); 440 $this->assertSame('New title for my article', $content['title']);
422 $this->assertSame(1, $content['user_id']); 441 $this->assertSame(1, $content['user_id']);
423 $this->assertCount(2, $content['tags']); 442 $this->assertCount(2, $content['tags']);
443 $this->assertNull($content['origin_url']);
424 $this->assertSame('my content', $content['content']); 444 $this->assertSame('my content', $content['content']);
425 $this->assertSame('de', $content['language']); 445 $this->assertSame('de', $content['language']);
426 $this->assertSame('2016-09-08T11:55:58+0200', $content['published_at']); 446 $this->assertSame('2016-09-08T11:55:58+0200', $content['published_at']);
@@ -531,6 +551,29 @@ class EntryRestControllerTest extends WallabagApiTestCase
531 $this->assertSame(1, $content['is_starred']); 551 $this->assertSame(1, $content['is_starred']);
532 } 552 }
533 553
554 public function testPostEntryWithOriginUrl()
555 {
556 $this->client->request('POST', '/api/entries.json', [
557 'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html',
558 'tags' => 'google',
559 'title' => 'New title for my article',
560 'content' => 'my content',
561 'language' => 'de',
562 'published_at' => '2016-09-08T11:55:58+0200',
563 'authors' => 'bob,helen',
564 'public' => 1,
565 'origin_url' => 'http://mysource.tld',
566 ]);
567
568 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
569
570 $content = json_decode($this->client->getResponse()->getContent(), true);
571
572 $this->assertGreaterThan(0, $content['id']);
573 $this->assertSame('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']);
574 $this->assertSame('http://mysource.tld', $content['origin_url']);
575 }
576
534 public function testPatchEntry() 577 public function testPatchEntry()
535 { 578 {
536 $entry = $this->client->getContainer() 579 $entry = $this->client->getContainer()
@@ -607,6 +650,91 @@ class EntryRestControllerTest extends WallabagApiTestCase
607 $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved'); 650 $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved');
608 } 651 }
609 652
653 public function testPatchEntryWithOriginUrl()
654 {
655 $entry = $this->client->getContainer()
656 ->get('doctrine.orm.entity_manager')
657 ->getRepository('WallabagCoreBundle:Entry')
658 ->findOneByUser(1);
659
660 if (!$entry) {
661 $this->markTestSkipped('No content found in db.');
662 }
663
664 $previousContent = $entry->getContent();
665 $previousLanguage = $entry->getLanguage();
666
667 $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
668 'title' => 'Another awesome title just for profit',
669 'origin_url' => 'https://myawesomesource.example.com',
670 ]);
671
672 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
673
674 $content = json_decode($this->client->getResponse()->getContent(), true);
675
676 $this->assertSame($entry->getId(), $content['id']);
677 $this->assertSame($entry->getUrl(), $content['url']);
678 $this->assertSame('https://myawesomesource.example.com', $content['origin_url']);
679 $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string');
680 $this->assertSame($previousContent, $content['content'], 'Ensure content has not moved');
681 $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved');
682 }
683
684 public function testPatchEntryRemoveOriginUrl()
685 {
686 $entry = $this->client->getContainer()
687 ->get('doctrine.orm.entity_manager')
688 ->getRepository('WallabagCoreBundle:Entry')
689 ->findOneByUser(1);
690
691 if (!$entry) {
692 $this->markTestSkipped('No content found in db.');
693 }
694
695 $previousContent = $entry->getContent();
696 $previousLanguage = $entry->getLanguage();
697 $previousTitle = $entry->getTitle();
698
699 $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
700 'origin_url' => '',
701 ]);
702
703 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
704
705 $content = json_decode($this->client->getResponse()->getContent(), true);
706
707 $this->assertSame($entry->getId(), $content['id']);
708 $this->assertSame($entry->getUrl(), $content['url']);
709 $this->assertEmpty($content['origin_url']);
710 $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string');
711 $this->assertSame($previousContent, $content['content'], 'Ensure content has not moved');
712 $this->assertSame($previousLanguage, $content['language'], 'Ensure language has not moved');
713 $this->assertSame($previousTitle, $content['title'], 'Ensure title has not moved');
714 }
715
716 public function testPatchEntryNullOriginUrl()
717 {
718 $entry = $this->client->getContainer()
719 ->get('doctrine.orm.entity_manager')
720 ->getRepository('WallabagCoreBundle:Entry')
721 ->findOneByUser(1);
722
723 if (!$entry) {
724 $this->markTestSkipped('No content found in db.');
725 }
726
727 $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
728 'origin_url' => null,
729 ]);
730
731 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
732
733 $content = json_decode($this->client->getResponse()->getContent(), true);
734
735 $this->assertNull($content['origin_url']);
736 }
737
610 public function testGetTagsEntry() 738 public function testGetTagsEntry()
611 { 739 {
612 $entry = $this->client->getContainer() 740 $entry = $this->client->getContainer()
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 2a2fd1a4..4ac4548b 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -478,6 +478,7 @@ class EntryControllerTest extends WallabagCoreTestCase
478 478
479 $data = [ 479 $data = [
480 'entry[title]' => 'My updated title hehe :)', 480 'entry[title]' => 'My updated title hehe :)',
481 'entry[origin_url]' => 'https://example.io',
481 ]; 482 ];
482 483
483 $client->submit($form, $data); 484 $client->submit($form, $data);
@@ -486,8 +487,43 @@ class EntryControllerTest extends WallabagCoreTestCase
486 487
487 $crawler = $client->followRedirect(); 488 $crawler = $client->followRedirect();
488 489
489 $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(['_text'])); 490 $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text']));
490 $this->assertContains('My updated title hehe :)', $alert[0]); 491 $this->assertContains('My updated title hehe :)', $title[0]);
492 $this->assertGreaterThan(1, $stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']));
493 $this->assertContains('example.io', trim($stats[1]));
494 }
495
496 public function testEditRemoveOriginUrl()
497 {
498 $this->logInAs('admin');
499 $client = $this->getClient();
500
501 $entry = new Entry($this->getLoggedInUser());
502 $entry->setUrl($this->url);
503 $this->getEntityManager()->persist($entry);
504 $this->getEntityManager()->flush();
505
506 $crawler = $client->request('GET', '/edit/' . $entry->getId());
507
508 $this->assertSame(200, $client->getResponse()->getStatusCode());
509
510 $form = $crawler->filter('button[type=submit]')->form();
511
512 $data = [
513 'entry[title]' => 'My updated title hehe :)',
514 'entry[origin_url]' => '',
515 ];
516
517 $client->submit($form, $data);
518
519 $this->assertSame(302, $client->getResponse()->getStatusCode());
520
521 $crawler = $client->followRedirect();
522
523 $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text']));
524 $this->assertContains('My updated title hehe :)', $title[0]);
525 $this->assertSame(1, count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text'])));
526 $this->assertNotContains('example.io', trim($stats[0]));
491 } 527 }
492 528
493 public function testToggleArchive() 529 public function testToggleArchive()
diff --git a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
index ceec4b37..82336060 100644
--- a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
+++ b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
@@ -30,4 +30,31 @@ class WallabagExtensionTest extends \PHPUnit_Framework_TestCase
30 $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr')); 30 $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
31 $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com')); 31 $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com'));
32 } 32 }
33
34 public function testRemoveSchemeAndWww()
35 {
36 $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
37 ->disableOriginalConstructor()
38 ->getMock();
39
40 $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository')
41 ->disableOriginalConstructor()
42 ->getMock();
43
44 $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')
45 ->disableOriginalConstructor()
46 ->getMock();
47
48 $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')
49 ->disableOriginalConstructor()
50 ->getMock();
51
52 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
53
54 $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('www.lemonde.fr'));
55 $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('http://lemonde.fr'));
56 $this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('https://www.lemonde.fr'));
57 $this->assertSame('gist.github.com', $extension->removeSchemeAndWww('https://gist.github.com'));
58 $this->assertSame('ftp://gist.github.com', $extension->removeSchemeAndWww('ftp://gist.github.com'));
59 }
33} 60}