diff options
Diffstat (limited to 'src')
14 files changed, 180 insertions, 290 deletions
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..dc399b8a 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -113,34 +113,7 @@ class EntryController extends Controller | |||
113 | */ | 113 | */ |
114 | public function showUnreadAction(Request $request, $page) | 114 | public function showUnreadAction(Request $request, $page) |
115 | { | 115 | { |
116 | $form = $this->get('form.factory')->create(new EntryFilterType()); | 116 | 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 | } | 117 | } |
145 | 118 | ||
146 | /** | 119 | /** |
@@ -155,21 +128,66 @@ class EntryController extends Controller | |||
155 | */ | 128 | */ |
156 | public function showArchiveAction(Request $request, $page) | 129 | public function showArchiveAction(Request $request, $page) |
157 | { | 130 | { |
158 | $form = $this->get('form.factory')->create(new EntryFilterType()); | 131 | return $this->showEntries('archive', $request, $page); |
132 | } | ||
133 | |||
134 | /** | ||
135 | * Shows starred entries for current user. | ||
136 | * | ||
137 | * @param Request $request | ||
138 | * @param int $page | ||
139 | * | ||
140 | * @Route("/starred/list/{page}", name="starred", defaults={"page" = "1"}) | ||
141 | * | ||
142 | * @return \Symfony\Component\HttpFoundation\Response | ||
143 | */ | ||
144 | public function showStarredAction(Request $request, $page) | ||
145 | { | ||
146 | return $this->showEntries('starred', $request, $page); | ||
147 | } | ||
159 | 148 | ||
160 | $filterBuilder = $this->getDoctrine() | 149 | /** |
161 | ->getRepository('WallabagCoreBundle:Entry') | 150 | * Global method to retrieve entries depending on the given type |
162 | ->findArchiveByUser($this->getUser()->getId()); | 151 | * It returns the response to be send. |
152 | * | ||
153 | * @param string $type Entries type: unread, starred or archive | ||
154 | * @param Request $request | ||
155 | * @param int $page | ||
156 | * | ||
157 | * @return \Symfony\Component\HttpFoundation\Response | ||
158 | */ | ||
159 | private function showEntries($type, Request $request, $page) | ||
160 | { | ||
161 | $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry'); | ||
162 | |||
163 | switch ($type) { | ||
164 | case 'starred': | ||
165 | $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId()); | ||
166 | break; | ||
167 | |||
168 | case 'archive': | ||
169 | $qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId()); | ||
170 | break; | ||
171 | |||
172 | case 'unread': | ||
173 | $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId()); | ||
174 | break; | ||
175 | |||
176 | default: | ||
177 | throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); | ||
178 | } | ||
179 | |||
180 | $form = $this->get('form.factory')->create(new EntryFilterType()); | ||
163 | 181 | ||
164 | if ($request->query->has($form->getName())) { | 182 | if ($request->query->has($form->getName())) { |
165 | // manually bind values from the request | 183 | // manually bind values from the request |
166 | $form->submit($request->query->get($form->getName())); | 184 | $form->submit($request->query->get($form->getName())); |
167 | 185 | ||
168 | // build the query from the given form object | 186 | // build the query from the given form object |
169 | $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder); | 187 | $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb); |
170 | } | 188 | } |
171 | 189 | ||
172 | $pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery()); | 190 | $pagerAdapter = new DoctrineORMAdapter($qb->getQuery()); |
173 | $entries = new Pagerfanta($pagerAdapter); | 191 | $entries = new Pagerfanta($pagerAdapter); |
174 | 192 | ||
175 | $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); | 193 | $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); |
@@ -183,25 +201,6 @@ class EntryController extends Controller | |||
183 | 'currentPage' => $page, | 201 | 'currentPage' => $page, |
184 | ) | 202 | ) |
185 | ); | 203 | ); |
186 | } | ||
187 | |||
188 | /** | ||
189 | * Shows starred entries for current user. | ||
190 | * | ||
191 | * @param Request $request | ||
192 | * @param int $page | ||
193 | * | ||
194 | * @Route("/starred/list/{page}", name="starred", defaults={"page" = "1"}) | ||
195 | * | ||
196 | * @return \Symfony\Component\HttpFoundation\Response | ||
197 | */ | ||
198 | public function showStarredAction(Request $request, $page) | ||
199 | { | ||
200 | $form = $this->get('form.factory')->create(new EntryFilterType()); | ||
201 | |||
202 | $filterBuilder = $this->getDoctrine() | ||
203 | ->getRepository('WallabagCoreBundle:Entry') | ||
204 | ->findStarredByUser($this->getUser()->getId()); | ||
205 | 204 | ||
206 | if ($request->query->has($form->getName())) { | 205 | if ($request->query->has($form->getName())) { |
207 | // manually bind values from the request | 206 | // manually bind values from the request |
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/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; | |||
7 | use Symfony\Component\Validator\Constraints as Assert; | 7 | use Symfony\Component\Validator\Constraints as Assert; |
8 | use Hateoas\Configuration\Annotation as Hateoas; | 8 | use Hateoas\Configuration\Annotation as Hateoas; |
9 | use JMS\Serializer\Annotation\XmlRoot; | 9 | use JMS\Serializer\Annotation\XmlRoot; |
10 | use Wallabag\CoreBundle\Helper\Tools; | 10 | use 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/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 | |||
3 | namespace Wallabag\CoreBundle\Helper; | ||
4 | |||
5 | class 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 | |||
3 | namespace Wallabag\CoreBundle\Helper; | ||
4 | |||
5 | final 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..5538ae82 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -9,19 +9,34 @@ use Pagerfanta\Pagerfanta; | |||
9 | class EntryRepository extends EntityRepository | 9 | class 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 unread entries for a user. | ||
29 | * | ||
30 | * @param int $userId | ||
31 | * | ||
32 | * @return QueryBuilder | ||
33 | */ | ||
34 | public function getBuilderForUnreadByUser($userId) | ||
35 | { | ||
36 | return $this | ||
37 | ->getBuilderByUser($userId) | ||
38 | ->andWhere('e.isArchived = false') | ||
39 | ; | ||
25 | } | 40 | } |
26 | 41 | ||
27 | /** | 42 | /** |
@@ -31,13 +46,12 @@ class EntryRepository extends EntityRepository | |||
31 | * | 46 | * |
32 | * @return QueryBuilder | 47 | * @return QueryBuilder |
33 | */ | 48 | */ |
34 | public function findArchiveByUser($userId) | 49 | public function getBuilderForArchiveByUser($userId) |
35 | { | 50 | { |
36 | return $this->createQueryBuilder('e') | 51 | return $this |
37 | ->leftJoin('e.user', 'u') | 52 | ->getBuilderByUser($userId) |
38 | ->where('e.isArchived = true') | 53 | ->andWhere('e.isArchived = true') |
39 | ->andWhere('u.id =:userId')->setParameter('userId', $userId) | 54 | ; |
40 | ->orderBy('e.id', 'desc'); | ||
41 | } | 55 | } |
42 | 56 | ||
43 | /** | 57 | /** |
@@ -47,13 +61,12 @@ class EntryRepository extends EntityRepository | |||
47 | * | 61 | * |
48 | * @return QueryBuilder | 62 | * @return QueryBuilder |
49 | */ | 63 | */ |
50 | public function findStarredByUser($userId) | 64 | public function getBuilderForStarredByUser($userId) |
51 | { | 65 | { |
52 | return $this->createQueryBuilder('e') | 66 | return $this |
53 | ->leftJoin('e.user', 'u') | 67 | ->getBuilderByUser($userId) |
54 | ->where('e.isStarred = true') | 68 | ->andWhere('e.isStarred = true') |
55 | ->andWhere('u.id =:userId')->setParameter('userId', $userId) | 69 | ; |
56 | ->orderBy('e.id', 'desc'); | ||
57 | } | 70 | } |
58 | 71 | ||
59 | /** | 72 | /** |
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 @@ | |||
1 | entry: | ||
2 | resource: "@WallabagCoreBundle/Controller/EntryController.php" | ||
3 | type: annotation | ||
4 | |||
5 | config: | ||
6 | resource: "@WallabagCoreBundle/Controller/ConfigController.php" | ||
7 | type: annotation | ||
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/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig index e27aceae..ac5d2bf9 100644 --- a/src/Wallabag/CoreBundle/Resources/views/base.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig | |||
@@ -71,7 +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 ('tag') }}">{% trans %}tags{% endtrans %}</a></li> | 74 | <li><a href="{{ path('tag') }}">{% trans %}tags{% endtrans %}</a></li> |
75 | <li><a href="{{ path('new') }}">{% trans %}save a link{% endtrans %}</a></li> | 75 | <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> | 76 | <li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a> |
77 | <div id="search-form" class="messages info popup-form"> | 77 | <div id="search-form" class="messages info popup-form"> |
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/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig index 554865d7..1456d5dd 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig | |||
@@ -55,9 +55,9 @@ | |||
55 | </div> | 55 | </div> |
56 | <div class="input-field nav-panel-buttom"> | 56 | <div class="input-field nav-panel-buttom"> |
57 | <ul> | 57 | <ul> |
58 | <li class="bold"><a class="waves-effect" href="{{ path('new') }}" id="nav-btn-add"><i class="mdi-content-add"></i></a></li> | 58 | <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> | 59 | <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> | 60 | <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> | 61 | </ul> |
62 | </div> | 62 | </div> |
63 | <form method="get" action="index.php"> | 63 | <form method="get" action="index.php"> |
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 | } |