aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/config/routing.yml12
-rw-r--r--src/Wallabag/ApiBundle/Controller/WallabagRestController.php4
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php42
-rw-r--r--src/Wallabag/CoreBundle/Controller/RssController.php21
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php38
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig4
-rwxr-xr-xsrc/Wallabag/CoreBundle/Resources/views/themes/baggy/public/css/main.css10
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php4
8 files changed, 76 insertions, 59 deletions
diff --git a/app/config/routing.yml b/app/config/routing.yml
index 8710e97f..e8bf08a5 100644
--- a/app/config/routing.yml
+++ b/app/config/routing.yml
@@ -6,10 +6,6 @@ app:
6 resource: @WallabagCoreBundle/Controller/ 6 resource: @WallabagCoreBundle/Controller/
7 type: annotation 7 type: annotation
8 8
9homepage:
10 pattern: /
11 defaults: { _controller: WallabagCoreBundle:Entry:showUnread }
12
13doc-api: 9doc-api:
14 resource: "@NelmioApiDocBundle/Resources/config/routing.yml" 10 resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
15 prefix: /api/doc 11 prefix: /api/doc
@@ -17,8 +13,10 @@ doc-api:
17login: 13login:
18 pattern: /login 14 pattern: /login
19 defaults: { _controller: WallabagCoreBundle:Security:login } 15 defaults: { _controller: WallabagCoreBundle:Security:login }
16
20login_check: 17login_check:
21 pattern: /login_check 18 pattern: /login_check
19
22logout: 20logout:
23 path: /logout 21 path: /logout
24 22
@@ -26,3 +24,9 @@ rest :
26 type : rest 24 type : rest
27 resource : "routing_rest.yml" 25 resource : "routing_rest.yml"
28 prefix : /api 26 prefix : /api
27
28homepage:
29 pattern: "/{page}"
30 defaults: { _controller: WallabagCoreBundle:Entry:showUnread, page : 1 }
31 requirements:
32 page: \d+
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
index 2f5923c8..692a4ae0 100644
--- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
@@ -189,8 +189,8 @@ class WallabagRestController extends Controller
189 $this->validateUserAccess($entry->getUser()->getId(), $this->getUser()->getId()); 189 $this->validateUserAccess($entry->getUser()->getId(), $this->getUser()->getId());
190 190
191 $title = $request->request->get('title'); 191 $title = $request->request->get('title');
192 $isArchived = $request->request->get('archive'); 192 $isArchived = $request->request->get('is_archived');
193 $isStarred = $request->request->get('star'); 193 $isStarred = $request->request->get('is_starred');
194 194
195 if (!is_null($title)) { 195 if (!is_null($title)) {
196 $entry->setTitle($title); 196 $entry->setTitle($title);
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index 4a7a0644..49714d02 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -89,60 +89,72 @@ class EntryController extends Controller
89 /** 89 /**
90 * Shows unread entries for current user. 90 * Shows unread entries for current user.
91 * 91 *
92 * @Route("/unread", name="unread") 92 * @Route("/unread/list/{page}", name="unread", defaults={"page" = "1"})
93 * 93 *
94 * @return \Symfony\Component\HttpFoundation\Response 94 * @return \Symfony\Component\HttpFoundation\Response
95 */ 95 */
96 public function showUnreadAction() 96 public function showUnreadAction($page)
97 { 97 {
98 // TODO change pagination
99 $entries = $this->getDoctrine() 98 $entries = $this->getDoctrine()
100 ->getRepository('WallabagCoreBundle:Entry') 99 ->getRepository('WallabagCoreBundle:Entry')
101 ->findUnreadByUser($this->getUser()->getId(), 0); 100 ->findUnreadByUser($this->getUser()->getId());
101
102 $entries->setCurrentPage($page);
102 103
103 return $this->render( 104 return $this->render(
104 'WallabagCoreBundle:Entry:entries.html.twig', 105 'WallabagCoreBundle:Entry:entries.html.twig',
105 array('entries' => $entries) 106 array(
107 'entries' => $entries,
108 'currentPage' => $page
109 )
106 ); 110 );
107 } 111 }
108 112
109 /** 113 /**
110 * Shows read entries for current user. 114 * Shows read entries for current user.
111 * 115 *
112 * @Route("/archive", name="archive") 116 * @Route("/archive/list/{page}", name="archive", defaults={"page" = "1"})
113 * 117 *
114 * @return \Symfony\Component\HttpFoundation\Response 118 * @return \Symfony\Component\HttpFoundation\Response
115 */ 119 */
116 public function showArchiveAction() 120 public function showArchiveAction($page)
117 { 121 {
118 // TODO change pagination
119 $entries = $this->getDoctrine() 122 $entries = $this->getDoctrine()
120 ->getRepository('WallabagCoreBundle:Entry') 123 ->getRepository('WallabagCoreBundle:Entry')
121 ->findArchiveByUser($this->getUser()->getId(), 0); 124 ->findArchiveByUser($this->getUser()->getId());
125
126 $entries->setCurrentPage($page);
122 127
123 return $this->render( 128 return $this->render(
124 'WallabagCoreBundle:Entry:entries.html.twig', 129 'WallabagCoreBundle:Entry:entries.html.twig',
125 array('entries' => $entries) 130 array(
131 'entries' => $entries,
132 'currentPage' => $page
133 )
126 ); 134 );
127 } 135 }
128 136
129 /** 137 /**
130 * Shows starred entries for current user. 138 * Shows starred entries for current user.
131 * 139 *
132 * @Route("/starred", name="starred") 140 * @Route("/starred/list/{page}", name="starred", defaults={"page" = "1"})
133 * 141 *
134 * @return \Symfony\Component\HttpFoundation\Response 142 * @return \Symfony\Component\HttpFoundation\Response
135 */ 143 */
136 public function showStarredAction() 144 public function showStarredAction($page)
137 { 145 {
138 // TODO change pagination
139 $entries = $this->getDoctrine() 146 $entries = $this->getDoctrine()
140 ->getRepository('WallabagCoreBundle:Entry') 147 ->getRepository('WallabagCoreBundle:Entry')
141 ->findStarredByUser($this->getUser()->getId(), 0); 148 ->findStarredByUser($this->getUser()->getId());
149
150 $entries->setCurrentPage($page);
142 151
143 return $this->render( 152 return $this->render(
144 'WallabagCoreBundle:Entry:entries.html.twig', 153 'WallabagCoreBundle:Entry:entries.html.twig',
145 array('entries' => $entries) 154 array(
155 'entries' => $entries,
156 'currentPage' => $page
157 )
146 ); 158 );
147 } 159 }
148 160
diff --git a/src/Wallabag/CoreBundle/Controller/RssController.php b/src/Wallabag/CoreBundle/Controller/RssController.php
index 86754e15..8428dce0 100644
--- a/src/Wallabag/CoreBundle/Controller/RssController.php
+++ b/src/Wallabag/CoreBundle/Controller/RssController.php
@@ -23,11 +23,12 @@ class RssController extends Controller
23 $entries = $this->getDoctrine() 23 $entries = $this->getDoctrine()
24 ->getRepository('WallabagCoreBundle:Entry') 24 ->getRepository('WallabagCoreBundle:Entry')
25 ->findUnreadByUser( 25 ->findUnreadByUser(
26 $user->getId(), 26 $user->getId()
27 0,
28 $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit')
29 ); 27 );
30 28
29 $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit');
30 $entries->setMaxPerPage($perPage);
31
31 return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array( 32 return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array(
32 'type' => 'unread', 33 'type' => 'unread',
33 'entries' => $entries, 34 'entries' => $entries,
@@ -47,11 +48,12 @@ class RssController extends Controller
47 $entries = $this->getDoctrine() 48 $entries = $this->getDoctrine()
48 ->getRepository('WallabagCoreBundle:Entry') 49 ->getRepository('WallabagCoreBundle:Entry')
49 ->findArchiveByUser( 50 ->findArchiveByUser(
50 $user->getId(), 51 $user->getId()
51 0,
52 $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit')
53 ); 52 );
54 53
54 $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit');
55 $entries->setMaxPerPage($perPage);
56
55 return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array( 57 return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array(
56 'type' => 'archive', 58 'type' => 'archive',
57 'entries' => $entries, 59 'entries' => $entries,
@@ -71,11 +73,12 @@ class RssController extends Controller
71 $entries = $this->getDoctrine() 73 $entries = $this->getDoctrine()
72 ->getRepository('WallabagCoreBundle:Entry') 74 ->getRepository('WallabagCoreBundle:Entry')
73 ->findStarredByUser( 75 ->findStarredByUser(
74 $user->getId(), 76 $user->getId()
75 0,
76 $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit')
77 ); 77 );
78 78
79 $perPage = $user->getConfig()->getRssLimit() ?: $this->container->getParameter('rss_limit');
80 $entries->setMaxPerPage($perPage);
81
79 return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array( 82 return $this->render('WallabagCoreBundle:Entry:entries.xml.twig', array(
80 'type' => 'starred', 83 'type' => 'starred',
81 'entries' => $entries, 84 'entries' => $entries,
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 1335e808..a4514d9e 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -3,7 +3,6 @@
3namespace Wallabag\CoreBundle\Repository; 3namespace Wallabag\CoreBundle\Repository;
4 4
5use Doctrine\ORM\EntityRepository; 5use Doctrine\ORM\EntityRepository;
6use Doctrine\ORM\Tools\Pagination\Paginator;
7use Pagerfanta\Adapter\DoctrineORMAdapter; 6use Pagerfanta\Adapter\DoctrineORMAdapter;
8use Pagerfanta\Pagerfanta; 7use Pagerfanta\Pagerfanta;
9 8
@@ -13,77 +12,66 @@ class EntryRepository extends EntityRepository
13 * Retrieves unread entries for a user. 12 * Retrieves unread entries for a user.
14 * 13 *
15 * @param int $userId 14 * @param int $userId
16 * @param int $firstResult
17 * @param int $maxResults
18 * 15 *
19 * @return Paginator 16 * @return Pagerfanta
20 */ 17 */
21 public function findUnreadByUser($userId, $firstResult, $maxResults = 12) 18 public function findUnreadByUser($userId)
22 { 19 {
23 $qb = $this->createQueryBuilder('e') 20 $qb = $this->createQueryBuilder('e')
24 ->setFirstResult($firstResult)
25 ->setMaxResults($maxResults)
26 ->leftJoin('e.user', 'u') 21 ->leftJoin('e.user', 'u')
27 ->where('e.isArchived = false') 22 ->where('e.isArchived = false')
28 ->andWhere('u.id =:userId')->setParameter('userId', $userId) 23 ->andWhere('u.id =:userId')->setParameter('userId', $userId)
29 ->orderBy('e.id', 'desc') 24 ->orderBy('e.id', 'desc')
30 ->getQuery(); 25 ->getQuery();
31 26
32 $paginator = new Paginator($qb); 27 $pagerAdapter = new DoctrineORMAdapter($qb);
33 28
34 return $paginator; 29 return new Pagerfanta($pagerAdapter);
35 } 30 }
36 31
37 /** 32 /**
38 * Retrieves read entries for a user. 33 * Retrieves read entries for a user.
39 * 34 *
40 * @param int $userId 35 * @param int $userId
41 * @param int $firstResult
42 * @param int $maxResults
43 * 36 *
44 * @return Paginator 37 * @return Pagerfanta
45 */ 38 */
46 public function findArchiveByUser($userId, $firstResult, $maxResults = 12) 39 public function findArchiveByUser($userId)
47 { 40 {
48 $qb = $this->createQueryBuilder('e') 41 $qb = $this->createQueryBuilder('e')
49 ->select('e') 42 ->select('e')
50 ->setFirstResult($firstResult)
51 ->setMaxResults($maxResults)
52 ->leftJoin('e.user', 'u') 43 ->leftJoin('e.user', 'u')
53 ->where('e.isArchived = true') 44 ->where('e.isArchived = true')
54 ->andWhere('u.id =:userId')->setParameter('userId', $userId) 45 ->andWhere('u.id =:userId')->setParameter('userId', $userId)
55 ->orderBy('e.id', 'desc') 46 ->orderBy('e.id', 'desc')
56 ->getQuery(); 47 ->getQuery();
57 48
58 $paginator = new Paginator($qb); 49 $pagerAdapter = new DoctrineORMAdapter($qb);
59 50
60 return $paginator; 51 return new Pagerfanta($pagerAdapter);
61 } 52 }
62 53
63 /** 54 /**
64 * Retrieves starred entries for a user. 55 * Retrieves starred entries for a user.
65 * 56 *
66 * @param int $userId 57 * @param int $userId
67 * @param int $firstResult
68 * @param int $maxResults
69 * 58 *
70 * @return Paginator 59 * @return Pagerfanta
71 */ 60 */
72 public function findStarredByUser($userId, $firstResult, $maxResults = 12) 61 public function findStarredByUser($userId)
73 { 62 {
63
74 $qb = $this->createQueryBuilder('e') 64 $qb = $this->createQueryBuilder('e')
75 ->select('e') 65 ->select('e')
76 ->setFirstResult($firstResult)
77 ->setMaxResults($maxResults)
78 ->leftJoin('e.user', 'u') 66 ->leftJoin('e.user', 'u')
79 ->where('e.isStarred = true') 67 ->where('e.isStarred = true')
80 ->andWhere('u.id =:userId')->setParameter('userId', $userId) 68 ->andWhere('u.id =:userId')->setParameter('userId', $userId)
81 ->orderBy('e.id', 'desc') 69 ->orderBy('e.id', 'desc')
82 ->getQuery(); 70 ->getQuery();
83 71
84 $paginator = new Paginator($qb); 72 $pagerAdapter = new DoctrineORMAdapter($qb);
85 73
86 return $paginator; 74 return new Pagerfanta($pagerAdapter);
87 } 75 }
88 76
89 /** 77 /**
diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
index acb96420..bf3caf09 100644
--- a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
@@ -8,9 +8,9 @@
8 <div class="results"> 8 <div class="results">
9 <div class="nb-results">{{ entries.count }} {% trans %}entries{% endtrans %}</div> 9 <div class="nb-results">{{ entries.count }} {% trans %}entries{% endtrans %}</div>
10 <div class="pagination"> 10 <div class="pagination">
11 {% for p in range(1, entries.count) %} 11 {% for p in range(1, entries.nbPages) %}
12 <li> 12 <li>
13 <a href="{{ path(app.request.attributes.get('_route'), {'page': p}) }}">{{ p }}</a> 13 <a href="{{ path(app.request.attributes.get('_route'), {'page': p}) }}" class="{{ currentPage == p ? 'current':''}}" >{{ p }}</a>
14 </li> 14 </li>
15 {% endfor %} 15 {% endfor %}
16 </div> 16 </div>
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 ff1a36a1..e2844ccc 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
@@ -537,6 +537,16 @@ footer a {
537 display: none; 537 display: none;
538} 538}
539 539
540.pagination .current {
541 height: 25px;
542 padding: 4px 8px;
543 border: 1px solid #d5d5d5;
544 text-decoration: none;
545 font-weight: bold;
546 color: #000;
547 background-color: #ccc;
548}
549
540/* ========================================================================== 550/* ==========================================================================
541 2.1 = "save a link" related styles 551 2.1 = "save a link" related styles
542 ========================================================================== */ 552 ========================================================================== */
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index 904e2a5c..2cd50130 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -78,7 +78,7 @@ class EntryControllerTest extends WallabagCoreTestCase
78 $this->logInAs('admin'); 78 $this->logInAs('admin');
79 $client = $this->getClient(); 79 $client = $this->getClient();
80 80
81 $client->request('GET', '/archive'); 81 $client->request('GET', '/archive/list');
82 82
83 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 83 $this->assertEquals(200, $client->getResponse()->getStatusCode());
84 } 84 }
@@ -88,7 +88,7 @@ class EntryControllerTest extends WallabagCoreTestCase
88 $this->logInAs('admin'); 88 $this->logInAs('admin');
89 $client = $this->getClient(); 89 $client = $this->getClient();
90 90
91 $client->request('GET', '/starred'); 91 $client->request('GET', '/starred/list');
92 92
93 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 93 $this->assertEquals(200, $client->getResponse()->getStatusCode());
94 } 94 }