diff options
10 files changed, 44 insertions, 15 deletions
diff --git a/app/Resources/static/themes/_global/index.js b/app/Resources/static/themes/_global/index.js index 3ec26488..fddb476d 100644 --- a/app/Resources/static/themes/_global/index.js +++ b/app/Resources/static/themes/_global/index.js | |||
@@ -9,7 +9,7 @@ import 'material-design-icons-iconfont/dist/material-design-icons.css'; | |||
9 | import 'lato-font/css/lato-font.css'; | 9 | import 'lato-font/css/lato-font.css'; |
10 | import './global.scss'; | 10 | import './global.scss'; |
11 | 11 | ||
12 | /* Shortcuts*/ | 12 | /* Shortcuts */ |
13 | import './js/shortcuts/entry'; | 13 | import './js/shortcuts/entry'; |
14 | import './js/shortcuts/main'; | 14 | import './js/shortcuts/main'; |
15 | 15 | ||
diff --git a/app/Resources/static/themes/_global/js/shortcuts/main.js b/app/Resources/static/themes/_global/js/shortcuts/main.js index c81bf869..b99fa802 100644 --- a/app/Resources/static/themes/_global/js/shortcuts/main.js +++ b/app/Resources/static/themes/_global/js/shortcuts/main.js | |||
@@ -1,6 +1,6 @@ | |||
1 | import Mousetrap from 'mousetrap'; | 1 | import Mousetrap from 'mousetrap'; |
2 | 2 | ||
3 | /** Shortcuts **/ | 3 | /* Shortcuts */ |
4 | 4 | ||
5 | /* Go to */ | 5 | /* Go to */ |
6 | Mousetrap.bind('g u', () => { window.location.href = Routing.generate('homepage'); }); | 6 | Mousetrap.bind('g u', () => { window.location.href = Routing.generate('homepage'); }); |
diff --git a/composer.json b/composer.json index e609af40..fa0a4a39 100644 --- a/composer.json +++ b/composer.json | |||
@@ -84,7 +84,8 @@ | |||
84 | "symfony/dom-crawler": "^3.1", | 84 | "symfony/dom-crawler": "^3.1", |
85 | "friendsofsymfony/jsrouting-bundle": "^1.6", | 85 | "friendsofsymfony/jsrouting-bundle": "^1.6", |
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 | }, | 89 | }, |
89 | "require-dev": { | 90 | "require-dev": { |
90 | "doctrine/doctrine-fixtures-bundle": "~2.2", | 91 | "doctrine/doctrine-fixtures-bundle": "~2.2", |
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php index 6de561e0..0ecfd18b 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php | |||
@@ -19,7 +19,7 @@ class LoadTagData extends AbstractFixture implements OrderedFixtureInterface | |||
19 | 19 | ||
20 | $manager->persist($tag1); | 20 | $manager->persist($tag1); |
21 | 21 | ||
22 | $this->addReference('foo-tag', $tag1); | 22 | $this->addReference('foo-bar-tag', $tag1); |
23 | 23 | ||
24 | $tag2 = new Tag(); | 24 | $tag2 = new Tag(); |
25 | $tag2->setLabel('bar'); | 25 | $tag2->setLabel('bar'); |
@@ -35,6 +35,13 @@ class LoadTagData extends AbstractFixture implements OrderedFixtureInterface | |||
35 | 35 | ||
36 | $this->addReference('baz-tag', $tag3); | 36 | $this->addReference('baz-tag', $tag3); |
37 | 37 | ||
38 | $tag4 = new Tag(); | ||
39 | $tag4->setLabel('foo'); | ||
40 | |||
41 | $manager->persist($tag4); | ||
42 | |||
43 | $this->addReference('foo-tag', $tag4); | ||
44 | |||
38 | $manager->flush(); | 45 | $manager->flush(); |
39 | } | 46 | } |
40 | 47 | ||
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index de259e7f..838b9734 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | namespace Wallabag\CoreBundle\Helper; | 3 | namespace Wallabag\CoreBundle\Helper; |
4 | 4 | ||
5 | use Html2Text\Html2Text; | ||
5 | use JMS\Serializer\SerializationContext; | 6 | use JMS\Serializer\SerializationContext; |
6 | use JMS\Serializer\SerializerBuilder; | 7 | use JMS\Serializer\SerializerBuilder; |
7 | use PHPePub\Core\EPub; | 8 | use PHPePub\Core\EPub; |
@@ -408,7 +409,8 @@ class EntriesExport | |||
408 | $bar = str_repeat('=', 100); | 409 | $bar = str_repeat('=', 100); |
409 | foreach ($this->entries as $entry) { | 410 | foreach ($this->entries as $entry) { |
410 | $content .= "\n\n" . $bar . "\n\n" . $entry->getTitle() . "\n\n" . $bar . "\n\n"; | 411 | $content .= "\n\n" . $bar . "\n\n" . $entry->getTitle() . "\n\n" . $bar . "\n\n"; |
411 | $content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent()))) . "\n\n"; | 412 | $html = new Html2Text($entry->getContent(), ['do_links' => 'none', 'width' => 100]); |
413 | $content .= $html->getText(); | ||
412 | } | 414 | } |
413 | 415 | ||
414 | return Response::create( | 416 | return Response::create( |
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index ecc159fc..05f0e0ba 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -133,7 +133,7 @@ class EntryRepository extends EntityRepository | |||
133 | { | 133 | { |
134 | $qb = $this->createQueryBuilder('e') | 134 | $qb = $this->createQueryBuilder('e') |
135 | ->leftJoin('e.tags', 't') | 135 | ->leftJoin('e.tags', 't') |
136 | ->where('e.user =:userId')->setParameter('userId', $userId); | 136 | ->where('e.user = :userId')->setParameter('userId', $userId); |
137 | 137 | ||
138 | if (null !== $isArchived) { | 138 | if (null !== $isArchived) { |
139 | $qb->andWhere('e.isArchived = :isArchived')->setParameter('isArchived', (bool) $isArchived); | 139 | $qb->andWhere('e.isArchived = :isArchived')->setParameter('isArchived', (bool) $isArchived); |
@@ -152,8 +152,23 @@ class EntryRepository extends EntityRepository | |||
152 | } | 152 | } |
153 | 153 | ||
154 | if ('' !== $tags) { | 154 | if ('' !== $tags) { |
155 | foreach (explode(',', $tags) as $tag) { | 155 | foreach (explode(',', $tags) as $i => $tag) { |
156 | $qb->andWhere('t.label = :label')->setParameter('label', $tag); | 156 | $entryAlias = 'e' . $i; |
157 | $tagAlias = 't' . $i; | ||
158 | |||
159 | // Complexe queries to ensure multiple tags are associated to an entry | ||
160 | // https://stackoverflow.com/a/6638146/569101 | ||
161 | $qb->andWhere($qb->expr()->in( | ||
162 | 'e.id', | ||
163 | $this->createQueryBuilder($entryAlias) | ||
164 | ->select($entryAlias . '.id') | ||
165 | ->leftJoin($entryAlias . '.tags', $tagAlias) | ||
166 | ->where($tagAlias . '.label = :label' . $i) | ||
167 | ->getDQL() | ||
168 | )); | ||
169 | |||
170 | // bound parameter to the main query builder | ||
171 | $qb->setParameter('label' . $i, $tag); | ||
157 | } | 172 | } |
158 | } | 173 | } |
159 | 174 | ||
@@ -181,7 +196,7 @@ class EntryRepository extends EntityRepository | |||
181 | ->innerJoin('e.tags', 't') | 196 | ->innerJoin('e.tags', 't') |
182 | ->innerJoin('e.user', 'u') | 197 | ->innerJoin('e.user', 'u') |
183 | ->addSelect('t', 'u') | 198 | ->addSelect('t', 'u') |
184 | ->where('e.user=:userId')->setParameter('userId', $userId) | 199 | ->where('e.user = :userId')->setParameter('userId', $userId) |
185 | ; | 200 | ; |
186 | 201 | ||
187 | return $qb->getQuery()->getResult(); | 202 | return $qb->getQuery()->getResult(); |
@@ -323,7 +338,7 @@ class EntryRepository extends EntityRepository | |||
323 | { | 338 | { |
324 | $qb = $this->createQueryBuilder('e') | 339 | $qb = $this->createQueryBuilder('e') |
325 | ->select('count(e)') | 340 | ->select('count(e)') |
326 | ->where('e.user=:userId')->setParameter('userId', $userId) | 341 | ->where('e.user = :userId')->setParameter('userId', $userId) |
327 | ; | 342 | ; |
328 | 343 | ||
329 | return (int) $qb->getQuery()->getSingleScalarResult(); | 344 | return (int) $qb->getQuery()->getSingleScalarResult(); |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 5e1f692e..455d47d1 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml | |||
@@ -392,7 +392,7 @@ tag: | |||
392 | page_title: 'Etiquetas' | 392 | page_title: 'Etiquetas' |
393 | list: | 393 | list: |
394 | number_on_the_page: "{0} I a pas cap d'etiquetas.|{1} I a una etiqueta.|]1,Inf[ I a %count% etiquetas." | 394 | number_on_the_page: "{0} I a pas cap d'etiquetas.|{1} I a una etiqueta.|]1,Inf[ I a %count% etiquetas." |
395 | see_untagged_entries: "Afichar las entradas sens pas cap d'etiquetas" | 395 | see_untagged_entries: "Afichar las entradas sens etiquetas" |
396 | new: | 396 | new: |
397 | add: 'Ajustar' | 397 | add: 'Ajustar' |
398 | placeholder: "Podètz ajustar mai qu'una etiqueta, separadas per de virgula." | 398 | placeholder: "Podètz ajustar mai qu'una etiqueta, separadas per de virgula." |
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index f4c8a630..fcec3f3b 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -292,6 +292,9 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
292 | $this->assertSame(1, $content['page']); | 292 | $this->assertSame(1, $content['page']); |
293 | $this->assertGreaterThanOrEqual(1, $content['pages']); | 293 | $this->assertGreaterThanOrEqual(1, $content['pages']); |
294 | 294 | ||
295 | $this->assertContains('foo', array_column($content['_embedded']['items'][0]['tags'], 'label'), 'Entries tags should have "foo" tag'); | ||
296 | $this->assertContains('bar', array_column($content['_embedded']['items'][0]['tags'], 'label'), 'Entries tags should have "bar" tag'); | ||
297 | |||
295 | $this->assertArrayHasKey('_links', $content); | 298 | $this->assertArrayHasKey('_links', $content); |
296 | $this->assertArrayHasKey('self', $content['_links']); | 299 | $this->assertArrayHasKey('self', $content['_links']); |
297 | $this->assertArrayHasKey('first', $content['_links']); | 300 | $this->assertArrayHasKey('first', $content['_links']); |
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php index 3e216381..ab7f23cc 100644 --- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | |||
@@ -239,7 +239,8 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
239 | $this->assertSame($contentInDB->getLanguage(), $content[0]['language']); | 239 | $this->assertSame($contentInDB->getLanguage(), $content[0]['language']); |
240 | $this->assertSame($contentInDB->getReadingtime(), $content[0]['reading_time']); | 240 | $this->assertSame($contentInDB->getReadingtime(), $content[0]['reading_time']); |
241 | $this->assertSame($contentInDB->getDomainname(), $content[0]['domain_name']); | 241 | $this->assertSame($contentInDB->getDomainname(), $content[0]['domain_name']); |
242 | $this->assertSame(['foo bar', 'baz'], $content[0]['tags']); | 242 | $this->assertContains('baz', $content[0]['tags']); |
243 | $this->assertContains('foo', $content[0]['tags']); | ||
243 | } | 244 | } |
244 | 245 | ||
245 | public function testXmlExport() | 246 | public function testXmlExport() |
diff --git a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php index 6167fe2d..c6ca4937 100644 --- a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php | |||
@@ -184,13 +184,13 @@ class RssControllerTest extends WallabagCoreTestCase | |||
184 | $em->flush(); | 184 | $em->flush(); |
185 | 185 | ||
186 | $client = $this->getClient(); | 186 | $client = $this->getClient(); |
187 | $client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml'); | 187 | $client->request('GET', '/admin/SUPERTOKEN/tags/foo.xml'); |
188 | 188 | ||
189 | $this->assertSame(200, $client->getResponse()->getStatusCode()); | 189 | $this->assertSame(200, $client->getResponse()->getStatusCode()); |
190 | 190 | ||
191 | $this->validateDom($client->getResponse()->getContent(), 'tag (foo bar)', 'tags/foo-bar'); | 191 | $this->validateDom($client->getResponse()->getContent(), 'tag (foo)', 'tags/foo'); |
192 | 192 | ||
193 | $client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml?page=3000'); | 193 | $client->request('GET', '/admin/SUPERTOKEN/tags/foo.xml?page=3000'); |
194 | $this->assertSame(302, $client->getResponse()->getStatusCode()); | 194 | $this->assertSame(302, $client->getResponse()->getStatusCode()); |
195 | } | 195 | } |
196 | } | 196 | } |