From: Nicolas Lœuillet Date: Sun, 23 Aug 2015 11:17:21 +0000 (+0200) Subject: Merge pull request #1384 from wallabag/v2-fix-config-display X-Git-Tag: 2.0.0-alpha.0~12 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=bccb5bba75e3f2bf8e89fef6b939500757c3d2b1;hp=83aaf84195bc7c43a548289761827c76c3ab77ab;p=github%2Fwallabag%2Fwallabag.git Merge pull request #1384 from wallabag/v2-fix-config-display fix #1371 config screen: display bug in RSS tab --- diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 08f4a3e9..8fbd8265 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -21,3 +21,7 @@ tools: php_code_coverage: true php_sim: false php_cpd: false + +checks: + php: + code_rating: true diff --git a/app/config/config.yml b/app/config/config.yml index 5b26b06f..efc815b8 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -51,6 +51,7 @@ twig: form: resources: - LexikFormFilterBundle:Form:form_div_layout.html.twig + # Assetic Configuration assetic: debug: "%kernel.debug%" diff --git a/composer.json b/composer.json index 709b23ac..2c5111fd 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ }, { "name": "Jérémy Benoist", + "homepage": "http://www.j0k3r.net", "role": "Developer" } ], diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php index 86c8de1e..7ae54b57 100644 --- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php @@ -170,6 +170,31 @@ class WallabagRestControllerTest extends WebTestCase $client = $this->createClient(); $headers = $this->generateHeaders('admin', 'mypassword'); + $client->request('GET', '/api/entries', array('star' => 1, 'sort' => 'updated'), array(), $headers); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + $content = json_decode($client->getResponse()->getContent(), true); + + $this->assertGreaterThanOrEqual(1, count($content)); + $this->assertNotEmpty($content['_embedded']['items']); + $this->assertGreaterThanOrEqual(1, $content['total']); + $this->assertEquals(1, $content['page']); + $this->assertGreaterThanOrEqual(1, $content['pages']); + + $this->assertTrue( + $client->getResponse()->headers->contains( + 'Content-Type', + 'application/json' + ) + ); + } + + public function testGetArchiveEntries() + { + $client = $this->createClient(); + $headers = $this->generateHeaders('admin', 'mypassword'); + $client->request('GET', '/api/entries', array('archive' => 1), array(), $headers); $this->assertEquals(200, $client->getResponse()->getStatusCode()); diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 006fa396..b73e9eec 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -101,6 +101,21 @@ class EntryController extends Controller )); } + /** + * Shows all entries for current user. + * + * @param Request $request + * @param int $page + * + * @Route("/all/list/{page}", name="all", defaults={"page" = "1"}) + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function showAllAction(Request $request, $page) + { + return $this->showEntries('all', $request, $page); + } + /** * Shows unread entries for current user. * @@ -113,34 +128,7 @@ class EntryController extends Controller */ public function showUnreadAction(Request $request, $page) { - $form = $this->get('form.factory')->create(new EntryFilterType()); - - $filterBuilder = $this->getDoctrine() - ->getRepository('WallabagCoreBundle:Entry') - ->findUnreadByUser($this->getUser()->getId()); - - if ($request->query->has($form->getName())) { - // manually bind values from the request - $form->submit($request->query->get($form->getName())); - - // build the query from the given form object - $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder); - } - - $pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery()); - $entries = new Pagerfanta($pagerAdapter); - - $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); - $entries->setCurrentPage($page); - - return $this->render( - 'WallabagCoreBundle:Entry:entries.html.twig', - array( - 'form' => $form->createView(), - 'entries' => $entries, - 'currentPage' => $page, - ) - ); + return $this->showEntries('unread', $request, $page); } /** @@ -155,34 +143,7 @@ class EntryController extends Controller */ public function showArchiveAction(Request $request, $page) { - $form = $this->get('form.factory')->create(new EntryFilterType()); - - $filterBuilder = $this->getDoctrine() - ->getRepository('WallabagCoreBundle:Entry') - ->findArchiveByUser($this->getUser()->getId()); - - if ($request->query->has($form->getName())) { - // manually bind values from the request - $form->submit($request->query->get($form->getName())); - - // build the query from the given form object - $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder); - } - - $pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery()); - $entries = new Pagerfanta($pagerAdapter); - - $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); - $entries->setCurrentPage($page); - - return $this->render( - 'WallabagCoreBundle:Entry:entries.html.twig', - array( - 'form' => $form->createView(), - 'entries' => $entries, - 'currentPage' => $page, - ) - ); + return $this->showEntries('archive', $request, $page); } /** @@ -197,21 +158,55 @@ class EntryController extends Controller */ public function showStarredAction(Request $request, $page) { - $form = $this->get('form.factory')->create(new EntryFilterType()); + return $this->showEntries('starred', $request, $page); + } + + /** + * Global method to retrieve entries depending on the given type + * It returns the response to be send. + * + * @param string $type Entries type: unread, starred or archive + * @param Request $request + * @param int $page + * + * @return \Symfony\Component\HttpFoundation\Response + */ + private function showEntries($type, Request $request, $page) + { + $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry'); + + switch ($type) { + case 'starred': + $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId()); + break; + + case 'archive': + $qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId()); + break; + + case 'unread': + $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId()); + break; - $filterBuilder = $this->getDoctrine() - ->getRepository('WallabagCoreBundle:Entry') - ->findStarredByUser($this->getUser()->getId()); + case 'all': + $qb = $repository->getBuilderForAllByUser($this->getUser()->getId()); + break; + + default: + throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); + } + + $form = $this->get('form.factory')->create(new EntryFilterType()); if ($request->query->has($form->getName())) { // manually bind values from the request $form->submit($request->query->get($form->getName())); // build the query from the given form object - $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder); + $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb); } - $pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery()); + $pagerAdapter = new DoctrineORMAdapter($qb->getQuery()); $entries = new Pagerfanta($pagerAdapter); $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); diff --git a/src/Wallabag/CoreBundle/Controller/RssController.php b/src/Wallabag/CoreBundle/Controller/RssController.php index 0558c53b..6121f361 100644 --- a/src/Wallabag/CoreBundle/Controller/RssController.php +++ b/src/Wallabag/CoreBundle/Controller/RssController.php @@ -22,22 +22,7 @@ class RssController extends Controller */ public function showUnreadAction(User $user) { - $qb = $this->getDoctrine() - ->getRepository('WallabagCoreBundle:Entry') - ->findUnreadByUser( - $user->getId() - ); - - $pagerAdapter = new DoctrineORMAdapter($qb->getQuery()); - $entries = new Pagerfanta($pagerAdapter); - - $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit'); - $entries->setMaxPerPage($perPage); - - return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array( - 'type' => 'unread', - 'entries' => $entries, - )); + return $this->showEntries('unread', $user); } /** @@ -50,22 +35,7 @@ class RssController extends Controller */ public function showArchiveAction(User $user) { - $qb = $this->getDoctrine() - ->getRepository('WallabagCoreBundle:Entry') - ->findArchiveByUser( - $user->getId() - ); - - $pagerAdapter = new DoctrineORMAdapter($qb->getQuery()); - $entries = new Pagerfanta($pagerAdapter); - - $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit'); - $entries->setMaxPerPage($perPage); - - return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array( - 'type' => 'archive', - 'entries' => $entries, - )); + return $this->showEntries('archive', $user); } /** @@ -78,11 +48,38 @@ class RssController extends Controller */ public function showStarredAction(User $user) { - $qb = $this->getDoctrine() - ->getRepository('WallabagCoreBundle:Entry') - ->findStarredByUser( - $user->getId() - ); + return $this->showEntries('starred', $user); + } + + /** + * Global method to retrieve entries depending on the given type + * It returns the response to be send. + * + * @param string $type Entries type: unread, starred or archive + * @param User $user + * + * @return \Symfony\Component\HttpFoundation\Response + */ + private function showEntries($type, User $user) + { + $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry'); + + switch ($type) { + case 'starred': + $qb = $repository->getBuilderForStarredByUser($user->getId()); + break; + + case 'archive': + $qb = $repository->getBuilderForArchiveByUser($user->getId()); + break; + + case 'unread': + $qb = $repository->getBuilderForUnreadByUser($user->getId()); + break; + + default: + throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); + } $pagerAdapter = new DoctrineORMAdapter($qb->getQuery()); $entries = new Pagerfanta($pagerAdapter); @@ -91,7 +88,7 @@ class RssController extends Controller $entries->setMaxPerPage($perPage); return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array( - 'type' => 'starred', + 'type' => $type, 'entries' => $entries, )); } diff --git a/src/Wallabag/CoreBundle/Controller/StaticController.php b/src/Wallabag/CoreBundle/Controller/StaticController.php index 3b844b44..64875a66 100644 --- a/src/Wallabag/CoreBundle/Controller/StaticController.php +++ b/src/Wallabag/CoreBundle/Controller/StaticController.php @@ -28,12 +28,4 @@ class StaticController extends Controller array() ); } - - /** - * @Route("/", name="homepage") - */ - public function apiAction() - { - return $this->redirect($this->generateUrl('nelmio_api_doc_index')); - } } diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index a342ec0b..fd2069e0 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -4,9 +4,59 @@ namespace Wallabag\CoreBundle\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\HttpFoundation\Request; +use Wallabag\CoreBundle\Form\Type\NewTagType; +use Wallabag\CoreBundle\Entity\Tag; +use Wallabag\CoreBundle\Entity\Entry; class TagController extends Controller { + /** + * @param Request $request + * + * @Route("/new-tag/{entry}", requirements={"entry" = "\d+"}, name="new_tag") + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function addTagFormAction(Request $request, Entry $entry) + { + $tag = new Tag($this->getUser()); + $form = $this->createForm(new NewTagType(), $tag); + $form->handleRequest($request); + + if ($form->isValid()) { + $existingTag = $this->getDoctrine() + ->getRepository('WallabagCoreBundle:Tag') + ->findOneByLabelAndUserId($tag->getLabel(), $this->getUser()->getId()); + + $em = $this->getDoctrine()->getManager(); + + if (is_null($existingTag)) { + $entry->addTag($tag); + $em->persist($tag); + } else { + if (!$existingTag->hasEntry($entry)) { + $entry->addTag($existingTag); + $em->persist($existingTag); + } + } + + $em->flush(); + + $this->get('session')->getFlashBag()->add( + 'notice', + 'Tag added' + ); + + return $this->redirect($this->generateUrl('view', array('id' => $entry->getId()))); + } + + return $this->render('WallabagCoreBundle:Tag:new_form.html.twig', array( + 'form' => $form->createView(), + 'entry' => $entry, + )); + } + /** * Shows tags for current user. * diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 7d2d2027..f88d189d 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -7,7 +7,7 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; use Hateoas\Configuration\Annotation as Hateoas; use JMS\Serializer\Annotation\XmlRoot; -use Wallabag\CoreBundle\Helper\Tools; +use Wallabag\CoreBundle\Tools\Utils; /** * Entry. @@ -265,7 +265,7 @@ class Entry public function setContent($content) { $this->content = $content; - $this->readingTime = Tools::getReadingTime($content); + $this->readingTime = Utils::getReadingTime($content); $this->domainName = parse_url($this->url, PHP_URL_HOST); return $this; diff --git a/src/Wallabag/CoreBundle/Entity/Tag.php b/src/Wallabag/CoreBundle/Entity/Tag.php index 6f005314..97c4579f 100644 --- a/src/Wallabag/CoreBundle/Entity/Tag.php +++ b/src/Wallabag/CoreBundle/Entity/Tag.php @@ -96,6 +96,11 @@ class Tag $this->entries[] = $entry; } + public function hasEntry($entry) + { + return $this->entries->contains($entry); + } + /** * @return User */ diff --git a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php index 771daef1..ff51785b 100644 --- a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php @@ -39,7 +39,9 @@ class EntryFilterType extends AbstractType return $filterQuery->createCondition($expression); }, - )); + )) + ->add('isArchived', 'filter_checkbox') + ->add('isStarred', 'filter_checkbox'); } public function getName() diff --git a/src/Wallabag/CoreBundle/Form/Type/NewTagType.php b/src/Wallabag/CoreBundle/Form/Type/NewTagType.php new file mode 100644 index 00000000..8e4ab649 --- /dev/null +++ b/src/Wallabag/CoreBundle/Form/Type/NewTagType.php @@ -0,0 +1,30 @@ +add('label', 'text', array('required' => true)) + ->add('save', 'submit') + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'Wallabag\CoreBundle\Entity\Tag', + )); + } + + public function getName() + { + return 'tag'; + } +} diff --git a/src/Wallabag/CoreBundle/Helper/Entry.php b/src/Wallabag/CoreBundle/Helper/Entry.php deleted file mode 100644 index 219711b3..00000000 --- a/src/Wallabag/CoreBundle/Helper/Entry.php +++ /dev/null @@ -1,7 +0,0 @@ - array( - 'timeout' => $timeout, - 'header' => 'User-Agent: '.$useragent, - 'follow_location' => true, - ), - 'ssl' => array( - 'verify_peer' => false, - 'allow_self_signed' => true, - ), - ) - ); - - # only download page lesser than 4MB - $data = @file_get_contents($url, false, $context, -1, 4000000); - - if (isset($http_response_header) and isset($http_response_header[0])) { - $httpcodeOK = isset($http_response_header) and isset($http_response_header[0]) and ((strpos($http_response_header[0], '200 OK') !== false) or (strpos($http_response_header[0], '301 Moved Permanently') !== false)); - } - } - - # if response is not empty and response is OK - if (isset($data) and isset($httpcodeOK) and $httpcodeOK) { - # take charset of page and get it - preg_match('##Usi', $data, $meta); - - # if meta tag is found - if (!empty($meta[0])) { - preg_match('#charset="?(.*)"#si', $meta[0], $encoding); - # if charset is found set it otherwise, set it to utf-8 - $html_charset = (!empty($encoding[1])) ? strtolower($encoding[1]) : 'utf-8'; - if (empty($encoding[1])) { - $encoding[1] = 'utf-8'; - } - } else { - $html_charset = 'utf-8'; - $encoding[1] = ''; - } - - # replace charset of url to charset of page - $data = str_replace('charset='.$encoding[1], 'charset='.$html_charset, $data); - - return $data; - } else { - return false; - } - } - - /** - * Encode a URL by using a salt. - * - * @param $string - * - * @return string - */ - public static function encodeString($string) - { - return sha1($string.SALT); - } - - public static function generateToken() - { - if (ini_get('open_basedir') === '') { - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - // alternative to /dev/urandom for Windows - $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); - } else { - $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15); - } - } else { - $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20); - } - - return str_replace('+', '', $token); - } - - /** - * For a given text, we calculate reading time for an article. - * - * @param $text - * - * @return float - */ - public static function getReadingTime($text) - { - return floor(str_word_count(strip_tags($text)) / 200); - } -} diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index f885ee94..e764e8f7 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -9,19 +9,48 @@ use Pagerfanta\Pagerfanta; class EntryRepository extends EntityRepository { /** - * Retrieves unread entries for a user. + * Return a query builder to used by other getBuilderFor* method. * * @param int $userId * * @return QueryBuilder */ - public function findUnreadByUser($userId) + private function getBuilderByUser($userId) { return $this->createQueryBuilder('e') ->leftJoin('e.user', 'u') - ->where('e.isArchived = false') - ->andWhere('u.id =:userId')->setParameter('userId', $userId) - ->orderBy('e.id', 'desc'); + ->andWhere('u.id = :userId')->setParameter('userId', $userId) + ->orderBy('e.id', 'desc') + ; + } + + /** + * Retrieves all entries for a user. + * + * @param int $userId + * + * @return QueryBuilder + */ + public function getBuilderForAllByUser($userId) + { + return $this + ->getBuilderByUser($userId) + ; + } + + /** + * Retrieves unread entries for a user. + * + * @param int $userId + * + * @return QueryBuilder + */ + public function getBuilderForUnreadByUser($userId) + { + return $this + ->getBuilderByUser($userId) + ->andWhere('e.isArchived = false') + ; } /** @@ -31,13 +60,12 @@ class EntryRepository extends EntityRepository * * @return QueryBuilder */ - public function findArchiveByUser($userId) + public function getBuilderForArchiveByUser($userId) { - return $this->createQueryBuilder('e') - ->leftJoin('e.user', 'u') - ->where('e.isArchived = true') - ->andWhere('u.id =:userId')->setParameter('userId', $userId) - ->orderBy('e.id', 'desc'); + return $this + ->getBuilderByUser($userId) + ->andWhere('e.isArchived = true') + ; } /** @@ -47,13 +75,12 @@ class EntryRepository extends EntityRepository * * @return QueryBuilder */ - public function findStarredByUser($userId) + public function getBuilderForStarredByUser($userId) { - return $this->createQueryBuilder('e') - ->leftJoin('e.user', 'u') - ->where('e.isStarred = true') - ->andWhere('u.id =:userId')->setParameter('userId', $userId) - ->orderBy('e.id', 'desc'); + return $this + ->getBuilderByUser($userId) + ->andWhere('e.isStarred = true') + ; } /** diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index 9c409607..ac3145a1 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php @@ -24,4 +24,21 @@ class TagRepository extends EntityRepository return new Pagerfanta($pagerAdapter); } + + /** + * Find a tag by its label and its owner. + * + * @param string $label + * @param int $userId + * + * @return Tag|null + */ + public function findOneByLabelAndUserId($label, $userId) + { + return $this->createQueryBuilder('t') + ->where('t.label = :label')->setParameter('label', $label) + ->andWhere('t.user = :user_id')->setParameter('user_id', $userId) + ->getQuery() + ->getOneOrNullResult(); + } } diff --git a/src/Wallabag/CoreBundle/Resources/config/routing.yml b/src/Wallabag/CoreBundle/Resources/config/routing.yml index f3502e15..e69de29b 100644 --- a/src/Wallabag/CoreBundle/Resources/config/routing.yml +++ b/src/Wallabag/CoreBundle/Resources/config/routing.yml @@ -1,7 +0,0 @@ -entry: - resource: "@WallabagCoreBundle/Controller/EntryController.php" - type: annotation - -config: - resource: "@WallabagCoreBundle/Controller/ConfigController.php" - type: annotation diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig index a794df0e..118a2f4b 100644 --- a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig @@ -21,7 +21,7 @@ {% if entries is empty %}

