aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php66
-rw-r--r--src/Wallabag/CoreBundle/Controller/RssController.php17
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php4
-rw-r--r--src/Wallabag/CoreBundle/Filter/EntryFilterType.php28
-rwxr-xr-xsrc/Wallabag/CoreBundle/Helper/Tools.php12
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php36
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig7
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/Entry/entries.xml.twig4
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/_global/public/css/style.css8
-rwxr-xr-xsrc/Wallabag/CoreBundle/Resources/views/themes/baggy/public/css/main.css50
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig5
-rwxr-xr-xsrc/Wallabag/CoreBundle/Resources/views/themes/material/public/css/print.css2
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php19
-rw-r--r--src/Wallabag/CoreBundle/Twig/Extension/WallabagExtension.php13
14 files changed, 184 insertions, 87 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index ef686ff1..6944a686 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -9,6 +9,9 @@ use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Service\Extractor; 9use Wallabag\CoreBundle\Service\Extractor;
10use Wallabag\CoreBundle\Form\Type\NewEntryType; 10use Wallabag\CoreBundle\Form\Type\NewEntryType;
11use Wallabag\CoreBundle\Form\Type\EditEntryType; 11use Wallabag\CoreBundle\Form\Type\EditEntryType;
12use Wallabag\CoreBundle\Filter\EntryFilterType;
13use Pagerfanta\Adapter\DoctrineORMAdapter;
14use Pagerfanta\Pagerfanta;
12 15
13class EntryController extends Controller 16class EntryController extends Controller
14{ 17{
@@ -101,22 +104,39 @@ class EntryController extends Controller
101 /** 104 /**
102 * Shows unread entries for current user. 105 * Shows unread entries for current user.
103 * 106 *
107 * @param Request $request
108 * @param int $page
109 *
104 * @Route("/unread/list/{page}", name="unread", defaults={"page" = "1"}) 110 * @Route("/unread/list/{page}", name="unread", defaults={"page" = "1"})
105 * 111 *
106 * @return \Symfony\Component\HttpFoundation\Response 112 * @return \Symfony\Component\HttpFoundation\Response
107 */ 113 */
108 public function showUnreadAction($page) 114 public function showUnreadAction(Request $request, $page)
109 { 115 {
110 $entries = $this->getDoctrine() 116 $form = $this->get('form.factory')->create(new EntryFilterType());
117
118 $filterBuilder = $this->getDoctrine()
111 ->getRepository('WallabagCoreBundle:Entry') 119 ->getRepository('WallabagCoreBundle:Entry')
112 ->findUnreadByUser($this->getUser()->getId()); 120 ->findUnreadByUser($this->getUser()->getId());
113 121
122 if ($request->query->has($form->getName())) {
123 // manually bind values from the request
124 $form->submit($request->query->get($form->getName()));
125
126 // build the query from the given form object
127 $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder);
128 }
129
130 $pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery());
131 $entries = new Pagerfanta($pagerAdapter);
132
114 $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); 133 $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage());
115 $entries->setCurrentPage($page); 134 $entries->setCurrentPage($page);
116 135
117 return $this->render( 136 return $this->render(
118 'WallabagCoreBundle:Entry:entries.html.twig', 137 'WallabagCoreBundle:Entry:entries.html.twig',
119 array( 138 array(
139 'form' => $form->createView(),
120 'entries' => $entries, 140 'entries' => $entries,
121 'currentPage' => $page 141 'currentPage' => $page
122 ) 142 )
@@ -126,22 +146,39 @@ class EntryController extends Controller
126 /** 146 /**
127 * Shows read entries for current user. 147 * Shows read entries for current user.
128 * 148 *
149 * @param Request $request
150 * @param int $page
151 *
129 * @Route("/archive/list/{page}", name="archive", defaults={"page" = "1"}) 152 * @Route("/archive/list/{page}", name="archive", defaults={"page" = "1"})
130 * 153 *
131 * @return \Symfony\Component\HttpFoundation\Response 154 * @return \Symfony\Component\HttpFoundation\Response
132 */ 155 */
133 public function showArchiveAction($page) 156 public function showArchiveAction(Request $request, $page)
134 { 157 {
135 $entries = $this->getDoctrine() 158 $form = $this->get('form.factory')->create(new EntryFilterType());
159
160 $filterBuilder = $this->getDoctrine()
136 ->getRepository('WallabagCoreBundle:Entry') 161 ->getRepository('WallabagCoreBundle:Entry')
137 ->findArchiveByUser($this->getUser()->getId()); 162 ->findArchiveByUser($this->getUser()->getId());
138 163
164 if ($request->query->has($form->getName())) {
165 // manually bind values from the request
166 $form->submit($request->query->get($form->getName()));
167
168 // build the query from the given form object
169 $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder);
170 }
171
172 $pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery());
173 $entries = new Pagerfanta($pagerAdapter);
174
139 $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); 175 $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage());
140 $entries->setCurrentPage($page); 176 $entries->setCurrentPage($page);
141 177
142 return $this->render( 178 return $this->render(
143 'WallabagCoreBundle:Entry:entries.html.twig', 179 'WallabagCoreBundle:Entry:entries.html.twig',
144 array( 180 array(
181 'form' => $form->createView(),
145 'entries' => $entries, 182 'entries' => $entries,
146 'currentPage' => $page 183 'currentPage' => $page
147 ) 184 )
@@ -151,22 +188,39 @@ class EntryController extends Controller
151 /** 188 /**
152 * Shows starred entries for current user. 189 * Shows starred entries for current user.
153 * 190 *
191 * @param Request $request
192 * @param int $page
193 *
154 * @Route("/starred/list/{page}", name="starred", defaults={"page" = "1"}) 194 * @Route("/starred/list/{page}", name="starred", defaults={"page" = "1"})
155 * 195 *
156 * @return \Symfony\Component\HttpFoundation\Response 196 * @return \Symfony\Component\HttpFoundation\Response
157 */ 197 */
158 public function showStarredAction($page) 198 public function showStarredAction(Request $request, $page)
159 { 199 {
160 $entries = $this->getDoctrine() 200 $form = $this->get('form.factory')->create(new EntryFilterType());
201
202 $filterBuilder = $this->getDoctrine()
161 ->getRepository('WallabagCoreBundle:Entry') 203 ->getRepository('WallabagCoreBundle:Entry')
162 ->findStarredByUser($this->getUser()->getId()); 204 ->findStarredByUser($this->getUser()->getId());
163 205
206 if ($request->query->has($form->getName())) {
207 // manually bind values from the request
208 $form->submit($request->query->get($form->getName()));
209
210 // build the query from the given form object
211 $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder);
212 }
213
214 $pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery());
215 $entries = new Pagerfanta($pagerAdapter);
216
164 $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); 217 $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage());
165 $entries->setCurrentPage($page); 218 $entries->setCurrentPage($page);
166 219
167 return $this->render( 220 return $this->render(
168 'WallabagCoreBundle:Entry:entries.html.twig', 221 'WallabagCoreBundle:Entry:entries.html.twig',
169 array( 222 array(
223 'form' => $form->createView(),
170 'entries' => $entries, 224 'entries' => $entries,
171 'currentPage' => $page 225 'currentPage' => $page
172 ) 226 )
diff --git a/src/Wallabag/CoreBundle/Controller/RssController.php b/src/Wallabag/CoreBundle/Controller/RssController.php
index 8428dce0..0558c53b 100644
--- a/src/Wallabag/CoreBundle/Controller/RssController.php
+++ b/src/Wallabag/CoreBundle/Controller/RssController.php
@@ -7,6 +7,8 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
7use Symfony\Bundle\FrameworkBundle\Controller\Controller; 7use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8use Wallabag\CoreBundle\Entity\User; 8use Wallabag\CoreBundle\Entity\User;
9use Wallabag\CoreBundle\Entity\Entry; 9use Wallabag\CoreBundle\Entity\Entry;
10use Pagerfanta\Adapter\DoctrineORMAdapter;
11use Pagerfanta\Pagerfanta;
10 12
11class RssController extends Controller 13class RssController extends Controller
12{ 14{
@@ -20,12 +22,15 @@ class RssController extends Controller
20 */ 22 */
21 public function showUnreadAction(User $user) 23 public function showUnreadAction(User $user)
22 { 24 {
23 $entries = $this->getDoctrine() 25 $qb = $this->getDoctrine()
24 ->getRepository('WallabagCoreBundle:Entry') 26 ->getRepository('WallabagCoreBundle:Entry')
25 ->findUnreadByUser( 27 ->findUnreadByUser(
26 $user->getId() 28 $user->getId()
27 ); 29 );
28 30
31 $pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
32 $entries = new Pagerfanta($pagerAdapter);
33
29 $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit'); 34 $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit');
30 $entries->setMaxPerPage($perPage); 35 $entries->setMaxPerPage($perPage);
31 36
@@ -45,12 +50,15 @@ class RssController extends Controller
45 */ 50 */
46 public function showArchiveAction(User $user) 51 public function showArchiveAction(User $user)
47 { 52 {
48 $entries = $this->getDoctrine() 53 $qb = $this->getDoctrine()
49 ->getRepository('WallabagCoreBundle:Entry') 54 ->getRepository('WallabagCoreBundle:Entry')
50 ->findArchiveByUser( 55 ->findArchiveByUser(
51 $user->getId() 56 $user->getId()
52 ); 57 );
53 58
59 $pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
60 $entries = new Pagerfanta($pagerAdapter);
61
54 $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit'); 62 $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit');
55 $entries->setMaxPerPage($perPage); 63 $entries->setMaxPerPage($perPage);
56 64
@@ -70,12 +78,15 @@ class RssController extends Controller
70 */ 78 */
71 public function showStarredAction(User $user) 79 public function showStarredAction(User $user)
72 { 80 {
73 $entries = $this->getDoctrine() 81 $qb = $this->getDoctrine()
74 ->getRepository('WallabagCoreBundle:Entry') 82 ->getRepository('WallabagCoreBundle:Entry')
75 ->findStarredByUser( 83 ->findStarredByUser(
76 $user->getId() 84 $user->getId()
77 ); 85 );
78 86
87 $pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
88 $entries = new Pagerfanta($pagerAdapter);
89
79 $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit'); 90 $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit');
80 $entries->setMaxPerPage($perPage); 91 $entries->setMaxPerPage($perPage);
81 92
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index f139bbac..9aebc55b 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -7,6 +7,7 @@ use Doctrine\ORM\Mapping as ORM;
7use Symfony\Component\Validator\Constraints as Assert; 7use Symfony\Component\Validator\Constraints as Assert;
8use Hateoas\Configuration\Annotation as Hateoas; 8use Hateoas\Configuration\Annotation as Hateoas;
9use JMS\Serializer\Annotation\XmlRoot; 9use JMS\Serializer\Annotation\XmlRoot;
10use Wallabag\CoreBundle\Helper\Tools;
10 11
11/** 12/**
12 * Entry. 13 * Entry.
@@ -96,7 +97,7 @@ class Entry
96 /** 97 /**
97 * @var int 98 * @var int
98 * 99 *
99 * @ORM\Column(name="reading_type", type="integer", nullable=true) 100 * @ORM\Column(name="reading_time", type="integer", nullable=true)
100 */ 101 */
101 private $readingTime; 102 private $readingTime;
102 103
@@ -264,6 +265,7 @@ class Entry
264 public function setContent($content) 265 public function setContent($content)
265 { 266 {
266 $this->content = $content; 267 $this->content = $content;
268 $this->readingTime = Tools::getReadingTime($content);
267 269
268 return $this; 270 return $this;
269 } 271 }
diff --git a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php
new file mode 100644
index 00000000..636ba324
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php
@@ -0,0 +1,28 @@
1<?php
2
3namespace Wallabag\CoreBundle\Filter;
4
5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\OptionsResolver\OptionsResolver;
8
9class EntryFilterType extends AbstractType
10{
11 public function buildForm(FormBuilderInterface $builder, array $options)
12 {
13 $builder->add('readingTime', 'filter_number_range');
14 }
15
16 public function getName()
17 {
18 return 'entry_filter';
19 }
20
21 public function configureOptions(OptionsResolver $resolver)
22 {
23 $resolver->setDefaults(array(
24 'csrf_protection' => false,
25 'validation_groups' => array('filtering')
26 ));
27 }
28}
diff --git a/src/Wallabag/CoreBundle/Helper/Tools.php b/src/Wallabag/CoreBundle/Helper/Tools.php
index be29ab99..d368ee71 100755
--- a/src/Wallabag/CoreBundle/Helper/Tools.php
+++ b/src/Wallabag/CoreBundle/Helper/Tools.php
@@ -118,4 +118,16 @@ final class Tools
118 118
119 return str_replace('+', '', $token); 119 return str_replace('+', '', $token);
120 } 120 }
121
122 /**
123 * For a given text, we calculate reading time for an article.
124 *
125 * @param $text
126 *
127 * @return float
128 */
129 public static function getReadingTime($text)
130 {
131 return floor(str_word_count(strip_tags($text)) / 200);
132 }
121} 133}
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index a4514d9e..f885ee94 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -13,20 +13,15 @@ class EntryRepository extends EntityRepository
13 * 13 *
14 * @param int $userId 14 * @param int $userId
15 * 15 *
16 * @return Pagerfanta 16 * @return QueryBuilder
17 */ 17 */
18 public function findUnreadByUser($userId) 18 public function findUnreadByUser($userId)
19 { 19 {
20 $qb = $this->createQueryBuilder('e') 20 return $this->createQueryBuilder('e')
21 ->leftJoin('e.user', 'u') 21 ->leftJoin('e.user', 'u')
22 ->where('e.isArchived = false') 22 ->where('e.isArchived = false')
23 ->andWhere('u.id =:userId')->setParameter('userId', $userId) 23 ->andWhere('u.id =:userId')->setParameter('userId', $userId)
24 ->orderBy('e.id', 'desc') 24 ->orderBy('e.id', 'desc');
25 ->getQuery();
26
27 $pagerAdapter = new DoctrineORMAdapter($qb);
28
29 return new Pagerfanta($pagerAdapter);
30 } 25 }
31 26
32 /** 27 /**
@@ -34,21 +29,15 @@ class EntryRepository extends EntityRepository
34 * 29 *
35 * @param int $userId 30 * @param int $userId
36 * 31 *
37 * @return Pagerfanta 32 * @return QueryBuilder
38 */ 33 */
39 public function findArchiveByUser($userId) 34 public function findArchiveByUser($userId)
40 { 35 {
41 $qb = $this->createQueryBuilder('e') 36 return $this->createQueryBuilder('e')
42 ->select('e')
43 ->leftJoin('e.user', 'u') 37 ->leftJoin('e.user', 'u')
44 ->where('e.isArchived = true') 38 ->where('e.isArchived = true')
45 ->andWhere('u.id =:userId')->setParameter('userId', $userId) 39 ->andWhere('u.id =:userId')->setParameter('userId', $userId)
46 ->orderBy('e.id', 'desc') 40 ->orderBy('e.id', 'desc');
47 ->getQuery();
48
49 $pagerAdapter = new DoctrineORMAdapter($qb);
50
51 return new Pagerfanta($pagerAdapter);
52 } 41 }
53 42
54 /** 43 /**
@@ -56,22 +45,15 @@ class EntryRepository extends EntityRepository
56 * 45 *
57 * @param int $userId 46 * @param int $userId
58 * 47 *
59 * @return Pagerfanta 48 * @return QueryBuilder
60 */ 49 */
61 public function findStarredByUser($userId) 50 public function findStarredByUser($userId)
62 { 51 {
63 52 return $this->createQueryBuilder('e')
64 $qb = $this->createQueryBuilder('e')
65 ->select('e')
66 ->leftJoin('e.user', 'u') 53 ->leftJoin('e.user', 'u')
67 ->where('e.isStarred = true') 54 ->where('e.isStarred = true')
68 ->andWhere('u.id =:userId')->setParameter('userId', $userId) 55 ->andWhere('u.id =:userId')->setParameter('userId', $userId)
69 ->orderBy('e.id', 'desc') 56 ->orderBy('e.id', 'desc');
70 ->getQuery();
71
72 $pagerAdapter = new DoctrineORMAdapter($qb);
73
74 return new Pagerfanta($pagerAdapter);
75 } 57 }
76 58
77 /** 59 /**
diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
index bf3caf09..7629ef35 100644
--- a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
@@ -21,11 +21,12 @@
21 {% if entries is empty %} 21 {% if entries is empty %}
22 <div class="messages warning"><p>{% trans %}No articles found.{% endtrans %}</p></div> 22 <div class="messages warning"><p>{% trans %}No articles found.{% endtrans %}</p></div>
23 {% else %} 23 {% else %}
24 <div><form>{{ form_rest(form) }}<button class="btn waves-effect waves-light" type="submit" id="submit-filter" value="filter">Filter</button></form></div>
24 {% for entry in entries %} 25 {% for entry in entries %}
25 <div id="entry-{{ entry.id|e }}" class="entrie"> 26 <div id="entry-{{ entry.id|e }}" class="entry">
26 <h2><a href="{{ path('view', { 'id': entry.id }) }}">{{ entry.title|raw }}</a></h2> 27 <h2><a href="{{ path('view', { 'id': entry.id }) }}">{{ entry.title|raw }}</a></h2>
27 {% if entry.content| readingTime > 0 %} 28 {% if entry.readingTime > 0 %}
28 <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} {{ entry.content| readingTime }} min</span></div> 29 <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} {{ entry.readingTime }} min</span></div>
29 {% else %} 30 {% else %}
30 <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} <small class="inferieur">&lt;</small> 1 min</span></div> 31 <div class="estimatedTime"><span class="tool reading-time">{% trans %}estimated reading time :{% endtrans %} <small class="inferieur">&lt;</small> 1 min</span></div>
31 {% endif %} 32 {% endif %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.xml.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.xml.twig
index 5ec9bc03..a39a8dc3 100644
--- a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.xml.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.xml.twig
@@ -17,8 +17,8 @@
17 <pubDate>{{ entry.createdAt|date('D, d M Y H:i:s') }}</pubDate> 17 <pubDate>{{ entry.createdAt|date('D, d M Y H:i:s') }}</pubDate>
18 <description> 18 <description>
19 <![CDATA[ 19 <![CDATA[
20 {%- if entry.content|readingTime > 0 -%} 20 {%- if entry.readingTime > 0 -%}
21 {% trans %}estimated reading time :{% endtrans %} {{ entry.content|readingTime }} min 21 {% trans %}estimated reading time :{% endtrans %} {{ entry.readingTime }} min
22 {%- else -%} 22 {%- else -%}
23 {% trans %}estimated reading time :{% endtrans %} &lt; 1 min 23 {% trans %}estimated reading time :{% endtrans %} &lt; 1 min
24 {%- endif %} 24 {%- endif %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/_global/public/css/style.css b/src/Wallabag/CoreBundle/Resources/views/themes/_global/public/css/style.css
index e3069b86..ffd9d022 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/_global/public/css/style.css
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/_global/public/css/style.css
@@ -121,7 +121,7 @@ a:visited {
121 font-size: 1.3em; 121 font-size: 1.3em;
122} 122}
123 123
124#main #content .entrie { 124#main #content .entry {
125 margin-top: 15px; 125 margin-top: 15px;
126 padding-bottom: 15px; 126 padding-bottom: 15px;
127 border-bottom: 1px dashed #222; 127 border-bottom: 1px dashed #222;
@@ -129,19 +129,19 @@ a:visited {
129} 129}
130 130
131/* First entry */ 131/* First entry */
132#main #content .results + .entrie { 132#main #content .results + .entry {
133 clear: both; 133 clear: both;
134 margin-top: 0; 134 margin-top: 0;
135} 135}
136 136
137#main .entrie .tools { 137#main .entry .tools {
138 float: right; 138 float: right;
139 text-align: right; 139 text-align: right;
140 list-style-type: none; 140 list-style-type: none;
141 opacity: 0.5; 141 opacity: 0.5;
142} 142}
143 143
144#main .entrie .tools .tool span { 144#main .entry .tools .tool span {
145 display: inline-block; 145 display: inline-block;
146 width: 16px; 146 width: 16px;
147 height: 16px; 147 height: 16px;
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 e2844ccc..6090face 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
@@ -322,7 +322,7 @@ footer a {
322 letter-spacing:-5px; 322 letter-spacing:-5px;
323} 323}
324 324
325.listmode .entrie { 325.listmode .entry {
326 width: 100%!important; 326 width: 100%!important;
327 margin-left: 0!important; 327 margin-left: 0!important;
328} 328}
@@ -343,7 +343,7 @@ footer a {
343 top: -1px; 343 top: -1px;
344} 344}
345 345
346.entrie { 346.entry {
347 background-color: #FFF; 347 background-color: #FFF;
348 letter-spacing:normal; 348 letter-spacing:normal;
349 box-shadow: 0 3px 7px rgba(0,0,0,0.3); 349 box-shadow: 0 3px 7px rgba(0,0,0,0.3);
@@ -366,7 +366,7 @@ footer a {
366 /* transition: all 0.5s ease; */ 366 /* transition: all 0.5s ease; */
367} 367}
368 368
369.entrie:before { 369.entry:before {
370 content: ""; 370 content: "";
371 width: 0; 371 width: 0;
372 height: 0; 372 height: 0;
@@ -384,7 +384,7 @@ footer a {
384 transition: all 0.5s ease; 384 transition: all 0.5s ease;
385} 385}
386 386
387.entrie:after { 387.entry:after {
388 content: ""; 388 content: "";
389 position: absolute; 389 position: absolute;
390 height: 7px; 390 height: 7px;
@@ -399,34 +399,34 @@ footer a {
399 transition: all 0.5s ease; 399 transition: all 0.5s ease;
400} 400}
401 401
402.entrie:hover { 402.entry:hover {
403 box-shadow: 0 3px 10px rgba(0,0,0,1); 403 box-shadow: 0 3px 10px rgba(0,0,0,1);
404} 404}
405 405
406.entrie:hover:after { 406.entry:hover:after {
407 height: 40px; 407 height: 40px;
408} 408}
409 409
410.entrie:hover:before { 410.entry:hover:before {
411 bottom: 2.4em; 411 bottom: 2.4em;
412} 412}
413 413
414.entrie:hover h2 a { 414.entry:hover h2 a {
415 color: #666; 415 color: #666;
416} 416}
417 417
418.entrie h2 { 418.entry h2 {
419 text-transform: none; 419 text-transform: none;
420 margin-bottom: 0; 420 margin-bottom: 0;
421 line-height: 1.2; 421 line-height: 1.2;
422} 422}
423 423
424 .entrie h2:after { 424 .entry h2:after {
425 content: none; 425 content: none;
426 } 426 }
427 427
428 428
429.entrie h2 a { 429.entry h2 a {
430 display: block; 430 display: block;
431 text-decoration: none; 431 text-decoration: none;
432 color: #000; 432 color: #000;
@@ -438,7 +438,7 @@ footer a {
438 transition: all 0.5s ease; 438 transition: all 0.5s ease;
439} 439}
440/* 440/*
441.entrie h2 a:after { 441.entry h2 a:after {
442 content: ""; 442 content: "";
443 position: absolute; 443 position: absolute;
444 top: 0; 444 top: 0;
@@ -448,21 +448,21 @@ footer a {
448} 448}
449*/ 449*/
450 450
451.entrie p { 451.entry p {
452 color: #666; 452 color: #666;
453 font-size: 0.9em; 453 font-size: 0.9em;
454 line-height: 1.7; 454 line-height: 1.7;
455} 455}
456 456
457 .entrie h2 a:first-letter { 457 .entry h2 a:first-letter {
458 text-transform: uppercase; 458 text-transform: uppercase;
459 } 459 }
460 460
461.entrie:hover .tools { 461.entry:hover .tools {
462 bottom: 0; 462 bottom: 0;
463} 463}
464 464
465.entrie .tools { 465.entry .tools {
466 position: absolute; 466 position: absolute;
467 bottom: -50px; 467 bottom: -50px;
468 left: 0; 468 left: 0;
@@ -477,22 +477,22 @@ footer a {
477 transition: all 0.5s ease; 477 transition: all 0.5s ease;
478} 478}
479 479
480 .entrie .tools a { 480 .entry .tools a {
481 color: #666; 481 color: #666;
482 text-decoration: none; 482 text-decoration: none;
483 display: block; 483 display: block;
484 padding: 0.4em; 484 padding: 0.4em;
485 } 485 }
486 486
487 .entrie .tools a:hover { 487 .entry .tools a:hover {
488 color: #FFF; 488 color: #FFF;
489 } 489 }
490 490
491 .entrie .tools li { 491 .entry .tools li {
492 display: inline-block; 492 display: inline-block;
493 } 493 }
494 494
495.entrie:nth-child(3n+1) { 495.entry:nth-child(3n+1) {
496 margin-left: 0; 496 margin-left: 0;
497} 497}
498 498
@@ -941,13 +941,13 @@ pre code {
941 ========================================================================== */ 941 ========================================================================== */
942 942
943@media screen and (max-width: 1050px) { 943@media screen and (max-width: 1050px) {
944 .entrie { 944 .entry {
945 width: 49%; 945 width: 49%;
946 } 946 }
947 .entrie:nth-child(3n+1) { 947 .entry:nth-child(3n+1) {
948 margin-left: 1.5%; 948 margin-left: 1.5%;
949 } 949 }
950 .entrie:nth-child(2n+1) { 950 .entry:nth-child(2n+1) {
951 margin-left: 0; 951 margin-left: 0;
952 } 952 }
953} 953}
@@ -962,7 +962,7 @@ pre code {
962} 962}
963 963
964@media screen and (max-width: 700px) { 964@media screen and (max-width: 700px) {
965 .entrie { 965 .entry {
966 width: 100%; 966 width: 100%;
967 margin-left: 0; 967 margin-left: 0;
968 } 968 }
@@ -972,7 +972,7 @@ pre code {
972} 972}
973 973
974@media screen and (max-width: 500px) { 974@media screen and (max-width: 500px) {
975 .entrie { 975 .entry {
976 width: 100%; 976 width: 100%;
977 margin-left: 0; 977 margin-left: 0;
978 } 978 }
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 fbdc1ffd..b9f1be49 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
@@ -18,6 +18,7 @@
18 {% if entries is not empty %} 18 {% if entries is not empty %}
19 <div class="results clearfix"> 19 <div class="results clearfix">
20 <div class="nb-results left">{{ entries.count }} {% trans %}entries{% endtrans %}</div> 20 <div class="nb-results left">{{ entries.count }} {% trans %}entries{% endtrans %}</div>
21 <div class="left"><form>{{ form_rest(form) }}<button class="btn waves-effect waves-light" type="submit" id="submit-filter" value="filter">Filter</button></form></div>
21 <ul class="pagination right"> 22 <ul class="pagination right">
22 {% for p in range(1, entries.nbPages) %} 23 {% for p in range(1, entries.nbPages) %}
23 <li class="{{ currentPage == p ? 'active':'waves-effect'}}"> 24 <li class="{{ currentPage == p ? 'active':'waves-effect'}}">
@@ -38,8 +39,8 @@
38 <div class="card"> 39 <div class="card">
39 <div class="card-content"> 40 <div class="card-content">
40 <span class="card-title"><a href="{{ path('view', { 'id': entry.id }) }}">{{ entry.title|raw }}</a></span> 41 <span class="card-title"><a href="{{ path('view', { 'id': entry.id }) }}">{{ entry.title|raw }}</a></span>
41 {% if entry.content| readingTime > 0 %} 42 {% if entry.readingTime > 0 %}
42 <div class="estimatedTime grey-text"><span class="tool reading-time">{% trans %}estimated reading time: {% endtrans %} {{ entry.content| readingTime }} min</span></div> 43 <div class="estimatedTime grey-text"><span class="tool reading-time">{% trans %}estimated reading time: {% endtrans %} {{ entry.readingTime }} min</span></div>
43 {% else %} 44 {% else %}
44 <div class="estimatedTime grey-text"><span class="tool reading-time">{% trans %}estimated reading time: {% endtrans %} <small class="inferieur">&lt;</small> 1 min</span></div> 45 <div class="estimatedTime grey-text"><span class="tool reading-time">{% trans %}estimated reading time: {% endtrans %} <small class="inferieur">&lt;</small> 1 min</span></div>
45 {% endif %} 46 {% endif %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/print.css b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/print.css
index 9dd6d295..2a799c44 100755
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/print.css
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/public/css/print.css
@@ -25,7 +25,7 @@ body > footer,
25div.tools, 25div.tools,
26header div, 26header div,
27.messages, 27.messages,
28.entrie + .results { 28.entry + .results {
29 display: none !important; 29 display: none !important;
30} 30}
31 31
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index 2cd50130..24848eb2 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -240,4 +240,23 @@ class EntryControllerTest extends WallabagCoreTestCase
240 240
241 $this->assertEquals(403, $client->getResponse()->getStatusCode()); 241 $this->assertEquals(403, $client->getResponse()->getStatusCode());
242 } 242 }
243
244 public function testFilterOnUnreadeView()
245 {
246 $this->logInAs('admin');
247 $client = $this->getClient();
248
249 $crawler = $client->request('GET', '/unread/list');
250
251 $form = $crawler->filter('button[id=submit-filter]')->form();
252
253 $data = array(
254 'entry_filter[readingTime][right_number]' => 11,
255 'entry_filter[readingTime][left_number]' => 11
256 );
257
258 $crawler = $client->submit($form, $data);
259
260 $this->assertCount(1, $crawler->filter('div[class=entry]'));
261 }
243} 262}
diff --git a/src/Wallabag/CoreBundle/Twig/Extension/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/Extension/WallabagExtension.php
index 18388948..5f0a9643 100644
--- a/src/Wallabag/CoreBundle/Twig/Extension/WallabagExtension.php
+++ b/src/Wallabag/CoreBundle/Twig/Extension/WallabagExtension.php
@@ -7,7 +7,6 @@ class WallabagExtension extends \Twig_Extension
7 public function getFilters() 7 public function getFilters()
8 { 8 {
9 return array( 9 return array(
10 new \Twig_SimpleFilter('readingTime', array($this, 'getReadingTime')),
11 new \Twig_SimpleFilter('domainName', array($this, 'getDomainName')), 10 new \Twig_SimpleFilter('domainName', array($this, 'getDomainName')),
12 ); 11 );
13 } 12 }
@@ -24,18 +23,6 @@ class WallabagExtension extends \Twig_Extension
24 return parse_url($url, PHP_URL_HOST); 23 return parse_url($url, PHP_URL_HOST);
25 } 24 }
26 25
27 /**
28 * For a given text, we calculate reading time for an article.
29 *
30 * @param $text
31 *
32 * @return float
33 */
34 public static function getReadingTime($text)
35 {
36 return floor(str_word_count(strip_tags($text)) / 200);
37 }
38
39 public function getName() 26 public function getName()
40 { 27 {
41 return 'wallabag_extension'; 28 return 'wallabag_extension';