aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php (renamed from src/Wallabag/CommentBundle/Controller/WallabagCommentController.php)62
-rw-r--r--src/Wallabag/AnnotationBundle/DataFixtures/ORM/LoadAnnotationData.php45
-rw-r--r--src/Wallabag/AnnotationBundle/DependencyInjection/Configuration.php (renamed from src/Wallabag/CommentBundle/DependencyInjection/Configuration.php)4
-rw-r--r--src/Wallabag/AnnotationBundle/DependencyInjection/WallabagAnnotationExtension.php (renamed from src/Wallabag/CommentBundle/DependencyInjection/WallabagCommentExtension.php)4
-rw-r--r--src/Wallabag/AnnotationBundle/Entity/Annotation.php (renamed from src/Wallabag/CommentBundle/Entity/Comment.php)24
-rw-r--r--src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php91
-rw-r--r--src/Wallabag/AnnotationBundle/Resources/config/routing_annotations.yml4
-rw-r--r--src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php (renamed from src/Wallabag/CommentBundle/Tests/Controller/CommentControllerTest.php)50
-rw-r--r--src/Wallabag/AnnotationBundle/Tests/WallabagAnnotationTestCase.php (renamed from src/Wallabag/CommentBundle/Tests/WallabagCommentTestCase.php)4
-rw-r--r--src/Wallabag/AnnotationBundle/WallabagAnnotationBundle.php9
-rw-r--r--src/Wallabag/CommentBundle/DataFixtures/ORM/LoadCommentData.php45
-rw-r--r--src/Wallabag/CommentBundle/Repository/CommentRepository.php94
-rw-r--r--src/Wallabag/CommentBundle/Resources/config/routing_comments.yml4
-rw-r--r--src/Wallabag/CommentBundle/WallabagCommentBundle.php9
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php18
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig8
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig8
18 files changed, 241 insertions, 244 deletions
diff --git a/src/Wallabag/CommentBundle/Controller/WallabagCommentController.php b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php
index be11f226..5f981eb5 100644
--- a/src/Wallabag/CommentBundle/Controller/WallabagCommentController.php
+++ b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php
@@ -1,19 +1,19 @@
1<?php 1<?php
2 2
3namespace Wallabag\CommentBundle\Controller; 3namespace Wallabag\AnnotationBundle\Controller;
4 4
5use FOS\RestBundle\Controller\FOSRestController; 5use FOS\RestBundle\Controller\FOSRestController;
6use Nelmio\ApiDocBundle\Annotation\ApiDoc; 6use Nelmio\ApiDocBundle\Annotation\ApiDoc;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpFoundation\Response; 8use Symfony\Component\HttpFoundation\Response;
9use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; 9use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
10use Wallabag\CommentBundle\Entity\Comment; 10use Wallabag\AnnotationBundle\Entity\Annotation;
11use Wallabag\CoreBundle\Entity\Entry; 11use Wallabag\CoreBundle\Entity\Entry;
12 12
13class WallabagCommentController extends FOSRestController 13class WallabagAnnotationController extends FOSRestController
14{ 14{
15 /** 15 /**
16 * Retrieve comments for an entry. 16 * Retrieve annotations for an entry.
17 * 17 *
18 * @ApiDoc( 18 * @ApiDoc(
19 * requirements={ 19 * requirements={
@@ -25,27 +25,27 @@ class WallabagCommentController extends FOSRestController
25 */ 25 */
26 public function getAnnotationsAction(Entry $entry) 26 public function getAnnotationsAction(Entry $entry)
27 { 27 {
28 $commentRows = $this 28 $annotationRows = $this
29 ->getDoctrine() 29 ->getDoctrine()
30 ->getRepository('WallabagCommentBundle:Comment') 30 ->getRepository('WallabagAnnotationBundle:Annotation')
31 ->findCommentsByPageId($entry->getId(), $this->getUser()->getId()); 31 ->findAnnotationsByPageId($entry->getId(), $this->getUser()->getId());
32 $total = count($commentRows); 32 $total = count($annotationRows);
33 $comments = array('total' => $total, 'rows' => $commentRows); 33 $annotations = array('total' => $total, 'rows' => $annotationRows);
34 34
35 $json = $this->get('serializer')->serialize($comments, 'json'); 35 $json = $this->get('serializer')->serialize($annotations, 'json');
36 36
37 return $this->renderJsonResponse($json); 37 return $this->renderJsonResponse($json);
38 } 38 }
39 39
40 /** 40 /**
41 * Creates a new comment. 41 * Creates a new annotation.
42 * 42 *
43 * @param Entry $entry 43 * @param Entry $entry
44 * 44 *
45 * @ApiDoc( 45 * @ApiDoc(
46 * requirements={ 46 * requirements={
47 * {"name"="ranges", "dataType"="array", "requirement"="\w+", "description"="The range array for the annotation"}, 47 * {"name"="ranges", "dataType"="array", "requirement"="\w+", "description"="The range array for the annotation"},
48 * {"name"="quote", "dataType"="string", "required"=false, "description"="Optional, quote for the comment"}, 48 * {"name"="quote", "dataType"="string", "required"=false, "description"="Optional, quote for the annotation"},
49 * {"name"="text", "dataType"="string", "required"=true, "description"=""}, 49 * {"name"="text", "dataType"="string", "required"=true, "description"=""},
50 * } 50 * }
51 * ) 51 * )
@@ -58,75 +58,75 @@ class WallabagCommentController extends FOSRestController
58 58
59 $em = $this->getDoctrine()->getManager(); 59 $em = $this->getDoctrine()->getManager();
60 60
61 $comment = new Comment($this->getUser()); 61 $annotation = new Annotation($this->getUser());
62 62
63 $comment->setText($data['text']); 63 $annotation->setText($data['text']);
64 if (array_key_exists('quote', $data)) { 64 if (array_key_exists('quote', $data)) {
65 $comment->setQuote($data['quote']); 65 $annotation->setQuote($data['quote']);
66 } 66 }
67 if (array_key_exists('ranges', $data)) { 67 if (array_key_exists('ranges', $data)) {
68 $comment->setRanges($data['ranges']); 68 $annotation->setRanges($data['ranges']);
69 } 69 }
70 70
71 $comment->setEntry($entry); 71 $annotation->setEntry($entry);
72 72
73 $em->persist($comment); 73 $em->persist($annotation);
74 $em->flush(); 74 $em->flush();
75 75
76 $json = $this->get('serializer')->serialize($comment, 'json'); 76 $json = $this->get('serializer')->serialize($annotation, 'json');
77 77
78 return $this->renderJsonResponse($json); 78 return $this->renderJsonResponse($json);
79 } 79 }
80 80
81 /** 81 /**
82 * Updates a comment. 82 * Updates an annotation.
83 * 83 *
84 * @ApiDoc( 84 * @ApiDoc(
85 * requirements={ 85 * requirements={
86 * {"name"="comment", "dataType"="string", "requirement"="\w+", "description"="The comment ID"} 86 * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
87 * } 87 * }
88 * ) 88 * )
89 * 89 *
90 * @ParamConverter("comment", class="WallabagCommentBundle:Comment") 90 * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
91 * 91 *
92 * @return Response 92 * @return Response
93 */ 93 */
94 public function putAnnotationAction(Comment $comment, Request $request) 94 public function putAnnotationAction(Annotation $annotation, Request $request)
95 { 95 {
96 $data = json_decode($request->getContent(), true); 96 $data = json_decode($request->getContent(), true);
97 97
98 if (!is_null($data['text'])) { 98 if (!is_null($data['text'])) {
99 $comment->setText($data['text']); 99 $annotation->setText($data['text']);
100 } 100 }
101 101
102 $em = $this->getDoctrine()->getManager(); 102 $em = $this->getDoctrine()->getManager();
103 $em->flush(); 103 $em->flush();
104 104
105 $json = $this->get('serializer')->serialize($comment, 'json'); 105 $json = $this->get('serializer')->serialize($annotation, 'json');
106 106
107 return $this->renderJsonResponse($json); 107 return $this->renderJsonResponse($json);
108 } 108 }
109 109
110 /** 110 /**
111 * Removes a comment. 111 * Removes an annotation.
112 * 112 *
113 * @ApiDoc( 113 * @ApiDoc(
114 * requirements={ 114 * requirements={
115 * {"name"="comment", "dataType"="string", "requirement"="\w+", "description"="The comment ID"} 115 * {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
116 * } 116 * }
117 * ) 117 * )
118 * 118 *
119 * @ParamConverter("comment", class="WallabagCommentBundle:Comment") 119 * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
120 * 120 *
121 * @return Response 121 * @return Response
122 */ 122 */
123 public function deleteAnnotationAction(Comment $comment) 123 public function deleteAnnotationAction(Annotation $annotation)
124 { 124 {
125 $em = $this->getDoctrine()->getManager(); 125 $em = $this->getDoctrine()->getManager();
126 $em->remove($comment); 126 $em->remove($annotation);
127 $em->flush(); 127 $em->flush();
128 128
129 $json = $this->get('serializer')->serialize($comment, 'json'); 129 $json = $this->get('serializer')->serialize($annotation, 'json');
130 130
131 return $this->renderJsonResponse($json); 131 return $this->renderJsonResponse($json);
132 } 132 }
diff --git a/src/Wallabag/AnnotationBundle/DataFixtures/ORM/LoadAnnotationData.php b/src/Wallabag/AnnotationBundle/DataFixtures/ORM/LoadAnnotationData.php
new file mode 100644
index 00000000..20e07fa3
--- /dev/null
+++ b/src/Wallabag/AnnotationBundle/DataFixtures/ORM/LoadAnnotationData.php
@@ -0,0 +1,45 @@
1<?php
2
3namespace Wallabag\AnnotationBundle\DataFixtures\ORM;
4
5use Doctrine\Common\DataFixtures\AbstractFixture;
6use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7use Doctrine\Common\Persistence\ObjectManager;
8use Wallabag\AnnotationBundle\Entity\Annotation;
9
10class LoadAnnotationData extends AbstractFixture implements OrderedFixtureInterface
11{
12 /**
13 * {@inheritdoc}
14 */
15 public function load(ObjectManager $manager)
16 {
17 $annotation1 = new Annotation($this->getReference('admin-user'));
18 $annotation1->setEntry($this->getReference('entry1'));
19 $annotation1->setText('This is my annotation /o/');
20 $annotation1->setQuote('content');
21
22 $manager->persist($annotation1);
23
24 $this->addReference('annotation1', $annotation1);
25
26 $annotation2 = new Annotation($this->getReference('admin-user'));
27 $annotation2->setEntry($this->getReference('entry2'));
28 $annotation2->setText('This is my 2nd annotation /o/');
29 $annotation2->setQuote('content');
30
31 $manager->persist($annotation2);
32
33 $this->addReference('annotation2', $annotation2);
34
35 $manager->flush();
36 }
37
38 /**
39 * {@inheritdoc}
40 */
41 public function getOrder()
42 {
43 return 35;
44 }
45}
diff --git a/src/Wallabag/CommentBundle/DependencyInjection/Configuration.php b/src/Wallabag/AnnotationBundle/DependencyInjection/Configuration.php
index bc8d0615..5e4e4e9c 100644
--- a/src/Wallabag/CommentBundle/DependencyInjection/Configuration.php
+++ b/src/Wallabag/AnnotationBundle/DependencyInjection/Configuration.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2 2
3namespace Wallabag\CommentBundle\DependencyInjection; 3namespace Wallabag\AnnotationBundle\DependencyInjection;
4 4
5use Symfony\Component\Config\Definition\Builder\TreeBuilder; 5use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6use Symfony\Component\Config\Definition\ConfigurationInterface; 6use Symfony\Component\Config\Definition\ConfigurationInterface;
@@ -13,7 +13,7 @@ class Configuration implements ConfigurationInterface
13 public function getConfigTreeBuilder() 13 public function getConfigTreeBuilder()
14 { 14 {
15 $treeBuilder = new TreeBuilder(); 15 $treeBuilder = new TreeBuilder();
16 $rootNode = $treeBuilder->root('wallabag_comment'); 16 $rootNode = $treeBuilder->root('wallabag_annotation');
17 17
18 return $treeBuilder; 18 return $treeBuilder;
19 } 19 }
diff --git a/src/Wallabag/CommentBundle/DependencyInjection/WallabagCommentExtension.php b/src/Wallabag/AnnotationBundle/DependencyInjection/WallabagAnnotationExtension.php
index 6b05fa00..159576d6 100644
--- a/src/Wallabag/CommentBundle/DependencyInjection/WallabagCommentExtension.php
+++ b/src/Wallabag/AnnotationBundle/DependencyInjection/WallabagAnnotationExtension.php
@@ -1,11 +1,11 @@
1<?php 1<?php
2 2
3namespace Wallabag\CommentBundle\DependencyInjection; 3namespace Wallabag\AnnotationBundle\DependencyInjection;
4 4
5use Symfony\Component\DependencyInjection\ContainerBuilder; 5use Symfony\Component\DependencyInjection\ContainerBuilder;
6use Symfony\Component\HttpKernel\DependencyInjection\Extension; 6use Symfony\Component\HttpKernel\DependencyInjection\Extension;
7 7
8class WallabagCommentExtension extends Extension 8class WallabagAnnotationExtension extends Extension
9{ 9{
10 /** 10 /**
11 * {@inheritdoc} 11 * {@inheritdoc}
diff --git a/src/Wallabag/CommentBundle/Entity/Comment.php b/src/Wallabag/AnnotationBundle/Entity/Annotation.php
index a89a2cb3..db9590b0 100644
--- a/src/Wallabag/CommentBundle/Entity/Comment.php
+++ b/src/Wallabag/AnnotationBundle/Entity/Annotation.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2 2
3namespace Wallabag\CommentBundle\Entity; 3namespace Wallabag\AnnotationBundle\Entity;
4 4
5use Doctrine\ORM\Mapping as ORM; 5use Doctrine\ORM\Mapping as ORM;
6use JMS\Serializer\Annotation\ExclusionPolicy; 6use JMS\Serializer\Annotation\ExclusionPolicy;
@@ -11,14 +11,14 @@ use Wallabag\UserBundle\Entity\User;
11use Wallabag\CoreBundle\Entity\Entry; 11use Wallabag\CoreBundle\Entity\Entry;
12 12
13/** 13/**
14 * Comment. 14 * Annotation.
15 * 15 *
16 * @ORM\Table(name="comment") 16 * @ORM\Table(name="annotation")
17 * @ORM\Entity(repositoryClass="Wallabag\CommentBundle\Repository\CommentRepository") 17 * @ORM\Entity(repositoryClass="Wallabag\AnnotationBundle\Repository\AnnotationRepository")
18 * @ORM\HasLifecycleCallbacks() 18 * @ORM\HasLifecycleCallbacks()
19 * @ExclusionPolicy("none") 19 * @ExclusionPolicy("none")
20 */ 20 */
21class Comment 21class Annotation
22{ 22{
23 /** 23 /**
24 * @var int 24 * @var int
@@ -74,7 +74,7 @@ class Comment
74 /** 74 /**
75 * @Exclude 75 * @Exclude
76 * 76 *
77 * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Entry", inversedBy="comments") 77 * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Entry", inversedBy="annotations")
78 * @ORM\JoinColumn(name="entry_id", referencedColumnName="id") 78 * @ORM\JoinColumn(name="entry_id", referencedColumnName="id")
79 */ 79 */
80 private $entry; 80 private $entry;
@@ -102,7 +102,7 @@ class Comment
102 * 102 *
103 * @param string $text 103 * @param string $text
104 * 104 *
105 * @return Comment 105 * @return Annotation
106 */ 106 */
107 public function setText($text) 107 public function setText($text)
108 { 108 {
@@ -168,7 +168,7 @@ class Comment
168 * 168 *
169 * @param string $quote 169 * @param string $quote
170 * 170 *
171 * @return Comment 171 * @return Annotation
172 */ 172 */
173 public function setQuote($quote) 173 public function setQuote($quote)
174 { 174 {
@@ -192,7 +192,7 @@ class Comment
192 * 192 *
193 * @param array $ranges 193 * @param array $ranges
194 * 194 *
195 * @return Comment 195 * @return Annotation
196 */ 196 */
197 public function setRanges($ranges) 197 public function setRanges($ranges)
198 { 198 {
@@ -206,7 +206,7 @@ class Comment
206 * 206 *
207 * @param string $user 207 * @param string $user
208 * 208 *
209 * @return Comment 209 * @return Annotation
210 */ 210 */
211 public function setUser($user) 211 public function setUser($user)
212 { 212 {
@@ -239,12 +239,12 @@ class Comment
239 * 239 *
240 * @param Entry $entry 240 * @param Entry $entry
241 * 241 *
242 * @return Comment 242 * @return Annotation
243 */ 243 */
244 public function setEntry($entry) 244 public function setEntry($entry)
245 { 245 {
246 $this->entry = $entry; 246 $this->entry = $entry;
247 $entry->setComment($this); 247 $entry->setAnnotation($this);
248 248
249 return $this; 249 return $this;
250 } 250 }
diff --git a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
new file mode 100644
index 00000000..c1c6e638
--- /dev/null
+++ b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
@@ -0,0 +1,91 @@
1<?php
2
3namespace Wallabag\AnnotationBundle\Repository;
4
5use Doctrine\ORM\EntityRepository;
6
7/**
8 * AnnotationRepository.
9 */
10class AnnotationRepository extends EntityRepository
11{
12 /**
13 * Return a query builder to used by other getBuilderFor* method.
14 *
15 * @param int $userId
16 *
17 * @return QueryBuilder
18 */
19 private function getBuilderByUser($userId)
20 {
21 return $this->createQueryBuilder('a')
22 ->leftJoin('a.user', 'u')
23 ->andWhere('u.id = :userId')->setParameter('userId', $userId)
24 ->orderBy('a.id', 'desc')
25 ;
26 }
27
28 /**
29 * Retrieves all annotations for a user.
30 *
31 * @param int $userId
32 *
33 * @return QueryBuilder
34 */
35 public function getBuilderForAllByUser($userId)
36 {
37 return $this
38 ->getBuilderByUser($userId)
39 ;
40 }
41
42 /**
43 * Get annotation for this id.
44 *
45 * @param int $annotationId
46 *
47 * @return array
48 */
49 public function findAnnotationById($annotationId)
50 {
51 return $this->createQueryBuilder('a')
52 ->andWhere('a.id = :annotationId')->setParameter('annotationId', $annotationId)
53 ->getQuery()->getSingleResult()
54 ;
55 }
56
57 /**
58 * Find annotations for entry id.
59 *
60 * @param int $entryId
61 * @param int $userId
62 *
63 * @return array
64 */
65 public function findAnnotationsByPageId($entryId, $userId)
66 {
67 return $this->createQueryBuilder('a')
68 ->where('a.entry = :entryId')->setParameter('entryId', $entryId)
69 ->andwhere('a.user = :userId')->setParameter('userId', $userId)
70 ->getQuery()->getResult()
71 ;
72 }
73
74 /**
75 * Find last annotation for a given entry id. Used only for tests.
76 *
77 * @param int $entryId
78 *
79 * @return array
80 */
81 public function findLastAnnotationByPageId($entryId, $userId)
82 {
83 return $this->createQueryBuilder('a')
84 ->where('a.entry = :entryId')->setParameter('entryId', $entryId)
85 ->andwhere('a.user = :userId')->setParameter('userId', $userId)
86 ->orderBy('a.id', 'DESC')
87 ->setMaxResults(1)
88 ->getQuery()
89 ->getOneOrNullResult();
90 }
91}
diff --git a/src/Wallabag/AnnotationBundle/Resources/config/routing_annotations.yml b/src/Wallabag/AnnotationBundle/Resources/config/routing_annotations.yml
new file mode 100644
index 00000000..4f3a5c93
--- /dev/null
+++ b/src/Wallabag/AnnotationBundle/Resources/config/routing_annotations.yml
@@ -0,0 +1,4 @@
1annotations:
2 type: rest
3 resource: "WallabagAnnotationBundle:WallabagAnnotation"
4 name_prefix: annotations_
diff --git a/src/Wallabag/CommentBundle/Tests/Controller/CommentControllerTest.php b/src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php
index f8b2a56f..c0efe272 100644
--- a/src/Wallabag/CommentBundle/Tests/Controller/CommentControllerTest.php
+++ b/src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php
@@ -1,31 +1,31 @@
1<?php 1<?php
2 2
3namespace Wallabag\CommentBundle\Tests\Controller; 3namespace Wallabag\AnnotationBundle\Tests\Controller;
4 4
5use Wallabag\CommentBundle\Tests\WallabagCommentTestCase; 5use Wallabag\AnnotationBundle\Tests\WallabagAnnotationTestCase;
6 6
7class CommentControllerTest extends WallabagCommentTestCase 7class AnnotationControllerTest extends WallabagAnnotationTestCase
8{ 8{
9 public function testGetComments() 9 public function testGetAnnotations()
10 { 10 {
11 $comment = $this->client->getContainer() 11 $annotation = $this->client->getContainer()
12 ->get('doctrine.orm.entity_manager') 12 ->get('doctrine.orm.entity_manager')
13 ->getRepository('WallabagCommentBundle:Comment') 13 ->getRepository('WallabagAnnotationBundle:Annotation')
14 ->findOneBy(array('user' => 1)); 14 ->findOneBy(array('user' => 1));
15 15
16 if (!$comment) { 16 if (!$annotation) {
17 $this->markTestSkipped('No content found in db.'); 17 $this->markTestSkipped('No content found in db.');
18 } 18 }
19 $this->logInAs('admin'); 19 $this->logInAs('admin');
20 $crawler = $this->client->request('GET', 'annotations/'.$comment->getEntry()->getId().'.json'); 20 $crawler = $this->client->request('GET', 'annotations/'.$annotation->getEntry()->getId().'.json');
21 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 21 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
22 22
23 $content = json_decode($this->client->getResponse()->getContent(), true); 23 $content = json_decode($this->client->getResponse()->getContent(), true);
24 $this->assertEquals(1, $content['total']); 24 $this->assertEquals(1, $content['total']);
25 $this->assertEquals($comment->getText(), $content['rows'][0]['text']); 25 $this->assertEquals($annotation->getText(), $content['rows'][0]['text']);
26 } 26 }
27 27
28 public function testSetcomment() 28 public function testSetAnnotation()
29 { 29 {
30 $this->logInAs('admin'); 30 $this->logInAs('admin');
31 31
@@ -36,7 +36,7 @@ class CommentControllerTest extends WallabagCommentTestCase
36 36
37 $headers = array('CONTENT_TYPE' => 'application/json'); 37 $headers = array('CONTENT_TYPE' => 'application/json');
38 $content = json_encode(array( 38 $content = json_encode(array(
39 'text' => 'my comment', 39 'text' => 'my annotation',
40 'quote' => 'my quote', 40 'quote' => 'my quote',
41 'range' => '[{"start":"","startOffset":24,"end":"","endOffset":31}]', 41 'range' => '[{"start":"","startOffset":24,"end":"","endOffset":31}]',
42 )); 42 ));
@@ -44,38 +44,38 @@ class CommentControllerTest extends WallabagCommentTestCase
44 44
45 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 45 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
46 46
47 $comment = $this->client->getContainer() 47 $annotation = $this->client->getContainer()
48 ->get('doctrine.orm.entity_manager') 48 ->get('doctrine.orm.entity_manager')
49 ->getRepository('WallabagCommentBundle:Comment') 49 ->getRepository('WallabagAnnotationBundle:Annotation')
50 ->findLastCommentByPageId($entry->getId(), 1); 50 ->findLastAnnotationByPageId($entry->getId(), 1);
51 51
52 $this->assertEquals('my comment', $comment->getText()); 52 $this->assertEquals('my annotation', $annotation->getText());
53 } 53 }
54 54
55 public function testEditcomment() 55 public function testEditAnnotation()
56 { 56 {
57 $comment = $this->client->getContainer() 57 $annotation = $this->client->getContainer()
58 ->get('doctrine.orm.entity_manager') 58 ->get('doctrine.orm.entity_manager')
59 ->getRepository('WallabagCommentBundle:Comment') 59 ->getRepository('WallabagAnnotationBundle:Annotation')
60 ->findOneBy(array('user' => 1)); 60 ->findOneBy(array('user' => 1));
61 61
62 $this->logInAs('admin'); 62 $this->logInAs('admin');
63 63
64 $headers = array('CONTENT_TYPE' => 'application/json'); 64 $headers = array('CONTENT_TYPE' => 'application/json');
65 $content = json_encode(array( 65 $content = json_encode(array(
66 'text' => 'a modified comment', 66 'text' => 'a modified annotation',
67 )); 67 ));
68 $crawler = $this->client->request('PUT', 'annotations/'.$comment->getId().'.json', array(), array(), $headers, $content); 68 $crawler = $this->client->request('PUT', 'annotations/'.$annotation->getId().'.json', array(), array(), $headers, $content);
69 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 69 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
70 70
71 $content = json_decode($this->client->getResponse()->getContent(), true); 71 $content = json_decode($this->client->getResponse()->getContent(), true);
72 72
73 $this->assertEquals('a modified comment', $content['text']); 73 $this->assertEquals('a modified annotation', $content['text']);
74 74
75 $commentUpdated = $this->client->getContainer() 75 $annotationUpdated = $this->client->getContainer()
76 ->get('doctrine.orm.entity_manager') 76 ->get('doctrine.orm.entity_manager')
77 ->getRepository('WallabagCommentBundle:Comment') 77 ->getRepository('WallabagAnnotationBundle:Annotation')
78 ->findCommentById($comment->getId()); 78 ->findAnnotationById($annotation->getId());
79 $this->assertEquals('a modified comment', $commentUpdated->getText()); 79 $this->assertEquals('a modified annotation', $annotationUpdated->getText());
80 } 80 }
81} 81}
diff --git a/src/Wallabag/CommentBundle/Tests/WallabagCommentTestCase.php b/src/Wallabag/AnnotationBundle/Tests/WallabagAnnotationTestCase.php
index f4a2ae6c..2deff6bf 100644
--- a/src/Wallabag/CommentBundle/Tests/WallabagCommentTestCase.php
+++ b/src/Wallabag/AnnotationBundle/Tests/WallabagAnnotationTestCase.php
@@ -1,11 +1,11 @@
1<?php 1<?php
2 2
3namespace Wallabag\CommentBundle\Tests; 3namespace Wallabag\AnnotationBundle\Tests;
4 4
5use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; 5use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6use Symfony\Component\BrowserKit\Cookie; 6use Symfony\Component\BrowserKit\Cookie;
7 7
8abstract class WallabagCommentTestCase extends WebTestCase 8abstract class WallabagAnnotationTestCase extends WebTestCase
9{ 9{
10 /** 10 /**
11 * @var Client 11 * @var Client
diff --git a/src/Wallabag/AnnotationBundle/WallabagAnnotationBundle.php b/src/Wallabag/AnnotationBundle/WallabagAnnotationBundle.php
new file mode 100644
index 00000000..b64920a3
--- /dev/null
+++ b/src/Wallabag/AnnotationBundle/WallabagAnnotationBundle.php
@@ -0,0 +1,9 @@
1<?php
2
3namespace Wallabag\AnnotationBundle;
4
5use Symfony\Component\HttpKernel\Bundle\Bundle;
6
7class WallabagAnnotationBundle extends Bundle
8{
9}
diff --git a/src/Wallabag/CommentBundle/DataFixtures/ORM/LoadCommentData.php b/src/Wallabag/CommentBundle/DataFixtures/ORM/LoadCommentData.php
deleted file mode 100644
index 717f4863..00000000
--- a/src/Wallabag/CommentBundle/DataFixtures/ORM/LoadCommentData.php
+++ /dev/null
@@ -1,45 +0,0 @@
1<?php
2
3namespace Wallabag\CoreBundle\DataFixtures\ORM;
4
5use Doctrine\Common\DataFixtures\AbstractFixture;
6use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7use Doctrine\Common\Persistence\ObjectManager;
8use Wallabag\CommentBundle\Entity\Comment;
9
10class LoadCommentData extends AbstractFixture implements OrderedFixtureInterface
11{
12 /**
13 * {@inheritdoc}
14 */
15 public function load(ObjectManager $manager)
16 {
17 $comment1 = new Comment($this->getReference('admin-user'));
18 $comment1->setEntry($this->getReference('entry1'));
19 $comment1->setText('This is my comment /o/');
20 $comment1->setQuote('content');
21
22 $manager->persist($comment1);
23
24 $this->addReference('comment1', $comment1);
25
26 $comment2 = new Comment($this->getReference('admin-user'));
27 $comment2->setEntry($this->getReference('entry2'));
28 $comment2->setText('This is my 2nd comment /o/');
29 $comment2->setQuote('content');
30
31 $manager->persist($comment2);
32
33 $this->addReference('comment2', $comment2);
34
35 $manager->flush();
36 }
37
38 /**
39 * {@inheritdoc}
40 */
41 public function getOrder()
42 {
43 return 35;
44 }
45}
diff --git a/src/Wallabag/CommentBundle/Repository/CommentRepository.php b/src/Wallabag/CommentBundle/Repository/CommentRepository.php
deleted file mode 100644
index 15acffbf..00000000
--- a/src/Wallabag/CommentBundle/Repository/CommentRepository.php
+++ /dev/null
@@ -1,94 +0,0 @@
1<?php
2
3namespace Wallabag\CommentBundle\Repository;
4
5use Doctrine\ORM\EntityRepository;
6
7/**
8 * CommentRepository.
9 *
10 * This class was generated by the Doctrine ORM. Add your own custom
11 * repository methods below.
12 */
13class CommentRepository extends EntityRepository
14{
15 /**
16 * Return a query builder to used by other getBuilderFor* method.
17 *
18 * @param int $userId
19 *
20 * @return QueryBuilder
21 */
22 private function getBuilderByUser($userId)
23 {
24 return $this->createQueryBuilder('c')
25 ->leftJoin('c.user', 'u')
26 ->andWhere('u.id = :userId')->setParameter('userId', $userId)
27 ->orderBy('c.id', 'desc')
28 ;
29 }
30
31 /**
32 * Retrieves all comments for a user.
33 *
34 * @param int $userId
35 *
36 * @return QueryBuilder
37 */
38 public function getBuilderForAllByUser($userId)
39 {
40 return $this
41 ->getBuilderByUser($userId)
42 ;
43 }
44
45 /**
46 * Get comment for this id.
47 *
48 * @param int $commentId
49 *
50 * @return array
51 */
52 public function findCommentById($commentId)
53 {
54 return $this->createQueryBuilder('c')
55 ->andWhere('c.id = :commentId')->setParameter('commentId', $commentId)
56 ->getQuery()->getSingleResult()
57 ;
58 }
59
60 /**
61 * Find comments for entry id.
62 *
63 * @param int $entryId
64 * @param int $userId
65 *
66 * @return array
67 */
68 public function findCommentsByPageId($entryId, $userId)
69 {
70 return $this->createQueryBuilder('c')
71 ->where('c.entry = :entryId')->setParameter('entryId', $entryId)
72 ->andwhere('c.user = :userId')->setParameter('userId', $userId)
73 ->getQuery()->getResult()
74 ;
75 }
76
77 /**
78 * Find last comment for a given entry id. Used only for tests.
79 *
80 * @param int $entryId
81 *
82 * @return array
83 */
84 public function findLastCommentByPageId($entryId, $userId)
85 {
86 return $this->createQueryBuilder('c')
87 ->where('c.entry = :entryId')->setParameter('entryId', $entryId)
88 ->andwhere('c.user = :userId')->setParameter('userId', $userId)
89 ->orderBy('c.id', 'DESC')
90 ->setMaxResults(1)
91 ->getQuery()
92 ->getOneOrNullResult();
93 }
94}
diff --git a/src/Wallabag/CommentBundle/Resources/config/routing_comments.yml b/src/Wallabag/CommentBundle/Resources/config/routing_comments.yml
deleted file mode 100644
index 1d3893d3..00000000
--- a/src/Wallabag/CommentBundle/Resources/config/routing_comments.yml
+++ /dev/null
@@ -1,4 +0,0 @@
1annotations:
2 type: rest
3 resource: "WallabagCommentBundle:WallabagComment"
4 name_prefix: annotations_
diff --git a/src/Wallabag/CommentBundle/WallabagCommentBundle.php b/src/Wallabag/CommentBundle/WallabagCommentBundle.php
deleted file mode 100644
index 8150034d..00000000
--- a/src/Wallabag/CommentBundle/WallabagCommentBundle.php
+++ /dev/null
@@ -1,9 +0,0 @@
1<?php
2
3namespace Wallabag\CommentBundle;
4
5use Symfony\Component\HttpKernel\Bundle\Bundle;
6
7class WallabagCommentBundle extends Bundle
8{
9}
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 5cf84f03..bd712a04 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -9,7 +9,7 @@ use JMS\Serializer\Annotation\Groups;
9use JMS\Serializer\Annotation\XmlRoot; 9use JMS\Serializer\Annotation\XmlRoot;
10use Symfony\Component\Validator\Constraints as Assert; 10use Symfony\Component\Validator\Constraints as Assert;
11use Wallabag\UserBundle\Entity\User; 11use Wallabag\UserBundle\Entity\User;
12use Wallabag\CommentBundle\Entity\Comment; 12use Wallabag\AnnotationBundle\Entity\Annotation;
13 13
14/** 14/**
15 * Entry. 15 * Entry.
@@ -99,12 +99,12 @@ class Entry
99 private $updatedAt; 99 private $updatedAt;
100 100
101 /** 101 /**
102 * @ORM\OneToMany(targetEntity="Wallabag\CommentBundle\Entity\Comment", mappedBy="entry", cascade={"persist", "remove"}) 102 * @ORM\OneToMany(targetEntity="Wallabag\AnnotationBundle\Entity\Annotation", mappedBy="entry", cascade={"persist", "remove"})
103 * @ORM\JoinTable 103 * @ORM\JoinTable
104 * 104 *
105 * @Groups({"entries_for_user", "export_all"}) 105 * @Groups({"entries_for_user", "export_all"})
106 */ 106 */
107 private $comments; 107 private $annotations;
108 108
109 /** 109 /**
110 * @var string 110 * @var string
@@ -366,19 +366,19 @@ class Entry
366 } 366 }
367 367
368 /** 368 /**
369 * @return ArrayCollection<Comment> 369 * @return ArrayCollection<Annotation>
370 */ 370 */
371 public function getComments() 371 public function getAnnotations()
372 { 372 {
373 return $this->comments; 373 return $this->annotations;
374 } 374 }
375 375
376 /** 376 /**
377 * @param Comment $comment 377 * @param Annotation $annotation
378 */ 378 */
379 public function setComment(Comment $comment) 379 public function setAnnotation(Annotation $annotation)
380 { 380 {
381 $this->comments[] = $comment; 381 $this->annotations[] = $annotation;
382 } 382 }
383 383
384 /** 384 /**
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index 548a164b..e4935b9e 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -98,7 +98,7 @@ Toggle favorite: 'Marquer comme favori'
98Delete: 'Supprimer' 98Delete: 'Supprimer'
99"{0} There is no entry.|{1} There is one entry.|]1,Inf[ There are %count% entries.": "{0} Il n'y a pas d'articles.|{1} Il y a un article.|]1,Inf[ Il y a %count% articles." 99"{0} There is no entry.|{1} There is one entry.|]1,Inf[ There are %count% entries.": "{0} Il n'y a pas d'articles.|{1} Il y a un article.|]1,Inf[ Il y a %count% articles."
100http://website: "http://siteweb" 100http://website: "http://siteweb"
101"{0} No annotations|{1} One annotation|]1,Inf[ %nbComments% annotations": "{0} Aucune annotation|{1} Une annotation|]1,Inf[ %nbComments% annotations" 101"{0} No annotations|{1} One annotation|]1,Inf[ %nbAnnotations% annotations": "{0} Aucune annotation|{1} Une annotation|]1,Inf[ %nbAnnotations% annotations"
102 102
103# Edit entry 103# Edit entry
104Edit an entry: "Éditer un article" 104Edit an entry: "Éditer un article"
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig
index 817e39b8..9323e787 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig
@@ -29,8 +29,8 @@
29 <li><a href="mailto:hello@wallabag.org?subject=Wrong%20display%20in%20wallabag&amp;body={{ entry.url|url_encode }}" title="{% trans %}Does this article appear wrong?{% endtrans %}" class="tool bad-display icon icon-delete"><span>{% trans %}Does this article appear wrong?{% endtrans %}</span></a></li> 29 <li><a href="mailto:hello@wallabag.org?subject=Wrong%20display%20in%20wallabag&amp;body={{ entry.url|url_encode }}" title="{% trans %}Does this article appear wrong?{% endtrans %}" class="tool bad-display icon icon-delete"><span>{% trans %}Does this article appear wrong?{% endtrans %}</span></a></li>
30 </ul> 30 </ul>
31 </div> 31 </div>
32 {% set nbComments = entry.comments | length %} 32 {% set nbAnnotations = entry.annotations | length %}
33 <span class="tool link mdi-communication-comment"> {% transchoice nbComments %}{0} No annotations|{1} One annotation|]1,Inf[ %nbComments% annotations{% endtranschoice %}</span> 33 <span class="tool link mdi-communication-comment"> {% transchoice nbAnnotations %}{0} No annotations|{1} One annotation|]1,Inf[ %nbAnnotations% annotations{% endtranschoice %}</span>
34 <aside class="tags"> 34 <aside class="tags">
35 {% for tag in entry.tags %} 35 {% for tag in entry.tags %}
36 <span class="mdi-action-label-outline">{{ tag.label }}</span> <a href="{{ path('remove_tag', { 'entry': entry.id, 'tag': tag.id }) }}"><i>✘</i></a> 36 <span class="mdi-action-label-outline">{{ tag.label }}</span> <a href="{{ path('remove_tag', { 'entry': entry.id, 'tag': tag.id }) }}"><i>✘</i></a>
@@ -117,8 +117,8 @@
117 prefix: '', 117 prefix: '',
118 urls: { 118 urls: {
119 create: '{{ path('annotations_post_annotation', { 'entry': entry.id }) }}', 119 create: '{{ path('annotations_post_annotation', { 'entry': entry.id }) }}',
120 update: '{{ path('annotations_put_annotation', { 'comment': 'idComment' }) }}', 120 update: '{{ path('annotations_put_annotation', { 'annotation': 'idAnnotation' }) }}',
121 destroy: '{{ path('annotations_delete_annotation', { 'comment': 'idComment' }) }}', 121 destroy: '{{ path('annotations_delete_annotation', { 'annotation': 'idAnnotation' }) }}',
122 search: '{{ path('annotations_get_annotations', { 'entry': entry.id }) }}' 122 search: '{{ path('annotations_get_annotations', { 'entry': entry.id }) }}'
123 } 123 }
124 }); 124 });
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 4839c3ea..6f33da23 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
@@ -187,8 +187,8 @@ main {
187 </header> 187 </header>
188 <aside> 188 <aside>
189 <a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link mdi-content-link"> <span>{{ entry.domainName|removeWww }}</span></a> 189 <a href="{{ entry.url|e }}" target="_blank" title="{% trans %}original{% endtrans %} : {{ entry.title|e }}" class="tool link mdi-content-link"> <span>{{ entry.domainName|removeWww }}</span></a>
190 {% set nbComments = entry.comments | length %} 190 {% set nbAnnotations = entry.annotations | length %}
191 <span class="tool link mdi-communication-comment"> {% transchoice nbComments %}{0} No annotations|{1} One annotation|]1,Inf[ %nbComments% annotations{% endtranschoice %}</span> 191 <span class="tool link mdi-communication-comment"> {% transchoice nbAnnotations %}{0} No annotations|{1} One annotation|]1,Inf[ %nbAnnotations% annotations{% endtranschoice %}</span>
192 <div id="list"> 192 <div id="list">
193 {% for tag in entry.tags %} 193 {% for tag in entry.tags %}
194 <div class="chip"> 194 <div class="chip">
@@ -221,8 +221,8 @@ app.include(annotator.storage.http, {
221 prefix: '', 221 prefix: '',
222 urls: { 222 urls: {
223 create: '{{ path('annotations_post_annotation', { 'entry': entry.id }) }}', 223 create: '{{ path('annotations_post_annotation', { 'entry': entry.id }) }}',
224 update: '{{ path('annotations_put_annotation', { 'comment': 'idComment' }) }}', 224 update: '{{ path('annotations_put_annotation', { 'annotation': 'idAnnotation' }) }}',
225 destroy: '{{ path('annotations_delete_annotation', { 'comment': 'idComment' }) }}', 225 destroy: '{{ path('annotations_delete_annotation', { 'annotation': 'idAnnotation' }) }}',
226 search: '{{ path('annotations_get_annotations', { 'entry': entry.id }) }}' 226 search: '{{ path('annotations_get_annotations', { 'entry': entry.id }) }}'
227 } 227 }
228}); 228});