{% trans %}No articles found.{% endtrans %}

{% else %} -
{{ form_rest(form) }}
+
{{ form_rest(form) }}
{% for entry in entries %}

{{ entry.title|raw }}

diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig index 00480d1a..18cfd59d 100644 --- a/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig @@ -28,7 +28,8 @@

{{ entry.title|raw }} ✎

{{ entry.content | raw }} diff --git a/src/Wallabag/CoreBundle/Resources/views/Static/about.html.twig b/src/Wallabag/CoreBundle/Resources/views/Static/about.html.twig index 9e188cd9..311b5067 100755 --- a/src/Wallabag/CoreBundle/Resources/views/Static/about.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/Static/about.html.twig @@ -3,38 +3,34 @@ {% block title %}{% trans %}About{% endtrans %}{% endblock %} {% block content %} -

{% trans %}About wallabag{% endtrans %}

+

{% trans %}Who is behind wallabag{% endtrans %}

-
{% trans %}Project website{% endtrans %}
-
https://www.wallabag.org
- -
{% trans %}Main developer{% endtrans %}
+
{% trans %}Developed by{% endtrans %}
Nicolas Lœuillet — {% trans %}website{% endtrans %}
+
Thomas Citharel — {% trans %}website{% endtrans %}
+
Jérémy Benoist — {% trans %}website{% endtrans %}
-
{% trans %}Contributors ♥:{% endtrans %}
-
{% trans %}on Github{% endtrans %}
+
{% trans %}And many others contributors ♥{% endtrans %} {% trans %}on Github{% endtrans %}
-
{% trans %}Bug reports{% endtrans %}
-
{% trans %}On our support website{% endtrans %} {% trans %}or{% endtrans %} {% trans %}on Github{% endtrans %}
+
{% trans %}Project website{% endtrans %}
+
https://www.wallabag.org
-
{% trans %}License{% endtrans %}
-
MIT
+
{% trans %}License{% endtrans %}: MIT
-
{% trans %}Version{% endtrans %}
-
{{ version }}
+
{% trans %}Version{% endtrans %}: {{ version }}
-

