From db96045a0ae96cfe67bc98d49596fde31c9124fc Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 20 Sep 2015 22:36:51 +0200 Subject: Adjust preview picture --- .../views/themes/material/Entry/entries.html.twig | 16 ++++++++++++++-- .../Resources/views/themes/material/public/css/main.css | 5 +++++ 2 files changed, 19 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 77483a09..c2157db5 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 @@ -98,13 +98,25 @@

{% trans %}Filters{% endtrans %}

+
+ +
+ +
+ {{ form_widget(form.isArchived) }} + +
+
+ {{ form_widget(form.isStarred) }} + +
- +
-
+
{{ form_widget(form.previewPicture) }}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css index 144e259f..7a4e7df2 100755 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/main.css @@ -209,6 +209,11 @@ nav input { overflow-y: visible; } +#filters div.with-checkbox { + height: 3rem; + margin-top: 0px; +} + /* ========================================================================== 4 = Cards ========================================================================== */ -- cgit v1.2.3 From 98f0929f168a336079456f65b6ca41e84b22efff Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 20 Sep 2015 22:37:27 +0200 Subject: Handle entry in language Fix #1333 --- src/Wallabag/CoreBundle/Entity/Entry.php | 31 ++++++++++++++++++++++ src/Wallabag/CoreBundle/Entity/User.php | 5 ++-- src/Wallabag/CoreBundle/Helper/ContentProxy.php | 1 + .../CoreBundle/Tests/Helper/ContentProxyTest.php | 24 +++++++++++++++-- 4 files changed, 56 insertions(+), 5 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index e684c9b1..7108889e 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -94,6 +94,13 @@ class Entry */ private $mimetype; + /** + * @var string + * + * @ORM\Column(name="language", type="text", nullable=true) + */ + private $language; + /** * @var int * @@ -450,4 +457,28 @@ class Entry { return $this->previewPicture; } + + /** + * Set language. + * + * @param string $language + * + * @return Entry + */ + public function setLanguage($language) + { + $this->language = $language; + + return $this; + } + + /** + * Get language. + * + * @return string + */ + public function getLanguage() + { + return $this->language; + } } diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php index eeae331e..a6002352 100644 --- a/src/Wallabag/CoreBundle/Entity/User.php +++ b/src/Wallabag/CoreBundle/Entity/User.php @@ -7,7 +7,6 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\AdvancedUserInterface; -use Symfony\Component\Validator\Constraints as Assert; use JMS\Serializer\Annotation\ExclusionPolicy; use JMS\Serializer\Annotation\Expose; use FOS\UserBundle\Model\User as BaseUser; @@ -74,8 +73,8 @@ class User extends BaseUser implements AdvancedUserInterface, \Serializable public function __construct() { parent::__construct(); - $this->entries = new ArrayCollection(); - $this->tags = new ArrayCollection(); + $this->entries = new ArrayCollection(); + $this->tags = new ArrayCollection(); } /** diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index 4565d8e7..3de8828f 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php @@ -49,6 +49,7 @@ class ContentProxy $entry->setUrl($content['url'] ?: $url); $entry->setTitle($title); $entry->setContent($html); + $entry->setLanguage($content['language']); $entry->setMimetype($content['content_type']); if (isset($content['open_graph']['og_image'])) { diff --git a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php index 71a004ff..30065d6b 100644 --- a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php +++ b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php @@ -18,7 +18,13 @@ class ContentProxyTest extends KernelTestCase $graby->expects($this->any()) ->method('fetchContent') - ->willReturn(array('html' => false, 'title' => '', 'url' => '', 'content_type' => '')); + ->willReturn(array( + 'html' => false, + 'title' => '', + 'url' => '', + 'content_type' => '', + 'language' => '', + )); $proxy = new ContentProxy($graby); $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); @@ -28,6 +34,7 @@ class ContentProxyTest extends KernelTestCase $this->assertEquals('

