From 038fccd244783884529ada34ae3b5ba555616025 Mon Sep 17 00:00:00 2001 From: Matt Burke Date: Sat, 3 Nov 2018 12:56:49 -0400 Subject: Remove preview picture from single entry view page for #1875 Showing the preview picture usually leads to showing a duplicate image, and frequently leads to showing duplicate images directly adjacent to each other. --- .../CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig | 3 --- .../CoreBundle/Resources/views/themes/material/Entry/entry.html.twig | 4 ---- 2 files changed, 7 deletions(-) (limited to 'src/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 d42739ac..32d95a31 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 @@ -96,9 +96,6 @@ - {% if entry.previewPicture is not null %} -
{{ entry.title|e|raw }}
- {% endif %}
{{ entry.content | raw }}
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 7484d53b..b7b62f6c 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 @@ -275,10 +275,6 @@ {{ render(controller( "WallabagCoreBundle:Tag:addTagForm", { 'id': entry.id } )) }} - {% if entry.previewPicture is not null %} -
{{ entry.title|striptags|default('entry.default_title'|trans)|raw }}
- {% endif %} -
{{ entry.content | raw }} -- cgit v1.2.3 From e5de9917fdd78d4cd3b46b376e3b2a4175efa36a Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sun, 25 Nov 2018 15:00:08 +0100 Subject: material: fix missing thumbnail on list view Signed-off-by: Kevin Decherf --- .../views/themes/material/Entry/_card_list.html.twig | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig index 7c83c3bb..1c00f2fa 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig @@ -1,10 +1,9 @@
-
- {% if entry.previewPicture is not null %} - - - - {% endif %} + {% include "@WallabagCore/themes/material/Entry/Card/_content.html.twig" with {'entry': entry, 'withTags': true, 'subClass': 'metadata'} only %}
    -- cgit v1.2.3 From b34b489cfdc7fc5c21eb0f0ea24a33419caedfa6 Mon Sep 17 00:00:00 2001 From: giuppi Date: Sun, 25 Nov 2018 16:07:08 +0100 Subject: Fix Android app login issue class and alt tags must be in the correct order for the android app to recognize the wallabag server --- src/Wallabag/UserBundle/Resources/views/layout.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/UserBundle/Resources/views/layout.html.twig b/src/Wallabag/UserBundle/Resources/views/layout.html.twig index 99bf7dfd..f97e9870 100644 --- a/src/Wallabag/UserBundle/Resources/views/layout.html.twig +++ b/src/Wallabag/UserBundle/Resources/views/layout.html.twig @@ -11,7 +11,7 @@
    -
    +
    {% block fos_user_content %} {% endblock fos_user_content %}
    -- cgit v1.2.3 From 5becf260fafd741fd34948f12131d8074dc2b5dc Mon Sep 17 00:00:00 2001 From: lizyn Date: Tue, 25 Dec 2018 15:31:44 +0800 Subject: fix incorrect reading time calculation for entries with CJK characters --- src/Wallabag/CoreBundle/Tools/Utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Tools/Utils.php b/src/Wallabag/CoreBundle/Tools/Utils.php index 46bb1dc5..0a805210 100644 --- a/src/Wallabag/CoreBundle/Tools/Utils.php +++ b/src/Wallabag/CoreBundle/Tools/Utils.php @@ -29,6 +29,6 @@ class Utils */ public static function getReadingTime($text) { - return floor(\count(preg_split('~[^\p{L}\p{N}\']+~u', strip_tags($text))) / 200); + return floor(\count(preg_split('~([^\p{L}\p{N}\']+|\p{Han}|\p{Hiragana}|\p{Katakana}|\p{Hangul})~u', strip_tags($text))) / 200); } } -- cgit v1.2.3 From bafb9744c87255ebe28945879da85e587175d241 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sat, 29 Dec 2018 19:22:05 +0100 Subject: fixtures: refactor EntryData, TagData, add a new tag Signed-off-by: Kevin Decherf --- .../CoreBundle/DataFixtures/ORM/LoadEntryData.php | 197 +++++++++++---------- .../CoreBundle/DataFixtures/ORM/LoadTagData.php | 43 ++--- 2 files changed, 122 insertions(+), 118 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php index 0e1510a2..8e7a1d2a 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php @@ -14,97 +14,112 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface */ public function load(ObjectManager $manager) { - $entry1 = new Entry($this->getReference('admin-user')); - $entry1->setUrl('http://0.0.0.0/entry1'); - $entry1->setReadingTime(11); - $entry1->setDomainName('domain.io'); - $entry1->setMimetype('text/html'); - $entry1->setTitle('test title entry1'); - $entry1->setContent('This is my content /o/'); - $entry1->setLanguage('en'); - - $entry1->addTag($this->getReference('foo-tag')); - $entry1->addTag($this->getReference('baz-tag')); - - $manager->persist($entry1); - - $this->addReference('entry1', $entry1); - - $entry2 = new Entry($this->getReference('admin-user')); - $entry2->setUrl('http://0.0.0.0/entry2'); - $entry2->setReadingTime(1); - $entry2->setDomainName('domain.io'); - $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); - - $this->addReference('entry2', $entry2); - - $entry3 = new Entry($this->getReference('bob-user')); - $entry3->setUrl('http://0.0.0.0/entry3'); - $entry3->setReadingTime(1); - $entry3->setDomainName('domain.io'); - $entry3->setMimetype('text/html'); - $entry3->setTitle('test title entry3'); - $entry3->setContent('This is my content /o/'); - $entry3->setLanguage('en'); - - $entry3->addTag($this->getReference('foo-tag')); - $entry3->addTag($this->getReference('bar-tag')); - - $manager->persist($entry3); - - $this->addReference('entry3', $entry3); - - $entry4 = new Entry($this->getReference('admin-user')); - $entry4->setUrl('http://0.0.0.0/entry4'); - $entry4->setReadingTime(12); - $entry4->setDomainName('domain.io'); - $entry4->setMimetype('text/html'); - $entry4->setTitle('test title entry4'); - $entry4->setContent('This is my content /o/'); - $entry4->setLanguage('en'); - - $entry4->addTag($this->getReference('foo-tag')); - $entry4->addTag($this->getReference('bar-tag')); - - $manager->persist($entry4); - - $this->addReference('entry4', $entry4); - - $entry5 = new Entry($this->getReference('admin-user')); - $entry5->setUrl('http://0.0.0.0/entry5'); - $entry5->setReadingTime(12); - $entry5->setDomainName('domain.io'); - $entry5->setMimetype('text/html'); - $entry5->setTitle('test title entry5'); - $entry5->setContent('This is my content /o/'); - $entry5->setStarred(true); - $entry5->setLanguage('fr'); - $entry5->setPreviewPicture('http://0.0.0.0/image.jpg'); - - $manager->persist($entry5); - - $this->addReference('entry5', $entry5); - - $entry6 = new Entry($this->getReference('admin-user')); - $entry6->setUrl('http://0.0.0.0/entry6'); - $entry6->setReadingTime(12); - $entry6->setDomainName('domain.io'); - $entry6->setMimetype('text/html'); - $entry6->setTitle('test title entry6'); - $entry6->setContent('This is my content /o/'); - $entry6->setArchived(true); - $entry6->setLanguage('de'); - $entry6->addTag($this->getReference('bar-tag')); - - $manager->persist($entry6); - - $this->addReference('entry6', $entry6); + $entries = [ + 'entry1' => [ + 'user' => 'admin-user', + 'url' => 'http://0.0.0.0/entry1', + 'reading_time' => 11, + 'domain' => 'domain.io', + 'mime' => 'text/html', + 'title' => 'test title entry1', + 'content' => 'This is my content /o/', + 'language' => 'en', + 'tags' => ['foo-tag', 'baz-tag'], + ], + 'entry2' => [ + 'user' => 'admin-user', + 'url' => 'http://0.0.0.0/entry2', + 'reading_time' => 1, + 'domain' => 'domain.io', + 'mime' => 'text/html', + 'title' => 'test title entry2', + 'content' => 'This is my content /o/', + 'origin' => 'ftp://oneftp.tld', + 'language' => 'fr', + ], + 'entry3' => [ + 'user' => 'bob-user', + 'url' => 'http://0.0.0.0/entry3', + 'reading_time' => 1, + 'domain' => 'domain.io', + 'mime' => 'text/html', + 'title' => 'test title entry3', + 'content' => 'This is my content /o/', + 'language' => 'en', + 'tags' => ['foo-tag', 'bar-tag', 'bob-tag'], + ], + 'entry4' => [ + 'user' => 'admin-user', + 'url' => 'http://0.0.0.0/entry4', + 'reading_time' => 12, + 'domain' => 'domain.io', + 'mime' => 'text/html', + 'title' => 'test title entry4', + 'content' => 'This is my content /o/', + 'language' => 'en', + 'tags' => ['foo-tag', 'bar-tag'], + ], + 'entry5' => [ + 'user' => 'admin-user', + 'url' => 'http://0.0.0.0/entry5', + 'reading_time' => 12, + 'domain' => 'domain.io', + 'mime' => 'text/html', + 'title' => 'test title entry5', + 'content' => 'This is my content /o/', + 'language' => 'fr', + 'starred' => true, + 'preview' => 'http://0.0.0.0/image.jpg', + ], + 'entry6' => [ + 'user' => 'admin-user', + 'url' => 'http://0.0.0.0/entry6', + 'reading_time' => 12, + 'domain' => 'domain.io', + 'mime' => 'text/html', + 'title' => 'test title entry6', + 'content' => 'This is my content /o/', + 'language' => 'de', + 'archived' => true, + 'tags' => ['bar-tag'], + ], + ]; + + foreach ($entries as $reference => $item) { + $entry = new Entry($this->getReference($item['user'])); + $entry->setUrl($item['url']); + $entry->setReadingTime($item['reading_time']); + $entry->setDomainName($item['domain']); + $entry->setMimetype($item['mime']); + $entry->setTitle($item['title']); + $entry->setContent($item['content']); + $entry->setLanguage($item['language']); + + if (isset($item['tags'])) { + foreach ($item['tags'] as $tag) { + $entry->addTag($this->getReference($tag)); + } + } + + if (isset($item['origin'])) { + $entry->setOriginUrl($item['origin']); + } + + if (isset($item['starred'])) { + $entry->setStarred($item['starred']); + } + + if (isset($item['archived'])) { + $entry->setArchived($item['archived']); + } + + if (isset($item['preview'])) { + $entry->setPreviewPicture($item['preview']); + } + + $manager->persist($entry); + $this->addReference($reference, $entry); + } $manager->flush(); } diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php index 0ecfd18b..485445c1 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php @@ -14,33 +14,22 @@ class LoadTagData extends AbstractFixture implements OrderedFixtureInterface */ public function load(ObjectManager $manager) { - $tag1 = new Tag(); - $tag1->setLabel('foo bar'); - - $manager->persist($tag1); - - $this->addReference('foo-bar-tag', $tag1); - - $tag2 = new Tag(); - $tag2->setLabel('bar'); - - $manager->persist($tag2); - - $this->addReference('bar-tag', $tag2); - - $tag3 = new Tag(); - $tag3->setLabel('baz'); - - $manager->persist($tag3); - - $this->addReference('baz-tag', $tag3); - - $tag4 = new Tag(); - $tag4->setLabel('foo'); - - $manager->persist($tag4); - - $this->addReference('foo-tag', $tag4); + $tags = [ + 'foo-bar-tag' => 'foo bar', //tag used for EntryControllerTest + 'bar-tag' => 'bar', + 'baz-tag' => 'baz', // tag used for ExportControllerTest + 'foo-tag' => 'foo', + 'bob-tag' => 'bob', // tag used for TagRestControllerTest + ]; + + foreach ($tags as $reference => $label) { + $tag = new Tag(); + $tag->setLabel($label); + + $manager->persist($tag); + + $this->addReference($reference, $tag); + } $manager->flush(); } -- cgit v1.2.3 From 6708bf238de46d7ce861e3c0eeb6a9b4623931ed Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sat, 29 Dec 2018 19:42:37 +0100 Subject: TagRepository: refactor query builder for queries by userId Signed-off-by: Kevin Decherf --- .../CoreBundle/Repository/TagRepository.php | 36 ++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index 3ae9d414..bd2d9f97 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php @@ -3,6 +3,7 @@ namespace Wallabag\CoreBundle\Repository; use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\QueryBuilder; use Wallabag\CoreBundle\Entity\Tag; class TagRepository extends EntityRepository @@ -45,12 +46,8 @@ class TagRepository extends EntityRepository */ public function findAllTags($userId) { - $ids = $this->createQueryBuilder('t') + $ids = $this->getQueryBuilderByUser($userId) ->select('t.id') - ->leftJoin('t.entries', 'e') - ->where('e.user = :userId')->setParameter('userId', $userId) - ->groupBy('t.id') - ->orderBy('t.slug') ->getQuery() ->getArrayResult(); @@ -71,14 +68,9 @@ class TagRepository extends EntityRepository */ public function findAllFlatTagsWithNbEntries($userId) { - return $this->createQueryBuilder('t') + return $this->getQueryBuilderByUser($userId) ->select('t.id, t.label, t.slug, count(e.id) as nbEntries') ->distinct(true) - ->leftJoin('t.entries', 'e') - ->where('e.user = :userId') - ->groupBy('t.id') - ->orderBy('t.slug') - ->setParameter('userId', $userId) ->getQuery() ->getArrayResult(); } @@ -101,13 +93,9 @@ class TagRepository extends EntityRepository public function findForArchivedArticlesByUser($userId) { - $ids = $this->createQueryBuilder('t') + $ids = $this->getQueryBuilderByUser($userId) ->select('t.id') - ->leftJoin('t.entries', 'e') - ->where('e.user = :userId')->setParameter('userId', $userId) ->andWhere('e.isArchived = true') - ->groupBy('t.id') - ->orderBy('t.slug') ->getQuery() ->getArrayResult(); @@ -118,4 +106,20 @@ class TagRepository extends EntityRepository return $tags; } + + /** + * Retrieve a sorted list of tags used by a user. + * + * @param int $userId + * + * @return QueryBuilder + */ + private function getQueryBuilderByUser($userId) + { + return $this->createQueryBuilder('t') + ->leftJoin('t.entries', 'e') + ->where('e.user = :userId')->setParameter('userId', $userId) + ->groupBy('t.id') + ->orderBy('t.slug'); + } } -- cgit v1.2.3 From 2a0e0a47d853937702d235bdb91df0ca0e3116b6 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sat, 29 Dec 2018 20:42:41 +0100 Subject: TagRestController: rewrite delete actions to only retrieve tags related to the user Fixes #3815 Signed-off-by: Kevin Decherf --- .../ApiBundle/Controller/TagRestController.php | 22 +++++++++++----------- .../CoreBundle/Repository/TagRepository.php | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 11 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/ApiBundle/Controller/TagRestController.php b/src/Wallabag/ApiBundle/Controller/TagRestController.php index c6d6df6a..f3498f55 100644 --- a/src/Wallabag/ApiBundle/Controller/TagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/TagRestController.php @@ -46,12 +46,14 @@ class TagRestController extends WallabagRestController $this->validateAuthentication(); $label = $request->get('tag', ''); - $tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($label); + $tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findByLabelsAndUser([$label], $this->getUser()->getId()); - if (empty($tag)) { + if (empty($tags)) { throw $this->createNotFoundException('Tag not found'); } + $tag = $tags[0]; + $this->getDoctrine() ->getRepository('WallabagCoreBundle:Entry') ->removeTag($this->getUser()->getId(), $tag); @@ -80,15 +82,7 @@ class TagRestController extends WallabagRestController $tagsLabels = $request->get('tags', ''); - $tags = []; - - foreach (explode(',', $tagsLabels) as $tagLabel) { - $tagEntity = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($tagLabel); - - if (!empty($tagEntity)) { - $tags[] = $tagEntity; - } - } + $tags = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findByLabelsAndUser(explode(',', $tagsLabels), $this->getUser()->getId()); if (empty($tags)) { throw $this->createNotFoundException('Tags not found'); @@ -120,6 +114,12 @@ class TagRestController extends WallabagRestController { $this->validateAuthentication(); + $tagFromDb = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findByLabelsAndUser([$tag->getLabel()], $this->getUser()->getId()); + + if (empty($tagFromDb)) { + throw $this->createNotFoundException('Tag not found'); + } + $this->getDoctrine() ->getRepository('WallabagCoreBundle:Entry') ->removeTag($this->getUser()->getId(), $tag); diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index bd2d9f97..8464a6a5 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php @@ -75,6 +75,23 @@ class TagRepository extends EntityRepository ->getArrayResult(); } + public function findByLabelsAndUser($labels, $userId) + { + $qb = $this->getQueryBuilderByUser($userId) + ->select('t.id'); + + $ids = $qb->andWhere($qb->expr()->in('t.label', $labels)) + ->getQuery() + ->getArrayResult(); + + $tags = []; + foreach ($ids as $id) { + $tags[] = $this->find($id); + } + + return $tags; + } + /** * Used only in test case to get a tag for our entry. * -- cgit v1.2.3 From 9f8f188d928b47503d39348c5990379a572b570a Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Tue, 18 Dec 2018 13:14:42 +0100 Subject: Validate imported entry to avoid error on import We got some imports with a missing `url` field generating some errors while trying to retrieve an existing entry with that url. Introducing the `validateEntry` allow us to dismiss a message when it doesn't have an url (or other missing stuff in the future) --- src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php | 7 +++++++ src/Wallabag/ImportBundle/Import/AbstractImport.php | 17 +++++++++++++++-- src/Wallabag/ImportBundle/Import/BrowserImport.php | 4 ++-- src/Wallabag/ImportBundle/Import/ChromeImport.php | 12 ++++++++++++ src/Wallabag/ImportBundle/Import/FirefoxImport.php | 12 ++++++++++++ src/Wallabag/ImportBundle/Import/InstapaperImport.php | 12 ++++++++++++ src/Wallabag/ImportBundle/Import/PinboardImport.php | 12 ++++++++++++ src/Wallabag/ImportBundle/Import/PocketImport.php | 12 ++++++++++++ src/Wallabag/ImportBundle/Import/ReadabilityImport.php | 12 ++++++++++++ src/Wallabag/ImportBundle/Import/WallabagImport.php | 12 ++++++++++++ 10 files changed, 108 insertions(+), 4 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php index b035f5cc..e4bfbdf0 100644 --- a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php +++ b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php @@ -52,6 +52,13 @@ abstract class AbstractConsumer $this->import->setUser($user); + if (false === $this->import->validateEntry($storedEntry)) { + $this->logger->warning('Entry is invalid', ['entry' => $storedEntry]); + + // return true to skip message + return true; + } + $entry = $this->import->parseEntry($storedEntry); if (null === $entry) { diff --git a/src/Wallabag/ImportBundle/Import/AbstractImport.php b/src/Wallabag/ImportBundle/Import/AbstractImport.php index 58a234f4..d39d71b6 100644 --- a/src/Wallabag/ImportBundle/Import/AbstractImport.php +++ b/src/Wallabag/ImportBundle/Import/AbstractImport.php @@ -118,6 +118,15 @@ abstract class AbstractImport implements ImportInterface */ abstract public function parseEntry(array $importedEntry); + /** + * Validate that an entry is valid (like has some required keys, etc.). + * + * @param array $importedEntry + * + * @return bool + */ + abstract public function validateEntry(array $importedEntry); + /** * Fetch content from the ContentProxy (using graby). * If it fails return the given entry to be saved in all case (to avoid user to loose the content). @@ -141,9 +150,9 @@ abstract class AbstractImport implements ImportInterface /** * Parse and insert all given entries. * - * @param $entries + * @param array $entries */ - protected function parseEntries($entries) + protected function parseEntries(array $entries) { $i = 1; $entryToBeFlushed = []; @@ -153,6 +162,10 @@ abstract class AbstractImport implements ImportInterface $importedEntry = $this->setEntryAsRead($importedEntry); } + if (false === $this->validateEntry($importedEntry)) { + continue; + } + $entry = $this->parseEntry($importedEntry); if (null === $entry) { diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php index 225f1791..4678ae0c 100644 --- a/src/Wallabag/ImportBundle/Import/BrowserImport.php +++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php @@ -149,9 +149,9 @@ abstract class BrowserImport extends AbstractImport /** * Parse and insert all given entries. * - * @param $entries + * @param array $entries */ - protected function parseEntries($entries) + protected function parseEntries(array $entries) { $i = 1; $entryToBeFlushed = []; diff --git a/src/Wallabag/ImportBundle/Import/ChromeImport.php b/src/Wallabag/ImportBundle/Import/ChromeImport.php index 09183abe..eccee698 100644 --- a/src/Wallabag/ImportBundle/Import/ChromeImport.php +++ b/src/Wallabag/ImportBundle/Import/ChromeImport.php @@ -30,6 +30,18 @@ class ChromeImport extends BrowserImport return 'import.chrome.description'; } + /** + * {@inheritdoc} + */ + public function validateEntry(array $importedEntry) + { + if (empty($importedEntry['url'])) { + return false; + } + + return true; + } + /** * {@inheritdoc} */ diff --git a/src/Wallabag/ImportBundle/Import/FirefoxImport.php b/src/Wallabag/ImportBundle/Import/FirefoxImport.php index 73269fe1..8999e3f3 100644 --- a/src/Wallabag/ImportBundle/Import/FirefoxImport.php +++ b/src/Wallabag/ImportBundle/Import/FirefoxImport.php @@ -30,6 +30,18 @@ class FirefoxImport extends BrowserImport return 'import.firefox.description'; } + /** + * {@inheritdoc} + */ + public function validateEntry(array $importedEntry) + { + if (empty($importedEntry['uri'])) { + return false; + } + + return true; + } + /** * {@inheritdoc} */ diff --git a/src/Wallabag/ImportBundle/Import/InstapaperImport.php b/src/Wallabag/ImportBundle/Import/InstapaperImport.php index e4f0970c..5a18c7c0 100644 --- a/src/Wallabag/ImportBundle/Import/InstapaperImport.php +++ b/src/Wallabag/ImportBundle/Import/InstapaperImport.php @@ -105,6 +105,18 @@ class InstapaperImport extends AbstractImport return true; } + /** + * {@inheritdoc} + */ + public function validateEntry(array $importedEntry) + { + if (empty($importedEntry['url'])) { + return false; + } + + return true; + } + /** * {@inheritdoc} */ diff --git a/src/Wallabag/ImportBundle/Import/PinboardImport.php b/src/Wallabag/ImportBundle/Import/PinboardImport.php index 110b0464..995d1f2c 100644 --- a/src/Wallabag/ImportBundle/Import/PinboardImport.php +++ b/src/Wallabag/ImportBundle/Import/PinboardImport.php @@ -80,6 +80,18 @@ class PinboardImport extends AbstractImport return true; } + /** + * {@inheritdoc} + */ + public function validateEntry(array $importedEntry) + { + if (empty($importedEntry['href'])) { + return false; + } + + return true; + } + /** * {@inheritdoc} */ diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index c1b35b7e..d3643389 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php @@ -168,6 +168,18 @@ class PocketImport extends AbstractImport $this->client = $client; } + /** + * {@inheritdoc} + */ + public function validateEntry(array $importedEntry) + { + if (empty($importedEntry['resolved_url']) && empty($importedEntry['given_url'])) { + return false; + } + + return true; + } + /** * {@inheritdoc} * diff --git a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php index 002b27f4..a5f3798e 100644 --- a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php +++ b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php @@ -80,6 +80,18 @@ class ReadabilityImport extends AbstractImport return true; } + /** + * {@inheritdoc} + */ + public function validateEntry(array $importedEntry) + { + if (empty($importedEntry['article__url'])) { + return false; + } + + return true; + } + /** * {@inheritdoc} */ diff --git a/src/Wallabag/ImportBundle/Import/WallabagImport.php b/src/Wallabag/ImportBundle/Import/WallabagImport.php index c64ccd64..350d0600 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagImport.php +++ b/src/Wallabag/ImportBundle/Import/WallabagImport.php @@ -86,6 +86,18 @@ abstract class WallabagImport extends AbstractImport return $this; } + /** + * {@inheritdoc} + */ + public function validateEntry(array $importedEntry) + { + if (empty($importedEntry['url'])) { + return false; + } + + return true; + } + /** * {@inheritdoc} */ -- cgit v1.2.3 From 35983eb9bbbf78041ff9f6679ca345850f41c5f1 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 4 Jan 2019 11:22:43 +0100 Subject: Improve reading time tests --- src/Wallabag/CoreBundle/Tools/Utils.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Tools/Utils.php b/src/Wallabag/CoreBundle/Tools/Utils.php index 0a805210..c14d2aa0 100644 --- a/src/Wallabag/CoreBundle/Tools/Utils.php +++ b/src/Wallabag/CoreBundle/Tools/Utils.php @@ -20,10 +20,9 @@ class Utils } /** - * For a given text, we calculate reading time for an article - * based on 200 words per minute. + * For a given text, we calculate reading time for an article based on 200 words per minute. * - * @param $text + * @param string $text * * @return float */ -- cgit v1.2.3 From 7f8630b91c1ef0a650bfe7cf422126187eb3c8f2 Mon Sep 17 00:00:00 2001 From: lizyn Date: Sat, 5 Jan 2019 12:30:15 +0800 Subject: Counting two characters together as a word in CJK --- src/Wallabag/CoreBundle/Tools/Utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Tools/Utils.php b/src/Wallabag/CoreBundle/Tools/Utils.php index c14d2aa0..e56e251e 100644 --- a/src/Wallabag/CoreBundle/Tools/Utils.php +++ b/src/Wallabag/CoreBundle/Tools/Utils.php @@ -28,6 +28,6 @@ class Utils */ public static function getReadingTime($text) { - return floor(\count(preg_split('~([^\p{L}\p{N}\']+|\p{Han}|\p{Hiragana}|\p{Katakana}|\p{Hangul})~u', strip_tags($text))) / 200); + return floor(\count(preg_split('~([^\p{L}\p{N}\']+|(\p{Han}|\p{Hiragana}|\p{Katakana}|\p{Hangul}){1,2})~u', strip_tags($text))) / 200); } } -- cgit v1.2.3 From bf22266a6230be105ec9a91eccf00e489108405c Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sun, 6 Jan 2019 18:38:02 +0100 Subject: EntriesExport/epub: replace epub identifier with unique urn We replace the title used as the unique identifier of the epub file with a urn following the format: urn:wallabag:{sha1("wallabagUrl:listOfEntryIdsSeparatedByComma")} This format is repeatable: it always gives the same uid for the same list of entries. Fixes #3811 Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Helper/EntriesExport.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index cbf1037b..6082f6b9 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -150,8 +150,6 @@ class EntriesExport */ $book->setTitle($this->title); - // Could also be the ISBN number, prefered for published books, or a UUID. - $book->setIdentifier($this->title, EPub::IDENTIFIER_URI); // Not needed, but included for the example, Language is mandatory, but EPub defaults to "en". Use RFC3066 Language codes, such as "en", "da", "fr" etc. $book->setLanguage($this->language); $book->setDescription('Some articles saved on my wallabag'); @@ -174,6 +172,8 @@ class EntriesExport $book->setCoverImage('Cover.png', file_get_contents($this->logoPath), 'image/png'); } + $entryIds = []; + /* * Adding actual entries */ @@ -192,8 +192,14 @@ class EntriesExport $book->addChapter('Title', 'Title.html', $titlepage, true, EPub::EXTERNAL_REF_ADD); $chapter = $content_start . $entry->getContent() . $bookEnd; $book->addChapter($entry->getTitle(), htmlspecialchars($filename) . '.html', $chapter, true, EPub::EXTERNAL_REF_ADD); + + $entryIds[] = $entry->getId(); } + // Could also be the ISBN number, prefered for published books, or a UUID. + $hash = sha1(sprintf('%s:%s', $this->wallabagUrl, implode(',', $entryIds))); + $book->setIdentifier(sprintf('urn:wallabag:%s', $hash), EPub::IDENTIFIER_URI); + $book->buildTOC(); return Response::create( -- cgit v1.2.3 From 063d5e7bda58fee5363dcbb1f86cee51d72c4940 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sun, 6 Jan 2019 18:55:39 +0100 Subject: EntriesExport/epub: remove TOC page This change only remove the rendered page of the TOC at the end of the book, the TOC remains available to readers. Fixes #3603 Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Helper/EntriesExport.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 6082f6b9..5658a7d3 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -200,8 +200,6 @@ class EntriesExport $hash = sha1(sprintf('%s:%s', $this->wallabagUrl, implode(',', $entryIds))); $book->setIdentifier(sprintf('urn:wallabag:%s', $hash), EPub::IDENTIFIER_URI); - $book->buildTOC(); - return Response::create( $book->getBook(), 200, -- cgit v1.2.3 From edd1825b5832303b714bec37b8796b9077e7ddc0 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sun, 6 Jan 2019 19:13:26 +0100 Subject: EntriesExport/epub: use sha1 sums for filenames, fix and rename title chapters This commit renames entry chapters file using a sha1 sum of their title for simplicity. Also we fix the 'Title' chapter duplicate issue by using the hash of the related entry and the suffix '_title'. Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Helper/EntriesExport.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 5658a7d3..ea5a03cf 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -173,6 +173,8 @@ class EntriesExport } $entryIds = []; + $entryCount = \count($this->entries); + $i = 0; /* * Adding actual entries @@ -180,20 +182,18 @@ class EntriesExport // set tags as subjects foreach ($this->entries as $entry) { + ++$i; foreach ($entry->getTags() as $tag) { $book->setSubject($tag->getLabel()); } - - // the reader in Kobo Devices doesn't likes special caracters - // in filenames, we limit to A-z/0-9 - $filename = preg_replace('/[^A-Za-z0-9\-]/', '', $entry->getTitle()); + $filename = sha1($entry->getTitle()); $titlepage = $content_start . '

    ' . $entry->getTitle() . '

    ' . $this->getExportInformation('PHPePub') . $bookEnd; - $book->addChapter('Title', 'Title.html', $titlepage, true, EPub::EXTERNAL_REF_ADD); + $book->addChapter("Entry {$i} of {$entryCount}", "{$filename}_cover.html", $titlepage, true, EPub::EXTERNAL_REF_ADD); $chapter = $content_start . $entry->getContent() . $bookEnd; - $book->addChapter($entry->getTitle(), htmlspecialchars($filename) . '.html', $chapter, true, EPub::EXTERNAL_REF_ADD); $entryIds[] = $entry->getId(); + $book->addChapter($entry->getTitle(), "{$filename}.html", $chapter, true, EPub::EXTERNAL_REF_ADD); } // Could also be the ISBN number, prefered for published books, or a UUID. -- cgit v1.2.3 From 30cf72bf55cdb2130e9096b1f7bcfa2f2ea1df1c Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sun, 6 Jan 2019 19:23:01 +0100 Subject: EntriesExport/epub: revert c779373f, move exportinfo to the end of the book Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Helper/EntriesExport.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index ea5a03cf..92f1779c 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -188,7 +188,7 @@ class EntriesExport } $filename = sha1($entry->getTitle()); - $titlepage = $content_start . '

    ' . $entry->getTitle() . '

    ' . $this->getExportInformation('PHPePub') . $bookEnd; + $titlepage = $content_start . '

    ' . $entry->getTitle() . '

    ' . $bookEnd; $book->addChapter("Entry {$i} of {$entryCount}", "{$filename}_cover.html", $titlepage, true, EPub::EXTERNAL_REF_ADD); $chapter = $content_start . $entry->getContent() . $bookEnd; @@ -196,6 +196,8 @@ class EntriesExport $book->addChapter($entry->getTitle(), "{$filename}.html", $chapter, true, EPub::EXTERNAL_REF_ADD); } + $book->addChapter('Notices', 'Cover2.html', $content_start . $this->getExportInformation('PHPePub') . $bookEnd); + // Could also be the ISBN number, prefered for published books, or a UUID. $hash = sha1(sprintf('%s:%s', $this->wallabagUrl, implode(',', $entryIds))); $book->setIdentifier(sprintf('urn:wallabag:%s', $hash), EPub::IDENTIFIER_URI); -- cgit v1.2.3 From f8108346236e18768c08d6c0d4dc5fb4dfe13b78 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sun, 6 Jan 2019 20:17:35 +0100 Subject: EntriesExport: change authors and title when not single entry export Change '{method} authors' (which gives 'Tag_entries authors' when exporting a tag) to 'Various authors'. When exporting a tag (tag_entries), change the title from 'Tag_entries articles' to 'Tag {tag} articles'. Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Controller/ExportController.php | 5 ++++- src/Wallabag/CoreBundle/Helper/EntriesExport.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php index 7ca89239..9e9dbe49 100644 --- a/src/Wallabag/CoreBundle/Controller/ExportController.php +++ b/src/Wallabag/CoreBundle/Controller/ExportController.php @@ -58,6 +58,7 @@ class ExportController extends Controller $method = ucfirst($category); $methodBuilder = 'getBuilderFor' . $method . 'ByUser'; $repository = $this->get('wallabag_core.entry_repository'); + $title = $method; if ('tag_entries' === $category) { $tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag')); @@ -66,6 +67,8 @@ class ExportController extends Controller $this->getUser()->getId(), $tag->getId() ); + + $title = 'Tag ' . $tag->getLabel(); } else { $entries = $repository ->$methodBuilder($this->getUser()->getId()) @@ -76,7 +79,7 @@ class ExportController extends Controller try { return $this->get('wallabag_core.helper.entries_export') ->setEntries($entries) - ->updateTitle($method) + ->updateTitle($title) ->updateAuthor($method) ->exportAs($format); } catch (\InvalidArgumentException $e) { diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 92f1779c..db5340fc 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -85,7 +85,7 @@ class EntriesExport public function updateAuthor($method) { if ('entry' !== $method) { - $this->author = $method . ' authors'; + $this->author = 'Various authors'; return $this; } -- cgit v1.2.3 From 4944703edc7cdd2c8cd645b785603b4405d2a288 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sun, 6 Jan 2019 23:27:13 +0100 Subject: EntriesExport/epub: add metadata to each entry's cover Add metadata to the cover of each entry: - Publishers - Estimated reading time - Date of creation ("Added on") - Address (URL) Related to #2821 Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Helper/EntriesExport.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index db5340fc..9cde27c6 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -188,7 +188,22 @@ class EntriesExport } $filename = sha1($entry->getTitle()); - $titlepage = $content_start . '

    ' . $entry->getTitle() . '

    ' . $bookEnd; + $publishedBy = $entry->getPublishedBy(); + if (!empty($publishedBy)) { + $authors = implode(',', $publishedBy); + } else { + $authors = $this->translator->trans('export.unknown'); + } + + $titlepage = $content_start . + '

    ' . $entry->getTitle() . '

    ' . + '
    ' . + '
    ' . $this->translator->trans('entry.view.published_by') . '
    ' . $authors . '
    ' . + '
    ' . $this->translator->trans('entry.metadata.reading_time') . '
    ' . $this->translator->trans('entry.metadata.reading_time_minutes_short', ['%readingTime%' => $entry->getReadingTime()]) . '
    ' . + '
    ' . $this->translator->trans('entry.metadata.added_on') . '
    ' . $entry->getCreatedAt()->format('Y-m-d') . '
    ' . + '
    ' . $this->translator->trans('entry.metadata.address') . '
    ' . $entry->getUrl() . '
    ' . + '
    ' . + $bookEnd; $book->addChapter("Entry {$i} of {$entryCount}", "{$filename}_cover.html", $titlepage, true, EPub::EXTERNAL_REF_ADD); $chapter = $content_start . $entry->getContent() . $bookEnd; -- cgit v1.2.3 From af83d05ce2bfda2a00bd764f5717d77824325d33 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sun, 6 Jan 2019 23:28:39 +0100 Subject: Add translations Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Resources/translations/messages.da.yml | 6 ++++++ src/Wallabag/CoreBundle/Resources/translations/messages.de.yml | 6 ++++++ src/Wallabag/CoreBundle/Resources/translations/messages.en.yml | 6 ++++++ src/Wallabag/CoreBundle/Resources/translations/messages.es.yml | 6 ++++++ src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml | 6 ++++++ src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml | 6 ++++++ src/Wallabag/CoreBundle/Resources/translations/messages.it.yml | 6 ++++++ src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml | 6 ++++++ src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml | 8 +++++++- src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml | 6 ++++++ src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml | 6 ++++++ src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml | 9 +++++++++ src/Wallabag/CoreBundle/Resources/translations/messages.th.yml | 6 ++++++ src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml | 6 ++++++ 14 files changed, 88 insertions(+), 1 deletion(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index e3ff21f1..97eb874d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -253,6 +253,11 @@ entry: confirm: # delete: "Are you sure you want to remove that article?" # delete_tag: "Are you sure you want to remove that tag from that article?" + metadata: + # reading_time: "Estimated reading time" + # reading_time_minutes_short: "%readingTime% min" + # address: "Address" + # added_on: "Added on" about: page_title: 'Om' @@ -402,6 +407,7 @@ tag: # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' +# unknown: 'Unknown' import: # page_title: 'Import' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index c297ffb5..0cf3b138 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -253,6 +253,11 @@ entry: confirm: delete: 'Bist du sicher, dass du diesen Artikel löschen möchtest?' delete_tag: 'Bist du sicher, dass du diesen Tag vom Artikel entfernen möchtest?' + metadata: + # reading_time: "Estimated reading time" + # reading_time_minutes_short: "%readingTime% min" + # address: "Address" + # added_on: "Added on" about: page_title: 'Über' @@ -402,6 +407,7 @@ tag: export: footer_template: '

    Generiert von wallabag mit Hilfe von %method%

    Bitte öffne ein Ticket wenn du ein Problem mit der Darstellung von diesem E-Book auf deinem Gerät hast.

    ' + # unknown: 'Unknown' import: page_title: 'Importieren' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 169ae728..6085be14 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -253,6 +253,11 @@ entry: confirm: delete: "Are you sure you want to remove that article?" delete_tag: "Are you sure you want to remove that tag from that article?" + metadata: + reading_time: "Estimated reading time" + reading_time_minutes_short: "%readingTime% min" + address: "Address" + added_on: "Added on" about: page_title: 'About' @@ -402,6 +407,7 @@ tag: export: footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' + unknown: 'Unknown' import: page_title: 'Import' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 039a1867..f2a8fb89 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -253,6 +253,11 @@ entry: confirm: # delete: "Are you sure you want to remove that article?" # delete_tag: "Are you sure you want to remove that tag from that article?" + metadata: + # reading_time: "Estimated reading time" + # reading_time_minutes_short: "%readingTime% min" + # address: "Address" + # added_on: "Added on" about: page_title: 'Acerca de' @@ -402,6 +407,7 @@ tag: # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' +# unknown: 'Unknown' import: page_title: 'Importar' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index b3f2eb58..a5cbd7ec 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -253,6 +253,11 @@ entry: confirm: # delete: "Are you sure you want to remove that article?" # delete_tag: "Are you sure you want to remove that tag from that article?" + metadata: + # reading_time: "Estimated reading time" + # reading_time_minutes_short: "%readingTime% min" + # address: "Address" + # added_on: "Added on" about: page_title: 'درباره' @@ -402,6 +407,7 @@ tag: # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' +# unknown: 'Unknown' import: page_title: 'درون‌ریزی' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 5cdd836e..a36d84ae 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -253,6 +253,11 @@ entry: confirm: delete: "Voulez-vous vraiment supprimer cet article ?" delete_tag: "Voulez-vous vraiment supprimer ce tag de cet article ?" + metadata: + reading_time: "Durée de lecture estimée" + reading_time_minutes_short: "%readingTime% min" + address: "Adresse" + added_on: "Ajouté le" about: page_title: "À propos" @@ -402,6 +407,7 @@ tag: export: footer_template: '

    Généré par wallabag with %method%

    Merci d''ouvrir un ticket si vous rencontrez des soucis d''affichage avec ce document sur votre support.

    ' + unknown: 'Inconnu' import: page_title: "Importer" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 83b3edcd..1649c0e4 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -253,6 +253,11 @@ entry: confirm: delete: "Vuoi veramente rimuovere quell'articolo?" delete_tag: "Vuoi veramente rimuovere quell'etichetta da quell'articolo?" + metadata: + # reading_time: "Estimated reading time" + # reading_time_minutes_short: "%readingTime% min" + # address: "Address" + # added_on: "Added on" about: page_title: 'A proposito' @@ -402,6 +407,7 @@ tag: # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' +# unknown: 'Unknown' import: page_title: 'Importa' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 95bc9560..e2298f1f 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -253,6 +253,11 @@ entry: confirm: delete: "Sètz segur de voler suprimir aqueste article ?" delete_tag: "Sètz segur de voler levar aquesta etiqueta de l'article ?" + metadata: + # reading_time: "Estimated reading time" + # reading_time_minutes_short: "%readingTime% min" + # address: "Address" + # added_on: "Added on" about: page_title: 'A prepaus' @@ -402,6 +407,7 @@ tag: export: footer_template: '

    Produch per wallabag amb %method%

    Mercés de dobrir una sollicitacion s’avètz de problèmas amb l’afichatge d’aqueste E-Book sus vòstre periferic.

    ' + # unknown: 'Unknown' import: page_title: 'Importar' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index a64e60b0..a5712733 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -253,6 +253,11 @@ entry: confirm: delete: "Czy jesteś pewien, że chcesz usunąć ten artykuł?" delete_tag: "Czy jesteś pewien, że chcesz usunąć ten tag, z tego artykułu?" + metadata: + # reading_time: "Estimated reading time" + # reading_time_minutes_short: "%readingTime% min" + # address: "Address" + # added_on: "Added on" about: page_title: 'O nas' @@ -401,7 +406,8 @@ tag: placeholder: 'Możesz dodać kilka tagów, oddzielając je przecinkami.' export: - footer_template: '

    Stworzone przez wallabag z %method%

    Proszę zgłoś sprawę, jeżeli masz problem z wyświetleniem tego e-booka na swoim urządzeniu.

    ' + footer_template: '

    Stworzone przez wallabag z %method%

    Proszę zgłoś sprawę, jeżeli masz problem z wyświetleniem tego e-booka na swoim urządzeniu.

    ' + # unknown: 'Unknown' import: page_title: 'Import' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml index 58d2d058..1ccf49e1 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml @@ -253,6 +253,11 @@ entry: confirm: # delete: "Are you sure you want to remove that article?" # delete_tag: "Are you sure you want to remove that tag from that article?" + metadata: + # reading_time: "Estimated reading time" + # reading_time_minutes_short: "%readingTime% min" + # address: "Address" + # added_on: "Added on" about: page_title: 'Sobre' @@ -402,6 +407,7 @@ tag: # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' +# unknown: 'Unknown' import: page_title: 'Importar' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 564fed94..6c0e18e1 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -253,6 +253,11 @@ entry: confirm: # delete: "Are you sure you want to remove that article?" # delete_tag: "Are you sure you want to remove that tag from that article?" + metadata: + # reading_time: "Estimated reading time" + # reading_time_minutes_short: "%readingTime% min" + # address: "Address" + # added_on: "Added on" about: page_title: 'Despre' @@ -402,6 +407,7 @@ tag: # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' +# unknown: 'Unknown' import: # page_title: 'Import' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml index 5f210c93..48753b55 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml @@ -241,6 +241,11 @@ entry: save_label: 'Сохранить' public: shared_by_wallabag: "Запись была опубликована wallabag" + metadata: + # reading_time: "Estimated reading time" + # reading_time_minutes_short: "%readingTime% min" + # address: "Address" + # added_on: "Added on" about: page_title: 'О' @@ -388,6 +393,10 @@ tag: add: 'Добавить' placeholder: 'Вы можете добавить несколько тегов, разделенных запятой.' +# export: +# footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' +# unknown: 'Unknown' + import: page_title: 'Импорт' page_description: 'Добро пожаловать в импортер wallabag. Выберите сервис, из которого вы хотите перенести данные.' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml index 9d22f90d..5524b1f1 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml @@ -251,6 +251,11 @@ entry: confirm: delete: "คุณแน่ใจหรือไม่ว่าคุณต้องการลบบทความนี้?" delete_tag: "คุณแน่ใจหรือไม่ว่าคุณต้องการลบแท็กจากบทความนี้?" + metadata: + # reading_time: "Estimated reading time" + # reading_time_minutes_short: "%readingTime% min" + # address: "Address" + # added_on: "Added on" about: page_title: 'เกี่ยวกับ' @@ -400,6 +405,7 @@ tag: export: footer_template: '

    ผลิตโดย wallabag กับ %method%

    ให้ทำการเปิด ฉบับนี้ ถ้าคุณมีข้อบกพร่องif you have trouble with the display of this E-Book on your device.

    ' + # unknown: 'Unknown' import: page_title: 'นำข้อมูลเช้า' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 4c71f0b9..e2156d47 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -251,6 +251,11 @@ entry: confirm: # delete: "Are you sure you want to remove that article?" # delete_tag: "Are you sure you want to remove that tag from that article?" + metadata: + # reading_time: "Estimated reading time" + # reading_time_minutes_short: "%readingTime% min" + # address: "Address" + # added_on: "Added on" about: page_title: 'Hakkımızda' @@ -400,6 +405,7 @@ tag: # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' +# unknown: 'Unknown' import: page_title: 'İçe Aktar' -- cgit v1.2.3 From ad5ef8bca0c0321f348dcf402e0a20791eca3f4d Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Mon, 7 Jan 2019 23:36:41 +0100 Subject: EntriesExport/pdf: move notice to the end, add metadata cover Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Helper/EntriesExport.php | 33 ++++++++++++++++++------ 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 9cde27c6..1debdf8e 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -299,14 +299,6 @@ class EntriesExport $pdf->SetSubject('Articles via wallabag'); $pdf->SetKeywords('wallabag'); - /* - * Front page - */ - $pdf->AddPage(); - $intro = '

    ' . $this->title . '

    ' . $this->getExportInformation('tcpdf'); - - $pdf->writeHTMLCell(0, 0, '', '', $intro, 0, 1, 0, true, '', true); - /* * Adding actual entries */ @@ -315,6 +307,23 @@ class EntriesExport $pdf->SetKeywords($tag->getLabel()); } + $publishedBy = $entry->getPublishedBy(); + if (!empty($publishedBy)) { + $authors = implode(',', $publishedBy); + } else { + $authors = $this->translator->trans('export.unknown'); + } + + $pdf->addPage(); + $html = '

    ' . $entry->getTitle() . '

    ' . + '
    ' . + '
    ' . $this->translator->trans('entry.view.published_by') . '
    ' . $authors . '
    ' . + '
    ' . $this->translator->trans('entry.metadata.reading_time') . '
    ' . $this->translator->trans('entry.metadata.reading_time_minutes_short', ['%readingTime%' => $entry->getReadingTime()]) . '
    ' . + '
    ' . $this->translator->trans('entry.metadata.added_on') . '
    ' . $entry->getCreatedAt()->format('Y-m-d') . '
    ' . + '
    ' . $this->translator->trans('entry.metadata.address') . '
    ' . $entry->getUrl() . '
    ' . + '
    '; + $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + $pdf->AddPage(); $html = '

    ' . $entry->getTitle() . '

    '; $html .= $entry->getContent(); @@ -322,6 +331,14 @@ class EntriesExport $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); } + /* + * Last page + */ + $pdf->AddPage(); + $html = $this->getExportInformation('tcpdf'); + + $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); + // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); -- cgit v1.2.3 From dac93644e8585cc6b2ea1a0409b11ed82bb8169d Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Mon, 7 Jan 2019 23:50:08 +0100 Subject: EntriesExport: sanitize filename and fix tests Filename will now only use a-zA-Z0-9-' and space. Fixes remaining filename issue on #3811 Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Helper/EntriesExport.php | 28 +++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 1debdf8e..1a611199 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -223,7 +223,7 @@ class EntriesExport [ 'Content-Description' => 'File Transfer', 'Content-type' => 'application/epub+zip', - 'Content-Disposition' => 'attachment; filename="' . $this->title . '.epub"', + 'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.epub"', 'Content-Transfer-Encoding' => 'binary', ] ); @@ -265,9 +265,6 @@ class EntriesExport } $mobi->setContentProvider($content); - // the browser inside Kindle Devices doesn't likes special caracters either, we limit to A-z/0-9 - $this->title = preg_replace('/[^A-Za-z0-9\-]/', '', $this->title); - return Response::create( $mobi->toString(), 200, @@ -275,7 +272,7 @@ class EntriesExport 'Accept-Ranges' => 'bytes', 'Content-Description' => 'File Transfer', 'Content-type' => 'application/x-mobipocket-ebook', - 'Content-Disposition' => 'attachment; filename="' . $this->title . '.mobi"', + 'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.mobi"', 'Content-Transfer-Encoding' => 'binary', ] ); @@ -348,7 +345,7 @@ class EntriesExport [ 'Content-Description' => 'File Transfer', 'Content-type' => 'application/pdf', - 'Content-Disposition' => 'attachment; filename="' . $this->title . '.pdf"', + 'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.pdf"', 'Content-Transfer-Encoding' => 'binary', ] ); @@ -394,7 +391,7 @@ class EntriesExport 200, [ 'Content-type' => 'application/csv', - 'Content-Disposition' => 'attachment; filename="' . $this->title . '.csv"', + 'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.csv"', 'Content-Transfer-Encoding' => 'UTF-8', ] ); @@ -412,7 +409,7 @@ class EntriesExport 200, [ 'Content-type' => 'application/json', - 'Content-Disposition' => 'attachment; filename="' . $this->title . '.json"', + 'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.json"', 'Content-Transfer-Encoding' => 'UTF-8', ] ); @@ -430,7 +427,7 @@ class EntriesExport 200, [ 'Content-type' => 'application/xml', - 'Content-Disposition' => 'attachment; filename="' . $this->title . '.xml"', + 'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.xml"', 'Content-Transfer-Encoding' => 'UTF-8', ] ); @@ -456,7 +453,7 @@ class EntriesExport 200, [ 'Content-type' => 'text/plain', - 'Content-Disposition' => 'attachment; filename="' . $this->title . '.txt"', + 'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.txt"', 'Content-Transfer-Encoding' => 'UTF-8', ] ); @@ -499,4 +496,15 @@ class EntriesExport return str_replace('%IMAGE%', '', $info); } + + /** + * Return a sanitized version of the title by applying translit iconv + * and removing non alphanumeric characters, - and space. + * + * @return string Sanitized filename + */ + private function getSanitizedFilename() + { + return preg_replace('/[^A-Za-z0-9\- \']/', '', iconv('utf-8', 'us-ascii//TRANSLIT', $this->title)); + } } -- cgit v1.2.3 From 5e1f27767bc2dcf0760bc3061544ecbb833ad5e7 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Wed, 9 Jan 2019 16:26:19 +0100 Subject: EntriesExport: avoid else on $authors Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Helper/EntriesExport.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 1a611199..64591687 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -189,10 +189,9 @@ class EntriesExport $filename = sha1($entry->getTitle()); $publishedBy = $entry->getPublishedBy(); + $authors = $this->translator->trans('export.unknown'); if (!empty($publishedBy)) { $authors = implode(',', $publishedBy); - } else { - $authors = $this->translator->trans('export.unknown'); } $titlepage = $content_start . @@ -305,10 +304,9 @@ class EntriesExport } $publishedBy = $entry->getPublishedBy(); + $authors = $this->translator->trans('export.unknown'); if (!empty($publishedBy)) { $authors = implode(',', $publishedBy); - } else { - $authors = $this->translator->trans('export.unknown'); } $pdf->addPage(); -- cgit v1.2.3 From 3a2d4cf9fda87760c86320a7f8a5041d1d4256c6 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 9 Jan 2019 23:29:30 +0100 Subject: Cast client id to avoid PG error If someone send a malformated client_id when trying to authenticate using the API we got a 500 if wallabag use postgres because the request send a string instead of an integer. --- src/Wallabag/ApiBundle/Entity/Client.php | 2 +- .../ApiBundle/Repository/ClientRepository.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/Wallabag/ApiBundle/Repository/ClientRepository.php (limited to 'src/Wallabag') diff --git a/src/Wallabag/ApiBundle/Entity/Client.php b/src/Wallabag/ApiBundle/Entity/Client.php index e6f98f98..78349820 100644 --- a/src/Wallabag/ApiBundle/Entity/Client.php +++ b/src/Wallabag/ApiBundle/Entity/Client.php @@ -11,7 +11,7 @@ use Wallabag\UserBundle\Entity\User; /** * @ORM\Table("oauth2_clients") - * @ORM\Entity + * @ORM\Entity(repositoryClass="Wallabag\ApiBundle\Repository\ClientRepository") */ class Client extends BaseClient { diff --git a/src/Wallabag/ApiBundle/Repository/ClientRepository.php b/src/Wallabag/ApiBundle/Repository/ClientRepository.php new file mode 100644 index 00000000..fc14262e --- /dev/null +++ b/src/Wallabag/ApiBundle/Repository/ClientRepository.php @@ -0,0 +1,19 @@ + Date: Thu, 10 Jan 2019 04:23:08 +0100 Subject: Update entries.html.twig Should fix https://github.com/wallabag/wallabag/issues/3832 --- .../Resources/views/themes/material/Entry/entries.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig index a137f3c3..742dd330 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig @@ -68,8 +68,8 @@ {% if craue_setting('export_epub') %}
  • EPUB
  • {% endif %} {% if craue_setting('export_mobi') %}
  • MOBI
  • {% endif %} {% if craue_setting('export_pdf') %}
  • PDF
  • {% endif %} - {% if craue_setting('export_csv') %}
  • JSON
  • {% endif %} - {% if craue_setting('export_json') %}
  • CSV
  • {% endif %} + {% if craue_setting('export_json') %}
  • JSON
  • {% endif %} + {% if craue_setting('export_csv') %}
  • CSV
  • {% endif %} {% if craue_setting('export_txt') %}
  • TXT
  • {% endif %} {% if craue_setting('export_xml') %}
  • XML
  • {% endif %}
-- cgit v1.2.3 From bb8ad42b279531a4437ab283e3b995bfa88ea87f Mon Sep 17 00:00:00 2001 From: Eloi Coutant Date: Thu, 10 Jan 2019 04:25:51 +0100 Subject: Update entries.html.twig Should fix https://github.com/wallabag/wallabag/issues/3832 --- .../CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig index cfc6644b..832112be 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig @@ -99,8 +99,8 @@ {% if craue_setting('export_epub') %}
  • EPUB
  • {% endif %} {% if craue_setting('export_mobi') %}
  • MOBI
  • {% endif %} {% if craue_setting('export_pdf') %}
  • PDF
  • {% endif %} - {% if craue_setting('export_csv') %}
  • JSON
  • {% endif %} - {% if craue_setting('export_json') %}
  • CSV
  • {% endif %} + {% if craue_setting('export_json') %}
  • JSON
  • {% endif %} + {% if craue_setting('export_csv') %}
  • CSV
  • {% endif %} {% if craue_setting('export_txt') %}
  • TXT
  • {% endif %} {% if craue_setting('export_xml') %}
  • XML
  • {% endif %} -- cgit v1.2.3 From 78e3fafa3fab86638295fe1ee2a05a559bf56ab1 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 14 Jan 2019 17:01:21 +0100 Subject: Avoid error when a bad `order` parameter is given Only allowed parameter are asc & desc --- .../ApiBundle/Controller/EntryRestController.php | 31 +++++++++++++--------- .../CoreBundle/Repository/EntryRepository.php | 6 ++++- 2 files changed, 23 insertions(+), 14 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index 0b4e74a0..b2bad406 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php @@ -9,6 +9,7 @@ use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Wallabag\CoreBundle\Entity\Entry; @@ -98,24 +99,28 @@ class EntryRestController extends WallabagRestController $isArchived = (null === $request->query->get('archive')) ? null : (bool) $request->query->get('archive'); $isStarred = (null === $request->query->get('starred')) ? null : (bool) $request->query->get('starred'); $isPublic = (null === $request->query->get('public')) ? null : (bool) $request->query->get('public'); - $sort = $request->query->get('sort', 'created'); - $order = $request->query->get('order', 'desc'); + $sort = strtolower($request->query->get('sort', 'created')); + $order = strtolower($request->query->get('order', 'desc')); $page = (int) $request->query->get('page', 1); $perPage = (int) $request->query->get('perPage', 30); $tags = \is_array($request->query->get('tags')) ? '' : (string) $request->query->get('tags', ''); $since = $request->query->get('since', 0); - /** @var \Pagerfanta\Pagerfanta $pager */ - $pager = $this->get('wallabag_core.entry_repository')->findEntries( - $this->getUser()->getId(), - $isArchived, - $isStarred, - $isPublic, - $sort, - $order, - $since, - $tags - ); + try { + /** @var \Pagerfanta\Pagerfanta $pager */ + $pager = $this->get('wallabag_core.entry_repository')->findEntries( + $this->getUser()->getId(), + $isArchived, + $isStarred, + $isPublic, + $sort, + $order, + $since, + $tags + ); + } catch (\Exception $e) { + throw new BadRequestHttpException($e->getMessage()); + } $pager->setMaxPerPage($perPage); $pager->setCurrentPage($page); diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 83379998..cebce714 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -142,7 +142,7 @@ class EntryRepository extends EntityRepository * * @return Pagerfanta */ - public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'ASC', $since = 0, $tags = '') + public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'asc', $since = 0, $tags = '') { $qb = $this->createQueryBuilder('e') ->leftJoin('e.tags', 't') @@ -185,6 +185,10 @@ class EntryRepository extends EntityRepository } } + if (!\in_array(strtolower($order), ['asc', 'desc'], true)) { + throw new \Exception('Order "' . $order . '" parameter is wrong, allowed: asc or desc'); + } + if ('created' === $sort) { $qb->orderBy('e.id', $order); } elseif ('updated' === $sort) { -- cgit v1.2.3