{% trans %}wallabag is a read-it-later application: you can save a web page by keeping only content. Elements like ads or menus are deleted.{% endtrans %}

-

{% trans %}Getting help{% endtrans %}

{% trans %}Documentation{% endtrans %}
-
Online documentation
+
english
+
français
+
deutsch
-
{% trans %}Support{% endtrans %}
-
http://support.wallabag.org/
+
{% trans %}Bug reports{% endtrans %}
+
{% trans %}On our support website{% endtrans %} {% trans %}or{% endtrans %} {% trans %}on Github{% endtrans %}

{% trans %}Helping wallabag{% endtrans %}

@@ -42,8 +38,10 @@

{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}

-
{% trans %}via Paypal{% endtrans %}
+
{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}
+
by contributing to the project: an issue lists all our needs
+
{% trans %}via Paypal{% endtrans %}
-
{% trans %}via Flattr{% endtrans %}
+
{% trans %}via Flattr{% endtrans %}
{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/Tag/new_form.html.twig b/src/Wallabag/CoreBundle/Resources/views/Tag/new_form.html.twig new file mode 100644 index 00000000..0b5a530d --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/Tag/new_form.html.twig @@ -0,0 +1,15 @@ +
+ + {% if form_errors(form) %} + {{ form_errors(form) }} + {% endif %} + + {% if form_errors(form.label) %} + {{ form_errors(form.label) }} + {% endif %} + + {{ form_widget(form.label, { 'attr': {'autocomplete': 'off'} }) }} + {{ form_widget(form.save, { 'attr': {'class': 'btn waves-effect waves-light'}, 'label': 'add tag' }) }} + + +
diff --git a/src/Wallabag/CoreBundle/Resources/views/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig index e27aceae..3ad776b9 100644 --- a/src/Wallabag/CoreBundle/Resources/views/base.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig @@ -71,6 +71,7 @@
  • {% trans %}unread{% endtrans %}
  • {% trans %}favorites{% endtrans %}
  • {% trans %}archive{% endtrans %}
  • +
  • {% trans %}all{% endtrans %}
  • {% trans %}tags{% endtrans %}
  • {% trans %}save a link{% endtrans %}
  • {% trans %}search{% endtrans %} 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 bd64067c..b45552f2 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 @@ -7,6 +7,8 @@ {% trans %}Starred{% endtrans %} {% elseif currentRoute == 'archive' %} {% trans %}Archive{% endtrans %} + {% elseif currentRoute == 'all' %} + {% trans %}Filtered{% endtrans %} {% else %} {% trans %}Unread{% endtrans %} {% endif %} @@ -59,12 +61,26 @@
    -
    +

    {% trans %}Filters{% endtrans %}

    + +
    + +
    +
    + {{ form_widget(form.isArchived) }} + +
    + +
    + {{ form_widget(form.isStarred) }} + +
    +
    @@ -77,7 +93,6 @@
    -
    {{ form_widget(form.domainName, {'type': 'text', 'attr' : {'placeholder': 'website.com'} }) }} 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 b92c41b6..31b2c664 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 @@ -137,7 +137,8 @@ main { {{ entry.domainName }}
    {{ entry.content | raw }} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/about.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/about.html.twig index 8c6269ec..5de71d77 100755 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/about.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Static/about.html.twig @@ -21,7 +21,7 @@
    {% trans %}Developed by{% endtrans %}
    Nicolas Lœuillet — {% trans %}website{% endtrans %}
    Thomas Citharel — {% trans %}website{% endtrans %}
    -
    Jérémy Besnoit — {% trans %}website{% endtrans %}
    +
    Jérémy Benoist — {% trans %}website{% endtrans %}
    {% trans %}And many others contributors ♥{% endtrans %} {% trans %}on Github{% endtrans %}
    {% trans %}Project website{% endtrans %}
    https://www.wallabag.org
    diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/new_form.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/new_form.html.twig new file mode 100644 index 00000000..0b5a530d --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/new_form.html.twig @@ -0,0 +1,15 @@ + + + {% if form_errors(form) %} + {{ form_errors(form) }} + {% endif %} + + {% if form_errors(form.label) %} + {{ form_errors(form.label) }} + {% endif %} + + {{ form_widget(form.label, { 'attr': {'autocomplete': 'off'} }) }} + {{ form_widget(form.save, { 'attr': {'class': 'btn waves-effect waves-light'}, 'label': 'add tag' }) }} + + + diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig index 554865d7..0ec2e082 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig @@ -42,6 +42,7 @@
  • {% trans %}unread{% endtrans %}
  • {% trans %}starred{% endtrans %}
  • {% trans %}archive{% endtrans %}
  • +
  • {% trans %}all{% endtrans %}
  • {% trans %}tags{% endtrans %}
  • {% trans %}config{% endtrans %}
  • {% trans %}howto{% endtrans %}
  • @@ -55,9 +56,9 @@
    diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/js/init.js b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/js/init.js index c0700c2c..d397f8e5 100755 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/js/init.js +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/js/init.js @@ -5,6 +5,7 @@ function init_filters() { $('.button-collapse-right').sideNav({ edge: 'right' }); $('#clear_form_filters').on('click', function(){ $('#filters input').val(''); + $('#filters :checked').removeAttr('checked'); return false; }); } diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 86a19f61..5f0a6076 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -276,7 +276,7 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->submit($form, $data); - $this->assertCount(4, $crawler->filter('div[class=entry]')); + $this->assertCount(5, $crawler->filter('div[class=entry]')); $data = array( 'entry_filter[createdAt][left_date]' => '01/01/1970', @@ -307,6 +307,14 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->request('GET', 'unread/list'.$parameters); $this->assertContains($parameters, $client->getResponse()->getContent()); + + // reset pagination + $crawler = $client->request('GET', '/config'); + $form = $crawler->filter('button[id=config_save]')->form(); + $data = array( + 'config[items_per_page]' => '12', + ); + $client->submit($form, $data); } public function testFilterOnDomainName() @@ -331,4 +339,25 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->submit($form, $data); $this->assertCount(0, $crawler->filter('div[class=entry]')); } + + public function testFilterOnStatus() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/unread/list'); + $form = $crawler->filter('button[id=submit-filter]')->form(); + $form['entry_filter[isArchived]']->tick(); + $form['entry_filter[isStarred]']->untick(); + + $crawler = $client->submit($form); + $this->assertCount(1, $crawler->filter('div[class=entry]')); + + $form = $crawler->filter('button[id=submit-filter]')->form(); + $form['entry_filter[isArchived]']->untick(); + $form['entry_filter[isStarred]']->tick(); + + $crawler = $client->submit($form); + $this->assertCount(1, $crawler->filter('div[class=entry]')); + } } diff --git a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php index 4a43e049..af39d6ce 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php @@ -15,4 +15,54 @@ class TagControllerTest extends WallabagCoreTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode()); } + + public function testAddTagToEntry() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $entry = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneByIsArchived(false); + + $crawler = $client->request('GET', '/view/'.$entry->getId()); + + $form = $crawler->filter('button[id=tag_save]')->form(); + + $data = array( + 'tag[label]' => 'opensource', + ); + + $client->submit($form, $data); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $this->assertEquals(1, count($entry->getTags())); + + # tag already exists and already assigned + $client->submit($form, $data); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $newEntry = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneById($entry->getId()); + + $this->assertEquals(1, count($newEntry->getTags())); + + # tag already exists but still not assigned to this entry + $data = array( + 'tag[label]' => 'foo', + ); + + $client->submit($form, $data); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $newEntry = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneById($entry->getId()); + + $this->assertEquals(2, count($newEntry->getTags())); + } } diff --git a/src/Wallabag/CoreBundle/Tools/Utils.php b/src/Wallabag/CoreBundle/Tools/Utils.php index 7e2968e7..a16baca9 100644 --- a/src/Wallabag/CoreBundle/Tools/Utils.php +++ b/src/Wallabag/CoreBundle/Tools/Utils.php @@ -25,4 +25,17 @@ class Utils // remove character which can broken the url return str_replace(array('+', '/'), '', $token); } + + /** + * For a given text, we calculate reading time for an article + * based on 200 words per minute. + * + * @param $text + * + * @return float + */ + public static function getReadingTime($text) + { + return floor(str_word_count(strip_tags($text)) / 200); + } }