aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.scrutinizer.yml4
-rw-r--r--app/config/config.yml1
-rw-r--r--composer.json1
-rw-r--r--src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php25
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php119
-rw-r--r--src/Wallabag/CoreBundle/Controller/RssController.php73
-rw-r--r--src/Wallabag/CoreBundle/Controller/StaticController.php8
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php50
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php4
-rw-r--r--src/Wallabag/CoreBundle/Entity/Tag.php5
-rw-r--r--src/Wallabag/CoreBundle/Filter/EntryFilterType.php4
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/NewTagType.php30
-rw-r--r--src/Wallabag/CoreBundle/Helper/Entry.php7
-rwxr-xr-xsrc/Wallabag/CoreBundle/Helper/Tools.php133
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php61
-rw-r--r--src/Wallabag/CoreBundle/Repository/TagRepository.php17
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/routing.yml7
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig3
-rwxr-xr-xsrc/Wallabag/CoreBundle/Resources/views/Static/about.html.twig38
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/Tag/new_form.html.twig15
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/base.html.twig1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig19
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig3
-rwxr-xr-xsrc/Wallabag/CoreBundle/Resources/views/themes/material/Static/about.html.twig2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/new_form.html.twig15
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig7
-rwxr-xr-xsrc/Wallabag/CoreBundle/Resources/views/themes/material/public/js/init.js1
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php31
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php50
-rw-r--r--src/Wallabag/CoreBundle/Tools/Utils.php13
31 files changed, 444 insertions, 305 deletions
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index 08f4a3e9..8fbd8265 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -21,3 +21,7 @@ tools:
21 php_code_coverage: true 21 php_code_coverage: true
22 php_sim: false 22 php_sim: false
23 php_cpd: false 23 php_cpd: false
24
25checks:
26 php:
27 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:
51 form: 51 form:
52 resources: 52 resources:
53 - LexikFormFilterBundle:Form:form_div_layout.html.twig 53 - LexikFormFilterBundle:Form:form_div_layout.html.twig
54
54# Assetic Configuration 55# Assetic Configuration
55assetic: 56assetic:
56 debug: "%kernel.debug%" 57 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 @@
19 }, 19 },
20 { 20 {
21 "name": "Jérémy Benoist", 21 "name": "Jérémy Benoist",
22 "homepage": "http://www.j0k3r.net",
22 "role": "Developer" 23 "role": "Developer"
23 } 24 }
24 ], 25 ],
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
170 $client = $this->createClient(); 170 $client = $this->createClient();
171 $headers = $this->generateHeaders('admin', 'mypassword'); 171 $headers = $this->generateHeaders('admin', 'mypassword');
172 172
173 $client->request('GET', '/api/entries', array('star' => 1, 'sort' => 'updated'), array(), $headers);
174
175 $this->assertEquals(200, $client->getResponse()->getStatusCode());
176
177 $content = json_decode($client->getResponse()->getContent(), true);
178
179 $this->assertGreaterThanOrEqual(1, count($content));
180 $this->assertNotEmpty($content['_embedded']['items']);
181 $this->assertGreaterThanOrEqual(1, $content['total']);
182 $this->assertEquals(1, $content['page']);
183 $this->assertGreaterThanOrEqual(1, $content['pages']);
184
185 $this->assertTrue(
186 $client->getResponse()->headers->contains(
187 'Content-Type',
188 'application/json'
189 )
190 );
191 }
192
193 public function testGetArchiveEntries()
194 {
195 $client = $this->createClient();
196 $headers = $this->generateHeaders('admin', 'mypassword');
197
173 $client->request('GET', '/api/entries', array('archive' => 1), array(), $headers); 198 $client->request('GET', '/api/entries', array('archive' => 1), array(), $headers);
174 199
175 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 200 $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
@@ -102,6 +102,21 @@ class EntryController extends Controller
102 } 102 }
103 103
104 /** 104 /**
105 * Shows all entries for current user.
106 *
107 * @param Request $request
108 * @param int $page
109 *
110 * @Route("/all/list/{page}", name="all", defaults={"page" = "1"})
111 *
112 * @return \Symfony\Component\HttpFoundation\Response
113 */
114 public function showAllAction(Request $request, $page)
115 {
116 return $this->showEntries('all', $request, $page);
117 }
118
119 /**
105 * Shows unread entries for current user. 120 * Shows unread entries for current user.
106 * 121 *
107 * @param Request $request 122 * @param Request $request
@@ -113,34 +128,7 @@ class EntryController extends Controller
113 */ 128 */
114 public function showUnreadAction(Request $request, $page) 129 public function showUnreadAction(Request $request, $page)
115 { 130 {
116 $form = $this->get('form.factory')->create(new EntryFilterType()); 131 return $this->showEntries('unread', $request, $page);
117
118 $filterBuilder = $this->getDoctrine()
119 ->getRepository('WallabagCoreBundle:Entry')
120 ->findUnreadByUser($this->getUser()->getId());
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
133 $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage());
134 $entries->setCurrentPage($page);
135
136 return $this->render(
137 'WallabagCoreBundle:Entry:entries.html.twig',
138 array(
139 'form' => $form->createView(),
140 'entries' => $entries,
141 'currentPage' => $page,
142 )
143 );
144 } 132 }
145 133
146 /** 134 /**
@@ -155,34 +143,7 @@ class EntryController extends Controller
155 */ 143 */
156 public function showArchiveAction(Request $request, $page) 144 public function showArchiveAction(Request $request, $page)
157 { 145 {
158 $form = $this->get('form.factory')->create(new EntryFilterType()); 146 return $this->showEntries('archive', $request, $page);
159
160 $filterBuilder = $this->getDoctrine()
161 ->getRepository('WallabagCoreBundle:Entry')
162 ->findArchiveByUser($this->getUser()->getId());
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
175 $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage());
176 $entries->setCurrentPage($page);
177
178 return $this->render(
179 'WallabagCoreBundle:Entry:entries.html.twig',
180 array(
181 'form' => $form->createView(),
182 'entries' => $entries,
183 'currentPage' => $page,
184 )
185 );
186 } 147 }
187 148
188 /** 149 /**
@@ -197,21 +158,55 @@ class EntryController extends Controller
197 */ 158 */
198 public function showStarredAction(Request $request, $page) 159 public function showStarredAction(Request $request, $page)
199 { 160 {
200 $form = $this->get('form.factory')->create(new EntryFilterType()); 161 return $this->showEntries('starred', $request, $page);
162 }
163
164 /**
165 * Global method to retrieve entries depending on the given type
166 * It returns the response to be send.
167 *
168 * @param string $type Entries type: unread, starred or archive
169 * @param Request $request
170 * @param int $page
171 *
172 * @return \Symfony\Component\HttpFoundation\Response
173 */
174 private function showEntries($type, Request $request, $page)
175 {
176 $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
177
178 switch ($type) {
179 case 'starred':
180 $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId());
181 break;
182
183 case 'archive':
184 $qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId());
185 break;
186
187 case 'unread':
188 $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
189 break;
201 190
202 $filterBuilder = $this->getDoctrine() 191 case 'all':
203 ->getRepository('WallabagCoreBundle:Entry') 192 $qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
204 ->findStarredByUser($this->getUser()->getId()); 193 break;
194
195 default:
196 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
197 }
198
199 $form = $this->get('form.factory')->create(new EntryFilterType());
205 200
206 if ($request->query->has($form->getName())) { 201 if ($request->query->has($form->getName())) {
207 // manually bind values from the request 202 // manually bind values from the request
208 $form->submit($request->query->get($form->getName())); 203 $form->submit($request->query->get($form->getName()));
209 204
210 // build the query from the given form object 205 // build the query from the given form object
211 $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder); 206 $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb);
212 } 207 }
213 208
214 $pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery()); 209 $pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
215 $entries = new Pagerfanta($pagerAdapter); 210 $entries = new Pagerfanta($pagerAdapter);
216 211
217 $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); 212 $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
22 */ 22 */
23 public function showUnreadAction(User $user) 23 public function showUnreadAction(User $user)
24 { 24 {
25 $qb = $this->getDoctrine() 25 return $this->showEntries('unread', $user);
26 ->getRepository('WallabagCoreBundle:Entry')
27 ->findUnreadByUser(
28 $user->getId()
29 );
30
31 $pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
32 $entries = new Pagerfanta($pagerAdapter);
33
34 $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit');
35 $entries->setMaxPerPage($perPage);
36
37 return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array(
38 'type' => 'unread',
39 'entries' => $entries,
40 ));
41 } 26 }
42 27
43 /** 28 /**
@@ -50,22 +35,7 @@ class RssController extends Controller
50 */ 35 */
51 public function showArchiveAction(User $user) 36 public function showArchiveAction(User $user)
52 { 37 {
53 $qb = $this->getDoctrine() 38 return $this->showEntries('archive', $user);
54 ->getRepository('WallabagCoreBundle:Entry')
55 ->findArchiveByUser(
56 $user->getId()
57 );
58
59 $pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
60 $entries = new Pagerfanta($pagerAdapter);
61
62 $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit');
63 $entries->setMaxPerPage($perPage);
64
65 return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array(
66 'type' => 'archive',
67 'entries' => $entries,
68 ));
69 } 39 }
70 40
71 /** 41 /**
@@ -78,11 +48,38 @@ class RssController extends Controller
78 */ 48 */
79 public function showStarredAction(User $user) 49 public function showStarredAction(User $user)
80 { 50 {
81 $qb = $this->getDoctrine() 51 return $this->showEntries('starred', $user);
82 ->getRepository('WallabagCoreBundle:Entry') 52 }
83 ->findStarredByUser( 53
84 $user->getId() 54 /**
85 ); 55 * Global method to retrieve entries depending on the given type
56 * It returns the response to be send.
57 *
58 * @param string $type Entries type: unread, starred or archive
59 * @param User $user
60 *
61 * @return \Symfony\Component\HttpFoundation\Response
62 */
63 private function showEntries($type, User $user)
64 {
65 $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
66
67 switch ($type) {
68 case 'starred':
69 $qb = $repository->getBuilderForStarredByUser($user->getId());
70 break;
71
72 case 'archive':
73 $qb = $repository->getBuilderForArchiveByUser($user->getId());
74 break;
75
76 case 'unread':
77 $qb = $repository->getBuilderForUnreadByUser($user->getId());
78 break;
79
80 default:
81 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
82 }
86 83
87 $pagerAdapter = new DoctrineORMAdapter($qb->getQuery()); 84 $pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
88 $entries = new Pagerfanta($pagerAdapter); 85 $entries = new Pagerfanta($pagerAdapter);
@@ -91,7 +88,7 @@ class RssController extends Controller
91 $entries->setMaxPerPage($perPage); 88 $entries->setMaxPerPage($perPage);
92 89
93 return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array( 90 return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array(
94 'type' => 'starred', 91 'type' => $type,
95 'entries' => $entries, 92 'entries' => $entries,
96 )); 93 ));
97 } 94 }
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
28 array() 28 array()
29 ); 29 );
30 } 30 }
31
32 /**
33 * @Route("/", name="homepage")
34 */
35 public function apiAction()
36 {
37 return $this->redirect($this->generateUrl('nelmio_api_doc_index'));
38 }
39} 31}
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,10 +4,60 @@ namespace Wallabag\CoreBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\CoreBundle\Form\Type\NewTagType;
9use Wallabag\CoreBundle\Entity\Tag;
10use Wallabag\CoreBundle\Entity\Entry;
7 11
8class TagController extends Controller 12class TagController extends Controller
9{ 13{
10 /** 14 /**
15 * @param Request $request
16 *
17 * @Route("/new-tag/{entry}", requirements={"entry" = "\d+"}, name="new_tag")
18 *
19 * @return \Symfony\Component\HttpFoundation\Response
20 */
21 public function addTagFormAction(Request $request, Entry $entry)
22 {
23 $tag = new Tag($this->getUser());
24 $form = $this->createForm(new NewTagType(), $tag);
25 $form->handleRequest($request);
26
27 if ($form->isValid()) {
28 $existingTag = $this->getDoctrine()
29 ->getRepository('WallabagCoreBundle:Tag')
30 ->findOneByLabelAndUserId($tag->getLabel(), $this->getUser()->getId());
31
32 $em = $this->getDoctrine()->getManager();
33
34 if (is_null($existingTag)) {
35 $entry->addTag($tag);
36 $em->persist($tag);
37 } else {
38 if (!$existingTag->hasEntry($entry)) {
39 $entry->addTag($existingTag);
40 $em->persist($existingTag);
41 }
42 }
43
44 $em->flush();
45
46 $this->get('session')->getFlashBag()->add(
47 'notice',
48 'Tag added'
49 );
50
51 return $this->redirect($this->generateUrl('view', array('id' => $entry->getId())));
52 }
53
54 return $this->render('WallabagCoreBundle:Tag:new_form.html.twig', array(
55 'form' => $form->createView(),
56 'entry' => $entry,
57 ));
58 }
59
60 /**
11 * Shows tags for current user. 61 * Shows tags for current user.
12 * 62 *
13 * @Route("/tag/list", name="tag") 63 * @Route("/tag/list", name="tag")
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;
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; 10use Wallabag\CoreBundle\Tools\Utils;
11 11
12/** 12/**
13 * Entry. 13 * Entry.
@@ -265,7 +265,7 @@ class Entry
265 public function setContent($content) 265 public function setContent($content)
266 { 266 {
267 $this->content = $content; 267 $this->content = $content;
268 $this->readingTime = Tools::getReadingTime($content); 268 $this->readingTime = Utils::getReadingTime($content);
269 $this->domainName = parse_url($this->url, PHP_URL_HOST); 269 $this->domainName = parse_url($this->url, PHP_URL_HOST);
270 270
271 return $this; 271 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
96 $this->entries[] = $entry; 96 $this->entries[] = $entry;
97 } 97 }
98 98
99 public function hasEntry($entry)
100 {
101 return $this->entries->contains($entry);
102 }
103
99 /** 104 /**
100 * @return User 105 * @return User
101 */ 106 */
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
39 39
40 return $filterQuery->createCondition($expression); 40 return $filterQuery->createCondition($expression);
41 }, 41 },
42 )); 42 ))
43 ->add('isArchived', 'filter_checkbox')
44 ->add('isStarred', 'filter_checkbox');
43 } 45 }
44 46
45 public function getName() 47 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 @@
1<?php
2
3namespace Wallabag\CoreBundle\Form\Type;
4
5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\OptionsResolver\OptionsResolver;
8
9class NewTagType extends AbstractType
10{
11 public function buildForm(FormBuilderInterface $builder, array $options)
12 {
13 $builder
14 ->add('label', 'text', array('required' => true))
15 ->add('save', 'submit')
16 ;
17 }
18
19 public function configureOptions(OptionsResolver $resolver)
20 {
21 $resolver->setDefaults(array(
22 'data_class' => 'Wallabag\CoreBundle\Entity\Tag',
23 ));
24 }
25
26 public function getName()
27 {
28 return 'tag';
29 }
30}
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 @@
1<?php
2
3namespace Wallabag\CoreBundle\Helper;
4
5class Entry
6{
7}
diff --git a/src/Wallabag/CoreBundle/Helper/Tools.php b/src/Wallabag/CoreBundle/Helper/Tools.php
deleted file mode 100755
index d368ee71..00000000
--- a/src/Wallabag/CoreBundle/Helper/Tools.php
+++ /dev/null
@@ -1,133 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\Helper;
4
5final class Tools
6{
7 /**
8 * Download a file (typically, for downloading pictures on web server).
9 *
10 * @param $url
11 *
12 * @return bool|mixed|string
13 */
14 public static function getFile($url)
15 {
16 $timeout = 15;
17 $useragent = 'Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0';
18
19 if (in_array('curl', get_loaded_extensions())) {
20 # Fetch feed from URL
21 $curl = curl_init();
22 curl_setopt($curl, CURLOPT_URL, $url);
23 curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
24 if (!ini_get('open_basedir') && !ini_get('safe_mode')) {
25 curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
26 }
27 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
28 curl_setopt($curl, CURLOPT_HEADER, false);
29
30 # for ssl, do not verified certificate
31 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
32 curl_setopt($curl, CURLOPT_AUTOREFERER, true);
33
34 # FeedBurner requires a proper USER-AGENT...
35 curl_setopt($curl, CURL_HTTP_VERSION_1_1, true);
36 curl_setopt($curl, CURLOPT_ENCODING, 'gzip, deflate');
37 curl_setopt($curl, CURLOPT_USERAGENT, $useragent);
38
39 $data = curl_exec($curl);
40 $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
41 $httpcodeOK = isset($httpcode) and ($httpcode == 200 or $httpcode == 301);
42 curl_close($curl);
43 } else {
44 # create http context and add timeout and user-agent
45 $context = stream_context_create(
46 array(
47 'http' => array(
48 'timeout' => $timeout,
49 'header' => 'User-Agent: '.$useragent,
50 'follow_location' => true,
51 ),
52 'ssl' => array(
53 'verify_peer' => false,
54 'allow_self_signed' => true,
55 ),
56 )
57 );
58
59 # only download page lesser than 4MB
60 $data = @file_get_contents($url, false, $context, -1, 4000000);
61
62 if (isset($http_response_header) and isset($http_response_header[0])) {
63 $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));
64 }
65 }
66
67 # if response is not empty and response is OK
68 if (isset($data) and isset($httpcodeOK) and $httpcodeOK) {
69 # take charset of page and get it
70 preg_match('#<meta .*charset=.*>#Usi', $data, $meta);
71
72 # if meta tag is found
73 if (!empty($meta[0])) {
74 preg_match('#charset="?(.*)"#si', $meta[0], $encoding);
75 # if charset is found set it otherwise, set it to utf-8
76 $html_charset = (!empty($encoding[1])) ? strtolower($encoding[1]) : 'utf-8';
77 if (empty($encoding[1])) {
78 $encoding[1] = 'utf-8';
79 }
80 } else {
81 $html_charset = 'utf-8';
82 $encoding[1] = '';
83 }
84
85 # replace charset of url to charset of page
86 $data = str_replace('charset='.$encoding[1], 'charset='.$html_charset, $data);
87
88 return $data;
89 } else {
90 return false;
91 }
92 }
93
94 /**
95 * Encode a URL by using a salt.
96 *
97 * @param $string
98 *
99 * @return string
100 */
101 public static function encodeString($string)
102 {
103 return sha1($string.SALT);
104 }
105
106 public static function generateToken()
107 {
108 if (ini_get('open_basedir') === '') {
109 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
110 // alternative to /dev/urandom for Windows
111 $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
112 } else {
113 $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15);
114 }
115 } else {
116 $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
117 }
118
119 return str_replace('+', '', $token);
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 }
133}
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;
9class EntryRepository extends EntityRepository 9class EntryRepository extends EntityRepository
10{ 10{
11 /** 11 /**
12 * Retrieves unread entries for a user. 12 * Return a query builder to used by other getBuilderFor* method.
13 * 13 *
14 * @param int $userId 14 * @param int $userId
15 * 15 *
16 * @return QueryBuilder 16 * @return QueryBuilder
17 */ 17 */
18 public function findUnreadByUser($userId) 18 private function getBuilderByUser($userId)
19 { 19 {
20 return $this->createQueryBuilder('e') 20 return $this->createQueryBuilder('e')
21 ->leftJoin('e.user', 'u') 21 ->leftJoin('e.user', 'u')
22 ->where('e.isArchived = false') 22 ->andWhere('u.id = :userId')->setParameter('userId', $userId)
23 ->andWhere('u.id =:userId')->setParameter('userId', $userId) 23 ->orderBy('e.id', 'desc')
24 ->orderBy('e.id', 'desc'); 24 ;
25 }
26
27 /**
28 * Retrieves all entries for a user.
29 *
30 * @param int $userId
31 *
32 * @return QueryBuilder
33 */
34 public function getBuilderForAllByUser($userId)
35 {
36 return $this
37 ->getBuilderByUser($userId)
38 ;
39 }
40
41 /**
42 * Retrieves unread entries for a user.
43 *
44 * @param int $userId
45 *
46 * @return QueryBuilder
47 */
48 public function getBuilderForUnreadByUser($userId)
49 {
50 return $this
51 ->getBuilderByUser($userId)
52 ->andWhere('e.isArchived = false')
53 ;
25 } 54 }
26 55
27 /** 56 /**
@@ -31,13 +60,12 @@ class EntryRepository extends EntityRepository
31 * 60 *
32 * @return QueryBuilder 61 * @return QueryBuilder
33 */ 62 */
34 public function findArchiveByUser($userId) 63 public function getBuilderForArchiveByUser($userId)
35 { 64 {
36 return $this->createQueryBuilder('e') 65 return $this
37 ->leftJoin('e.user', 'u') 66 ->getBuilderByUser($userId)
38 ->where('e.isArchived = true') 67 ->andWhere('e.isArchived = true')
39 ->andWhere('u.id =:userId')->setParameter('userId', $userId) 68 ;
40 ->orderBy('e.id', 'desc');
41 } 69 }
42 70
43 /** 71 /**
@@ -47,13 +75,12 @@ class EntryRepository extends EntityRepository
47 * 75 *
48 * @return QueryBuilder 76 * @return QueryBuilder
49 */ 77 */
50 public function findStarredByUser($userId) 78 public function getBuilderForStarredByUser($userId)
51 { 79 {
52 return $this->createQueryBuilder('e') 80 return $this
53 ->leftJoin('e.user', 'u') 81 ->getBuilderByUser($userId)
54 ->where('e.isStarred = true') 82 ->andWhere('e.isStarred = true')
55 ->andWhere('u.id =:userId')->setParameter('userId', $userId) 83 ;
56 ->orderBy('e.id', 'desc');
57 } 84 }
58 85
59 /** 86 /**
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
24 24
25 return new Pagerfanta($pagerAdapter); 25 return new Pagerfanta($pagerAdapter);
26 } 26 }
27
28 /**
29 * Find a tag by its label and its owner.
30 *
31 * @param string $label
32 * @param int $userId
33 *
34 * @return Tag|null
35 */
36 public function findOneByLabelAndUserId($label, $userId)
37 {
38 return $this->createQueryBuilder('t')
39 ->where('t.label = :label')->setParameter('label', $label)
40 ->andWhere('t.user = :user_id')->setParameter('user_id', $userId)
41 ->getQuery()
42 ->getOneOrNullResult();
43 }
27} 44}
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 @@
1entry:
2 resource: "@WallabagCoreBundle/Controller/EntryController.php"
3 type: annotation
4
5config:
6 resource: "@WallabagCoreBundle/Controller/ConfigController.php"
7 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 @@
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 <div><form action="{{ path('all') }}">{{ form_rest(form) }}<button class="btn waves-effect waves-light" type="submit" id="submit-filter" value="filter">Filter</button></form></div>
25 {% for entry in entries %} 25 {% for entry in entries %}
26 <div id="entry-{{ entry.id|e }}" class="entry"> 26 <div id="entry-{{ entry.id|e }}" class="entry">
27 <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>
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 @@
28 <h1>{{ entry.title|raw }} <a href="{{ path('edit', { 'id': entry.id }) }}" title="{% trans %}Edit tags{% endtrans %}">✎</a></h1> 28 <h1>{{ entry.title|raw }} <a href="{{ path('edit', { 'id': entry.id }) }}" title="{% trans %}Edit tags{% endtrans %}">✎</a></h1>
29 </header> 29 </header>
30 <aside class="tags"> 30 <aside class="tags">
31 tags: {% for tag in entry.tags %}<a href="./?view=tag&amp;id={{ tag.id }}">{{ tag.label }}</a> {% endfor %}<a href="./?view=edit-tags&amp;id={{ entry.id }}" title="{% trans %}Edit tags{% endtrans %}">✎</a> 31 {% for tag in entry.tags %}<span class="mdi-action-label-outline">{{ tag.label }}</span>{% endfor %}
32 {{ render(controller( "WallabagCoreBundle:Tag:addTagForm", { 'id': entry.id } )) }}
32 </aside> 33 </aside>
33 <article> 34 <article>
34 {{ entry.content | raw }} 35 {{ 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 @@
3{% block title %}{% trans %}About{% endtrans %}{% endblock %} 3{% block title %}{% trans %}About{% endtrans %}{% endblock %}
4 4
5{% block content %} 5{% block content %}
6 <h2>{% trans %}About wallabag{% endtrans %}</h2> 6 <h2>{% trans %}Who is behind wallabag{% endtrans %}</h2>
7 7
8 <dl> 8 <dl>
9 <dt>{% trans %}Project website{% endtrans %}</dt> 9 <dt>{% trans %}Developed by{% endtrans %}</dt>
10 <dd><a href="https://www.wallabag.org">https://www.wallabag.org</a></dd>
11
12 <dt>{% trans %}Main developer{% endtrans %}</dt>
13 <dd><a href="mailto:nicolas@loeuillet.org">Nicolas Lœuillet</a> — <a href="http://cdetc.fr">{% trans %}website{% endtrans %}</a></dd> 10 <dd><a href="mailto:nicolas@loeuillet.org">Nicolas Lœuillet</a> — <a href="http://cdetc.fr">{% trans %}website{% endtrans %}</a></dd>
11 <dd>Thomas Citharel — <a href="https://tcit.fr">{% trans %}website{% endtrans %}</a></dd>
12 <dd>Jérémy Benoist — <a href="http://www.j0k3r.net">{% trans %}website{% endtrans %}</a></dd>
14 13
15 <dt>{% trans %}Contributors ♥:{% endtrans %}</dt> 14 <dt>{% trans %}And many others contributors ♥{% endtrans %} <a href="https://github.com/wallabag/wallabag/graphs/contributors">{% trans %}on Github{% endtrans %}</a></dt>
16 <dd><a href="https://github.com/wallabag/wallabag/graphs/contributors">{% trans %}on Github{% endtrans %}</a></dd>
17 15
18 <dt>{% trans %}Bug reports{% endtrans %}</dt> 16 <dt>{% trans %}Project website{% endtrans %}</dt>
19 <dd><a href="https://support.wallabag.org">{% trans %}On our support website{% endtrans %}</a> {% trans %}or{% endtrans %} <a href="https://github.com/wallabag/wallabag/issues">{% trans %}on Github{% endtrans %}</a></dd> 17 <dd><a href="https://www.wallabag.org">https://www.wallabag.org</a></dd>
20 18
21 <dt>{% trans %}License{% endtrans %}</dt> 19 <dt>{% trans %}License{% endtrans %}: <a href="http://en.wikipedia.org/wiki/MIT_License">MIT</a></dt>
22 <dd><a href="http://en.wikipedia.org/wiki/MIT_License">MIT</a></dd>
23 20
24 <dt>{% trans %}Version{% endtrans %}</dt> 21 <dt>{% trans %}Version{% endtrans %}: {{ version }}</dt>
25 <dd>{{ version }}</dd>
26 </dl> 22 </dl>
27 23
28 <p>{% 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 %}</p>
29
30 <h2>{% trans %}Getting help{% endtrans %}</h2> 24 <h2>{% trans %}Getting help{% endtrans %}</h2>
31 25
32 <dl> 26 <dl>
33 <dt>{% trans %}Documentation{% endtrans %}</dt> 27 <dt>{% trans %}Documentation{% endtrans %}</dt>
34 <dd><a href="https://doc.wallabag.org/">Online documentation</a></dd> 28 <dd><a href="https://doc.wallabag.org/en">english</a></dd>
29 <dd><a href="https://doc.wallabag.org/fr">français</a></dd>
30 <dd><a href="https://doc.wallabag.org/de">deutsch</a></dd>
35 31
36 <dt>{% trans %}Support{% endtrans %}</dt> 32 <dt>{% trans %}Bug reports{% endtrans %}</dt>
37 <dd><a href="http://support.wallabag.org/">http://support.wallabag.org/</a></dd> 33 <dd><a href="https://support.wallabag.org">{% trans %}On our support website{% endtrans %}</a> {% trans %}or{% endtrans %} <a href="https://github.com/wallabag/wallabag/issues">{% trans %}on Github{% endtrans %}</a></dd>
38 </dl> 34 </dl>
39 35
40 <h2>{% trans %}Helping wallabag{% endtrans %}</h2> 36 <h2>{% trans %}Helping wallabag{% endtrans %}</h2>
@@ -42,8 +38,10 @@
42 <p>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</p> 38 <p>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</p>
43 39
44 <dl> 40 <dl>
45 <dt><a href="{{ paypal_url }}">{% trans %}via Paypal{% endtrans %}</a></dt> 41 <dt>{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}</dt>
42 <dd>by contributing to the project: <a href="https://github.com/wallabag/wallabag/issues/1254">an issue lists all our needs</a></dd>
43 <dd><a href="{{ paypal_url }}">{% trans %}via Paypal{% endtrans %}</a></dd>
46 44
47 <dt><a href="{{ flattr_url }}">{% trans %}via Flattr{% endtrans %}</a></dt> 45 <dd><a href="{{ flattr_url }}">{% trans %}via Flattr{% endtrans %}</a></dd>
48 </dl> 46 </dl>
49{% endblock %} 47{% 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 @@
1<form name="tag" method="post" action="{{ path('new_tag', { 'entry': entry.id })}}">
2
3 {% if form_errors(form) %}
4 <span class="black-text">{{ form_errors(form) }}</span>
5 {% endif %}
6
7 {% if form_errors(form.label) %}
8 <span class="black-text">{{ form_errors(form.label) }}</span>
9 {% endif %}
10
11 {{ form_widget(form.label, { 'attr': {'autocomplete': 'off'} }) }}
12 {{ form_widget(form.save, { 'attr': {'class': 'btn waves-effect waves-light'}, 'label': 'add tag' }) }}
13
14 <div class="hidden">{{ form_rest(form) }}</div>
15</form>
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 @@
71 <li><a href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li> 71 <li><a href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li>
72 <li><a href="{{ path('starred') }}">{% trans %}favorites{% endtrans %}</a></li> 72 <li><a href="{{ path('starred') }}">{% trans %}favorites{% endtrans %}</a></li>
73 <li><a href="{{ path('archive') }}"}>{% trans %}archive{% endtrans %}</a></li> 73 <li><a href="{{ path('archive') }}"}>{% trans %}archive{% endtrans %}</a></li>
74 <li><a href="{{ path('all') }}"}>{% trans %}all{% endtrans %}</a></li>
74 <li><a href="{{ path ('tag') }}">{% trans %}tags{% endtrans %}</a></li> 75 <li><a href="{{ path ('tag') }}">{% trans %}tags{% endtrans %}</a></li>
75 <li><a href="{{ path('new') }}">{% trans %}save a link{% endtrans %}</a></li> 76 <li><a href="{{ path('new') }}">{% trans %}save a link{% endtrans %}</a></li>
76 <li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a> 77 <li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a>
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 @@
7 {% trans %}Starred{% endtrans %} 7 {% trans %}Starred{% endtrans %}
8 {% elseif currentRoute == 'archive' %} 8 {% elseif currentRoute == 'archive' %}
9 {% trans %}Archive{% endtrans %} 9 {% trans %}Archive{% endtrans %}
10 {% elseif currentRoute == 'all' %}
11 {% trans %}Filtered{% endtrans %}
10 {% else %} 12 {% else %}
11 {% trans %}Unread{% endtrans %} 13 {% trans %}Unread{% endtrans %}
12 {% endif %} 14 {% endif %}
@@ -59,12 +61,26 @@
59 61
60 <!-- Filters --> 62 <!-- Filters -->
61 <div id="filters" class="side-nav fixed right-aligned"> 63 <div id="filters" class="side-nav fixed right-aligned">
62 <form> 64 <form action="{{ path('all') }}">
63 65
64 <h4 class="center">{% trans %}Filters{% endtrans %}</h1> 66 <h4 class="center">{% trans %}Filters{% endtrans %}</h1>
65 67
66 <div class="row"> 68 <div class="row">
67 69
70
71 <div class="col s12">
72 <label>{% trans %}Status{% endtrans %}</label>
73 </div>
74 <div class="input-field col s6">
75 {{ form_widget(form.isArchived) }}
76 <label for="entry_filter_isArchived">{% trans %}Archived{% endtrans %}</label>
77 </div>
78
79 <div class="input-field col s6">
80 {{ form_widget(form.isStarred) }}
81 <label for="entry_filter_isStarred">{% trans %}Starred{% endtrans %}</label>
82 </div>
83
68 <div class="col s12"> 84 <div class="col s12">
69 <label>{% trans %}Reading time in minutes{% endtrans %}</label> 85 <label>{% trans %}Reading time in minutes{% endtrans %}</label>
70 </div> 86 </div>
@@ -77,7 +93,6 @@
77 <label for="entry_filter_readingTime_right_number">{% trans %}to{% endtrans %}</label> 93 <label for="entry_filter_readingTime_right_number">{% trans %}to{% endtrans %}</label>
78 </div> 94 </div>
79 95
80
81 <div class="input-field col s6"> 96 <div class="input-field col s6">
82 {{ form_widget(form.domainName, {'type': 'text', 'attr' : {'placeholder': 'website.com'} }) }} 97 {{ form_widget(form.domainName, {'type': 'text', 'attr' : {'placeholder': 'website.com'} }) }}
83 <label for="entry_filter_domainName">{% trans %}Domain name{% endtrans %}</label> 98 <label for="entry_filter_domainName">{% trans %}Domain name{% endtrans %}</label>
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 {
137 <a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link"><span>{{ entry.domainName }}</span></a> 137 <a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link"><span>{{ entry.domainName }}</span></a>
138 </header> 138 </header>
139 <aside class="tags"> 139 <aside class="tags">
140 tags: {% for tag in entry.tags %}<a href="./?view=tag&amp;id={{ tag.id }}">{{ tag.label }}</a> {% endfor %}<a href="./?view=edit-tags&amp;id={{ entry.id }}" title="{% trans %}Edit tags{% endtrans %}">✎</a> 140 {% for tag in entry.tags %}<span class="mdi-action-label-outline">{{ tag.label }}</span>{% endfor %}
141 {{ render(controller( "WallabagCoreBundle:Tag:addTagForm", { 'id': entry.id } )) }}
141 </aside> 142 </aside>
142 <article> 143 <article>
143 {{ entry.content | raw }} 144 {{ 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 @@
21 <dt>{% trans %}Developed by{% endtrans %}</dt> 21 <dt>{% trans %}Developed by{% endtrans %}</dt>
22 <dd><a href="mailto:nicolas@loeuillet.org">Nicolas Lœuillet</a> — <a href="http://cdetc.fr">{% trans %}website{% endtrans %}</a></dd> 22 <dd><a href="mailto:nicolas@loeuillet.org">Nicolas Lœuillet</a> — <a href="http://cdetc.fr">{% trans %}website{% endtrans %}</a></dd>
23 <dd>Thomas Citharel — <a href="https://tcit.fr">{% trans %}website{% endtrans %}</a></dd> 23 <dd>Thomas Citharel — <a href="https://tcit.fr">{% trans %}website{% endtrans %}</a></dd>
24 <dd>Jérémy Besnoit — <a href="http://wildtrip.net">{% trans %}website{% endtrans %}</a></dd> 24 <dd>Jérémy Benoist — <a href="http://www.j0k3r.net">{% trans %}website{% endtrans %}</a></dd>
25 <dt>{% trans %}And many others contributors ♥{% endtrans %} <a href="https://github.com/wallabag/wallabag/graphs/contributors">{% trans %}on Github{% endtrans %}</a></dt> 25 <dt>{% trans %}And many others contributors ♥{% endtrans %} <a href="https://github.com/wallabag/wallabag/graphs/contributors">{% trans %}on Github{% endtrans %}</a></dt>
26 <dt>{% trans %}Project website{% endtrans %}</dt> 26 <dt>{% trans %}Project website{% endtrans %}</dt>
27 <dd><a href="https://www.wallabag.org">https://www.wallabag.org</a></dd> 27 <dd><a href="https://www.wallabag.org">https://www.wallabag.org</a></dd>
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 @@
1<form name="tag" method="post" action="{{ path('new_tag', { 'entry': entry.id })}}">
2
3 {% if form_errors(form) %}
4 <span class="black-text">{{ form_errors(form) }}</span>
5 {% endif %}
6
7 {% if form_errors(form.label) %}
8 <span class="black-text">{{ form_errors(form.label) }}</span>
9 {% endif %}
10
11 {{ form_widget(form.label, { 'attr': {'autocomplete': 'off'} }) }}
12 {{ form_widget(form.save, { 'attr': {'class': 'btn waves-effect waves-light'}, 'label': 'add tag' }) }}
13
14 <div class="hidden">{{ form_rest(form) }}</div>
15</form>
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 @@
42 <li class="bold {% if currentRoute == 'unread' or currentRoute == 'homepage' %}active{% endif %}"><a class="waves-effect" href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li> 42 <li class="bold {% if currentRoute == 'unread' or currentRoute == 'homepage' %}active{% endif %}"><a class="waves-effect" href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li>
43 <li class="bold {% if currentRoute == 'starred' %}active{% endif %}"><a class="waves-effect" href="{{ path('starred') }}">{% trans %}starred{% endtrans %}</a></li> 43 <li class="bold {% if currentRoute == 'starred' %}active{% endif %}"><a class="waves-effect" href="{{ path('starred') }}">{% trans %}starred{% endtrans %}</a></li>
44 <li class="bold {% if currentRoute == 'archive' %}active{% endif %}"><a class="waves-effect" href="{{ path('archive') }}">{% trans %}archive{% endtrans %}</a></li> 44 <li class="bold {% if currentRoute == 'archive' %}active{% endif %}"><a class="waves-effect" href="{{ path('archive') }}">{% trans %}archive{% endtrans %}</a></li>
45 <li class="bold {% if currentRoute == 'all' %}active{% endif %}"><a class="waves-effect" href="{{ path('all') }}">{% trans %}all{% endtrans %}</a></li>
45 <li class="bold border-bottom {% if currentRoute == 'tags' %}active{% endif %}"><a class="waves-effect" href="{{ path('tag') }}">{% trans %}tags{% endtrans %}</a></li> 46 <li class="bold border-bottom {% if currentRoute == 'tags' %}active{% endif %}"><a class="waves-effect" href="{{ path('tag') }}">{% trans %}tags{% endtrans %}</a></li>
46 <li class="bold {% if currentRoute == 'config' %}active{% endif %}"><a class="waves-effect" href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li> 47 <li class="bold {% if currentRoute == 'config' %}active{% endif %}"><a class="waves-effect" href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li>
47 <li class="bold {% if currentRoute == 'howto' %}active{% endif %}"><a class="waves-effect" href="{{ path('howto') }}">{% trans %}howto{% endtrans %}</a></li> 48 <li class="bold {% if currentRoute == 'howto' %}active{% endif %}"><a class="waves-effect" href="{{ path('howto') }}">{% trans %}howto{% endtrans %}</a></li>
@@ -55,9 +56,9 @@
55 </div> 56 </div>
56 <div class="input-field nav-panel-buttom"> 57 <div class="input-field nav-panel-buttom">
57 <ul> 58 <ul>
58 <li class="bold"><a class="waves-effect" href="{{ path('new') }}" id="nav-btn-add"><i class="mdi-content-add"></i></a></li> 59 <li class="bold"><a title="{% trans %}Add a new entry{% endtrans %}" class="waves-effect" href="{{ path('new') }}" id="nav-btn-add"><i class="mdi-content-add"></i></a></li>
59 <li><a class="waves-effect" href="javascript: void(null);" id="nav-btn-search"><i class="mdi-action-search"></i></a> 60 <li><a title="{% trans %}Search{% endtrans %}" class="waves-effect" href="javascript: void(null);" id="nav-btn-search"><i class="mdi-action-search"></i></a>
60 <li id="button_filters"><a href="#" data-activates="filters" class="nav-panel-menu button-collapse-right"><i class="mdi-content-filter-list"></i></a></li> 61 <li id="button_filters"><a title="{% trans %}Filter entries{% endtrans %}" href="#" data-activates="filters" class="nav-panel-menu button-collapse-right"><i class="mdi-content-filter-list"></i></a></li>
61 </ul> 62 </ul>
62 </div> 63 </div>
63 <form method="get" action="index.php"> 64 <form method="get" action="index.php">
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() {
5 $('.button-collapse-right').sideNav({ edge: 'right' }); 5 $('.button-collapse-right').sideNav({ edge: 'right' });
6 $('#clear_form_filters').on('click', function(){ 6 $('#clear_form_filters').on('click', function(){
7 $('#filters input').val(''); 7 $('#filters input').val('');
8 $('#filters :checked').removeAttr('checked');
8 return false; 9 return false;
9 }); 10 });
10 } 11 }
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
276 276
277 $crawler = $client->submit($form, $data); 277 $crawler = $client->submit($form, $data);
278 278
279 $this->assertCount(4, $crawler->filter('div[class=entry]')); 279 $this->assertCount(5, $crawler->filter('div[class=entry]'));
280 280
281 $data = array( 281 $data = array(
282 'entry_filter[createdAt][left_date]' => '01/01/1970', 282 'entry_filter[createdAt][left_date]' => '01/01/1970',
@@ -307,6 +307,14 @@ class EntryControllerTest extends WallabagCoreTestCase
307 $crawler = $client->request('GET', 'unread/list'.$parameters); 307 $crawler = $client->request('GET', 'unread/list'.$parameters);
308 308
309 $this->assertContains($parameters, $client->getResponse()->getContent()); 309 $this->assertContains($parameters, $client->getResponse()->getContent());
310
311 // reset pagination
312 $crawler = $client->request('GET', '/config');
313 $form = $crawler->filter('button[id=config_save]')->form();
314 $data = array(
315 'config[items_per_page]' => '12',
316 );
317 $client->submit($form, $data);
310 } 318 }
311 319
312 public function testFilterOnDomainName() 320 public function testFilterOnDomainName()
@@ -331,4 +339,25 @@ class EntryControllerTest extends WallabagCoreTestCase
331 $crawler = $client->submit($form, $data); 339 $crawler = $client->submit($form, $data);
332 $this->assertCount(0, $crawler->filter('div[class=entry]')); 340 $this->assertCount(0, $crawler->filter('div[class=entry]'));
333 } 341 }
342
343 public function testFilterOnStatus()
344 {
345 $this->logInAs('admin');
346 $client = $this->getClient();
347
348 $crawler = $client->request('GET', '/unread/list');
349 $form = $crawler->filter('button[id=submit-filter]')->form();
350 $form['entry_filter[isArchived]']->tick();
351 $form['entry_filter[isStarred]']->untick();
352
353 $crawler = $client->submit($form);
354 $this->assertCount(1, $crawler->filter('div[class=entry]'));
355
356 $form = $crawler->filter('button[id=submit-filter]')->form();
357 $form['entry_filter[isArchived]']->untick();
358 $form['entry_filter[isStarred]']->tick();
359
360 $crawler = $client->submit($form);
361 $this->assertCount(1, $crawler->filter('div[class=entry]'));
362 }
334} 363}
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
15 15
16 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 16 $this->assertEquals(200, $client->getResponse()->getStatusCode());
17 } 17 }
18
19 public function testAddTagToEntry()
20 {
21 $this->logInAs('admin');
22 $client = $this->getClient();
23
24 $entry = $client->getContainer()
25 ->get('doctrine.orm.entity_manager')
26 ->getRepository('WallabagCoreBundle:Entry')
27 ->findOneByIsArchived(false);
28
29 $crawler = $client->request('GET', '/view/'.$entry->getId());
30
31 $form = $crawler->filter('button[id=tag_save]')->form();
32
33 $data = array(
34 'tag[label]' => 'opensource',
35 );
36
37 $client->submit($form, $data);
38 $this->assertEquals(302, $client->getResponse()->getStatusCode());
39
40 $this->assertEquals(1, count($entry->getTags()));
41
42 # tag already exists and already assigned
43 $client->submit($form, $data);
44 $this->assertEquals(302, $client->getResponse()->getStatusCode());
45
46 $newEntry = $client->getContainer()
47 ->get('doctrine.orm.entity_manager')
48 ->getRepository('WallabagCoreBundle:Entry')
49 ->findOneById($entry->getId());
50
51 $this->assertEquals(1, count($newEntry->getTags()));
52
53 # tag already exists but still not assigned to this entry
54 $data = array(
55 'tag[label]' => 'foo',
56 );
57
58 $client->submit($form, $data);
59 $this->assertEquals(302, $client->getResponse()->getStatusCode());
60
61 $newEntry = $client->getContainer()
62 ->get('doctrine.orm.entity_manager')
63 ->getRepository('WallabagCoreBundle:Entry')
64 ->findOneById($entry->getId());
65
66 $this->assertEquals(2, count($newEntry->getTags()));
67 }
18} 68}
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
25 // remove character which can broken the url 25 // remove character which can broken the url
26 return str_replace(array('+', '/'), '', $token); 26 return str_replace(array('+', '/'), '', $token);
27 } 27 }
28
29 /**
30 * For a given text, we calculate reading time for an article
31 * based on 200 words per minute.
32 *
33 * @param $text
34 *
35 * @return float
36 */
37 public static function getReadingTime($text)
38 {
39 return floor(str_word_count(strip_tags($text)) / 200);
40 }
28} 41}