Unable to retrieve readable content.

', $entry->getContent()); $this->assertEmpty($entry->getPreviewPicture()); $this->assertEmpty($entry->getMimetype()); + $this->assertEmpty($entry->getLanguage()); } public function testWithEmptyContentButOG() @@ -39,7 +46,17 @@ class ContentProxyTest extends KernelTestCase $graby->expects($this->any()) ->method('fetchContent') - ->willReturn(array('html' => false, 'title' => '', 'url' => '', 'content_type' => '', 'open_graph' => array('og_title' => 'my title', 'og_description' => 'desc'))); + ->willReturn(array( + 'html' => false, + 'title' => '', + 'url' => '', + 'content_type' => '', + 'language' => '', + 'open_graph' => array( + 'og_title' => 'my title', + 'og_description' => 'desc', + ), + )); $proxy = new ContentProxy($graby); $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); @@ -48,6 +65,7 @@ class ContentProxyTest extends KernelTestCase $this->assertEquals('my title', $entry->getTitle()); $this->assertEquals('

Unable to retrieve readable content.

But we found a short description:

desc', $entry->getContent()); $this->assertEmpty($entry->getPreviewPicture()); + $this->assertEmpty($entry->getLanguage()); $this->assertEmpty($entry->getMimetype()); } @@ -65,6 +83,7 @@ class ContentProxyTest extends KernelTestCase 'title' => 'this is my title', 'url' => 'http://1.1.1.1', 'content_type' => 'text/html', + 'language' => 'fr', 'open_graph' => array( 'og_title' => 'my OG title', 'og_description' => 'OG desc', @@ -80,5 +99,6 @@ class ContentProxyTest extends KernelTestCase $this->assertEquals('this is my content', $entry->getContent()); $this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture()); $this->assertEquals('text/html', $entry->getMimetype()); + $this->assertEquals('fr', $entry->getLanguage()); } } -- cgit v1.2.3 From 0d3bafdfdfe4fa1e4aa62f6056d8028ebd7d920d Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 23 Sep 2015 07:51:17 +0200 Subject: Remove tab from baggy css And add a border left on the filter slider --- .../views/themes/baggy/public/css/main.css | 102 ++++++++++----------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/css/main.css b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/css/main.css index 950d8b0e..4aeadb4f 100755 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/css/main.css +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/css/main.css @@ -356,9 +356,9 @@ footer a { overflow: hidden; padding: 1.5em 1.5em 3em 1.5em; - /* Removing CSS transitions because they make the switch from list view to - * table view jerky - */ + /* Removing CSS transitions because they make the switch from list view to + * table view jerky + */ /* -webkit-transition: all 0.5s ease; */ /* -moz-transition: all 0.5s ease; */ /* -ms-transition: all 0.5s ease; */ @@ -570,47 +570,47 @@ img.preview { border-left: 1px #EEE solid; } - .popup-form form { - background-color: #FFF; - position: absolute; - top: 0; - left: 0; - z-index: 20; - border: 10px solid #000; - width: 400px; - height: 200px; - padding: 2em; - } + .popup-form form { + background-color: #FFF; + position: absolute; + top: 0; + left: 0; + z-index: 20; + border: 10px solid #000; + width: 400px; + height: 200px; + padding: 2em; + } #bagit-form-form .addurl { - margin-left: 0; + margin-left: 0; } .closeMessage, .close-button { background-color: #000; color: #FFF; - font-size: 1.2em; - line-height: 1.6; - width: 1.6em; - height: 1.6em; - text-align: center; + font-size: 1.2em; + line-height: 1.6; + width: 1.6em; + height: 1.6em; + text-align: center; text-decoration: none; } - .closeMessage:hover, - .closeMessage:focus, - .close-button:hover, - .close-button:focus { - background-color: #999; - color: #000; - } + .closeMessage:hover, + .closeMessage:focus, + .close-button:hover, + .close-button:focus { + background-color: #999; + color: #000; + } .close-button--popup { - display: inline-block; - position: absolute; - top: 0; - right: 0; - font-size: 1.4em; + display: inline-block; + position: absolute; + top: 0; + right: 0; + font-size: 1.4em; } .active-current { @@ -753,24 +753,24 @@ a.add-to-wallabag-link-after:after { /* .icon-image class, for image-based icons - ========================================================================== */ + ========================================================================== */ .icon-image { - background-size: 16px 16px; - background-repeat: no-repeat; - background-position: center; - padding-right: 1em !important; - padding-left: 1em !important; + background-size: 16px 16px; + background-repeat: no-repeat; + background-position: center; + padding-right: 1em !important; + padding-left: 1em !important; } /* Carrot (http://carrot.org) */ .icon-image--carrot { - background-image: url('../../_global/img/icons/carrot-icon--white.png'); + background-image: url('../../_global/img/icons/carrot-icon--white.png'); } /* Diaspora */ .icon-image--diaspora { - background-image: url('../../_global/img/icons/diaspora-icon--black.png'); + background-image: url('../../_global/img/icons/diaspora-icon--black.png'); }} /* ========================================================================== @@ -813,14 +813,14 @@ a.add-to-wallabag-link-after:after { } .more-info { - font-size: 0.85em; + font-size: 0.85em; line-height: 1.5; - color: #aaa; + color: #aaa; } - .more-info a { - color: #aaa; - } + .more-info a { + color: #aaa; + } /* ========================================================================== 5 = Article @@ -934,9 +934,9 @@ blockquote { } pre code { - font-family: "Courier New", Courier, monospace; - border: 1px solid #ccc; - font-size: 0.96em; + font-family: "Courier New", Courier, monospace; + border: 1px solid #ccc; + font-size: 0.96em; } #filter-form { @@ -949,18 +949,18 @@ pre code { padding: 15px; padding-right: 30px; padding-top: 30px; - + border-left: 1px #333 solid; z-index: 12; /*transition-property: transform; transition-duration: 0.3s; transition-delay: 0.3s; - + transform: translate3d(100%, 0, 0);*/ } #filter-form form { - + } #filter-form form .filter-group { -- cgit v1.2.3 From d4ebe5c5dcf581416ab76136908cafbde78f63bf Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 23 Sep 2015 07:55:55 +0200 Subject: Entries filter on language + updated deps --- .../CoreBundle/Controller/EntryController.php | 2 +- .../CoreBundle/DataFixtures/ORM/LoadEntryData.php | 6 +++++ src/Wallabag/CoreBundle/Filter/EntryFilterType.php | 23 +++++++++++++++++- .../CoreBundle/Repository/EntryRepository.php | 27 ++++++++++++++++++++++ .../views/themes/baggy/Entry/entries.html.twig | 8 +++++++ .../views/themes/material/Entry/entries.html.twig | 10 ++++---- .../Tests/Controller/EntryControllerTest.php | 23 ++++++++++++++++++ 7 files changed, 91 insertions(+), 8 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index b9e4e67e..a9f35c36 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -192,7 +192,7 @@ class EntryController extends Controller throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); } - $form = $this->get('form.factory')->create(new EntryFilterType()); + $form = $this->get('form.factory')->create(new EntryFilterType($repository, $this->getUser())); if ($request->query->has($form->getName())) { // manually bind values from the request diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php index 6cd24d44..dd316194 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php @@ -19,6 +19,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface $entry1->setUrl('http://0.0.0.0'); $entry1->setTitle('test title entry1'); $entry1->setContent('This is my content /o/'); + $entry1->setLanguage('en'); $manager->persist($entry1); @@ -28,6 +29,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface $entry2->setUrl('http://0.0.0.0'); $entry2->setTitle('test title entry2'); $entry2->setContent('This is my content /o/'); + $entry2->setLanguage('fr'); $manager->persist($entry2); @@ -37,6 +39,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface $entry3->setUrl('http://0.0.0.0'); $entry3->setTitle('test title entry3'); $entry3->setContent('This is my content /o/'); + $entry3->setLanguage('en'); $tag1 = new Tag($this->getReference('bob-user')); $tag1->setLabel('foo'); @@ -54,6 +57,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface $entry4->setUrl('http://0.0.0.0'); $entry4->setTitle('test title entry4'); $entry4->setContent('This is my content /o/'); + $entry4->setLanguage('en'); $tag1 = new Tag($this->getReference('admin-user')); $tag1->setLabel('foo'); @@ -72,6 +76,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface $entry5->setTitle('test title entry5'); $entry5->setContent('This is my content /o/'); $entry5->setStarred(true); + $entry5->setLanguage('fr'); $manager->persist($entry5); @@ -82,6 +87,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface $entry6->setTitle('test title entry6'); $entry6->setContent('This is my content /o/'); $entry6->setArchived(true); + $entry6->setLanguage('de'); $manager->persist($entry6); diff --git a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php index 024486e6..f40c1c2d 100644 --- a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php @@ -6,9 +6,26 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface; +use Doctrine\ORM\EntityRepository; +use Wallabag\CoreBundle\Entity\User; class EntryFilterType extends AbstractType { + private $user; + private $repository; + + /** + * Repository & user are used to get a list of language entries for this user + * + * @param EntityRepository $entryRepository + * @param User $user + */ + public function __construct(EntityRepository $entryRepository, User $user) + { + $this->repository = $entryRepository; + $this->user = $user; + } + public function buildForm(FormBuilderInterface $builder, array $options) { $builder @@ -53,7 +70,11 @@ class EntryFilterType extends AbstractType return $filterQuery->createCondition($expression); }, - )); + )) + ->add('language', 'filter_choice', array( + 'choices' => $this->repository->findDistinctLanguageByUser($this->user->getId()), + )) + ; } public function getName() diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index e764e8f7..87b9befe 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -134,4 +134,31 @@ class EntryRepository extends EntityRepository return $qb->getQuery()->getResult(); } + + /** + * Find distinct language for a given user. + * Used to build the filter language list. + * + * @param int $userId User id + * + * @return array + */ + public function findDistinctLanguageByUser($userId) + { + $results = $this->createQueryBuilder('e') + ->select('e.language') + ->where('e.user = :userId')->setParameter('userId', $userId) + ->andWhere('e.language IS NOT NULL') + ->groupBy('e.language') + ->orderBy('e.language', ' ASC') + ->getQuery() + ->getResult(); + + $languages = array(); + foreach ($results as $result) { + $languages[$result['language']] = $result['language']; + } + + return $languages; + } } 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 176290e4..08f3fe60 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 @@ -71,6 +71,14 @@
+ +
+ +
+ {{ form_widget(form.language) }} +
+
+
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 c2157db5..dcdf7c09 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 @@ -121,14 +121,12 @@
-
- {{ form_widget(form.isArchived) }} - +
+
-
- {{ form_widget(form.isStarred) }} - +
+ {{ form_widget(form.language) }}
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 77b57884..cbd84a97 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -382,4 +382,27 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->submit($form); $this->assertCount(1, $crawler->filter('div[class=entry]')); } + + public function testFilterOnLanguage() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/unread/list'); + $form = $crawler->filter('button[id=submit-filter]')->form(); + $data = array( + 'entry_filter[language]' => 'de', + ); + + $crawler = $client->submit($form, $data); + $this->assertCount(1, $crawler->filter('div[class=entry]')); + + $form = $crawler->filter('button[id=submit-filter]')->form(); + $data = array( + 'entry_filter[language]' => 'en', + ); + + $crawler = $client->submit($form, $data); + $this->assertCount(2, $crawler->filter('div[class=entry]')); + } } -- cgit v1.2.3