]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Rename CommentBundle with AnnotationBundle
authorNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 26 Feb 2016 12:59:08 +0000 (13:59 +0100)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Fri, 26 Feb 2016 17:14:42 +0000 (18:14 +0100)
22 files changed:
app/AppKernel.php
app/config/routing.yml
docs/en/user/annotations.rst
docs/fr/user/annotations.rst
src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php [moved from src/Wallabag/CommentBundle/Controller/WallabagCommentController.php with 57% similarity]
src/Wallabag/AnnotationBundle/DataFixtures/ORM/LoadAnnotationData.php [new file with mode: 0644]
src/Wallabag/AnnotationBundle/DependencyInjection/Configuration.php [moved from src/Wallabag/CommentBundle/DependencyInjection/Configuration.php with 74% similarity]
src/Wallabag/AnnotationBundle/DependencyInjection/WallabagAnnotationExtension.php [moved from src/Wallabag/CommentBundle/DependencyInjection/WallabagCommentExtension.php with 77% similarity]
src/Wallabag/AnnotationBundle/Entity/Annotation.php [moved from src/Wallabag/CommentBundle/Entity/Comment.php with 91% similarity]
src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php [new file with mode: 0644]
src/Wallabag/AnnotationBundle/Resources/config/routing_annotations.yml [new file with mode: 0644]
src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php [moved from src/Wallabag/CommentBundle/Tests/Controller/CommentControllerTest.php with 55% similarity]
src/Wallabag/AnnotationBundle/Tests/WallabagAnnotationTestCase.php [moved from src/Wallabag/CommentBundle/Tests/WallabagCommentTestCase.php with 94% similarity]
src/Wallabag/AnnotationBundle/WallabagAnnotationBundle.php [new file with mode: 0644]
src/Wallabag/CommentBundle/DataFixtures/ORM/LoadCommentData.php [deleted file]
src/Wallabag/CommentBundle/Repository/CommentRepository.php [deleted file]
src/Wallabag/CommentBundle/Resources/config/routing_comments.yml [deleted file]
src/Wallabag/CommentBundle/WallabagCommentBundle.php [deleted file]
src/Wallabag/CoreBundle/Entity/Entry.php
src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig

index 1f2d4ad4f786a0f49d55fa0ee430fa5497ba3f25..30ac7463ba742bb6bdda0b650b69c9c325f3c7a7 100644 (file)
@@ -35,7 +35,7 @@ class AppKernel extends Kernel
             new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
             new Craue\ConfigBundle\CraueConfigBundle(),
             new Lexik\Bundle\MaintenanceBundle\LexikMaintenanceBundle(),
             new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
             new Craue\ConfigBundle\CraueConfigBundle(),
             new Lexik\Bundle\MaintenanceBundle\LexikMaintenanceBundle(),
-            new Wallabag\CommentBundle\WallabagCommentBundle(),
+            new Wallabag\AnnotationBundle\WallabagAnnotationBundle(),
         ];
 
         if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
         ];
 
         if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
index 8fbcb6432a6a6b063702a7568bcfc7148836a1a3..6a6aa6aca65ff3763cbde25a0bda56305a934ea4 100644 (file)
@@ -1,6 +1,6 @@
-wallabag_comment:
+wallabag_annotation:
   type : rest
   type : rest
-  resource: "@WallabagCommentBundle/Resources/config/routing_comments.yml"
+  resource: "@WallabagAnnotationBundle/Resources/config/routing_annotations.yml"
 
 wallabag_import:
     resource: "@WallabagImportBundle/Controller/"
 
 wallabag_import:
     resource: "@WallabagImportBundle/Controller/"
index d30b2c525a8ca5809a70500df5330b4b2b9a9798..fab854aae89621807ee809e0acfeafe5a857443c 100644 (file)
@@ -3,22 +3,22 @@ Annotations
 
 In each article you read, you can write annotations. It's easier to understand with some pictures.
 
 
 In each article you read, you can write annotations. It's easier to understand with some pictures.
 
-Select the part of the article that you want to comment and click on the pencil:
+Select the part of the article that you want to annotate and click on the pencil:
 
 .. image:: ../../img/user/annotations_1.png
    :alt: Select your text
    :align: center
 
 
 .. image:: ../../img/user/annotations_1.png
    :alt: Select your text
    :align: center
 
-Then, write your comment:
+Then, write your annotation:
 
 .. image:: ../../img/user/annotations_2.png
 
 .. image:: ../../img/user/annotations_2.png
-   :alt: Write your comment
+   :alt: Write your annotation
    :align: center
 
    :align: center
 
-The text is now highlighted and you can read your comment if you move the mouse cursor over it.
+The text is now highlighted and you can read your annotation if you move the mouse cursor over it.
 
 .. image:: ../../img/user/annotations_3.png
 
 .. image:: ../../img/user/annotations_3.png
-   :alt: Read your comment
+   :alt: Read your annotation
    :align: center
 
    :align: center
 
-You can create as many comments as you wish.
+You can create as many annotations as you wish.
index 8ba87e2652256ed8dd107b46f8d0be9a3db9a542..2458596184a64ee850a1a981beaf4bf3d7cd8f50 100644 (file)
@@ -1,25 +1,25 @@
-Commentaires
-============
+Annotations
+===========
 
 
-Sur chaque article que vous lisez, vous pouvez écrire des commentaires. Puisqu'une image vaut mieux qu'un long discours,
+Sur chaque article que vous lisez, vous pouvez écrire des annotations. Puisqu'une image vaut mieux qu'un long discours,
 voici ce que ça donne.
 
 voici ce que ça donne.
 
-Sélectionnez la zone du texte que vous souhaitez commenter et cliquez sur le crayon :
+Sélectionnez la zone du texte que vous souhaitez annoter et cliquez sur le crayon :
 
 .. image:: ../../img/user/annotations_1.png
 
 .. image:: ../../img/user/annotations_1.png
-   :alt: Select your text
+   :alt: Sélectionnez votre texte
    :align: center
 
    :align: center
 
-Ensuite, écrivez votre commentaire :
+Ensuite, écrivez votre annotation :
 
 .. image:: ../../img/user/annotations_2.png
 
 .. image:: ../../img/user/annotations_2.png
-   :alt: Write your comment
+   :alt: Écrivez votre annotation
    :align: center
 
    :align: center
 
-Le texte est maintenant surligné et vous pouvez lire le commentaire en le survolant avec votre souris.
+Le texte est maintenant surligné et vous pouvez lire le annotation en le survolant avec votre souris.
 
 .. image:: ../../img/user/annotations_3.png
 
 .. image:: ../../img/user/annotations_3.png
-   :alt: Read your comment
+   :alt: Lisez votre annotation
    :align: center
 
    :align: center
 
-Vous pouvez créer autant de commentaires que vous le souhaitez.
+Vous pouvez créer autant de annotations que vous le souhaitez.
similarity index 57%
rename from src/Wallabag/CommentBundle/Controller/WallabagCommentController.php
rename to src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php
index be11f22601f93c5c6b0c396ebe40c3d8c73dc023..5f981eb58522f200633257fe04aa0165b98b901f 100644 (file)
@@ -1,19 +1,19 @@
 <?php
 
 <?php
 
-namespace Wallabag\CommentBundle\Controller;
+namespace Wallabag\AnnotationBundle\Controller;
 
 use FOS\RestBundle\Controller\FOSRestController;
 use Nelmio\ApiDocBundle\Annotation\ApiDoc;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
 
 use FOS\RestBundle\Controller\FOSRestController;
 use Nelmio\ApiDocBundle\Annotation\ApiDoc;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
-use Wallabag\CommentBundle\Entity\Comment;
+use Wallabag\AnnotationBundle\Entity\Annotation;
 use Wallabag\CoreBundle\Entity\Entry;
 
 use Wallabag\CoreBundle\Entity\Entry;
 
-class WallabagCommentController extends FOSRestController
+class WallabagAnnotationController extends FOSRestController
 {
     /**
 {
     /**
-     * Retrieve comments for an entry.
+     * Retrieve annotations for an entry.
      *
      * @ApiDoc(
      *      requirements={
      *
      * @ApiDoc(
      *      requirements={
@@ -25,27 +25,27 @@ class WallabagCommentController extends FOSRestController
      */
     public function getAnnotationsAction(Entry $entry)
     {
      */
     public function getAnnotationsAction(Entry $entry)
     {
-        $commentRows = $this
+        $annotationRows = $this
                 ->getDoctrine()
                 ->getDoctrine()
-                ->getRepository('WallabagCommentBundle:Comment')
-                ->findCommentsByPageId($entry->getId(), $this->getUser()->getId());
-        $total = count($commentRows);
-        $comments = array('total' => $total, 'rows' => $commentRows);
+                ->getRepository('WallabagAnnotationBundle:Annotation')
+                ->findAnnotationsByPageId($entry->getId(), $this->getUser()->getId());
+        $total = count($annotationRows);
+        $annotations = array('total' => $total, 'rows' => $annotationRows);
 
 
-        $json = $this->get('serializer')->serialize($comments, 'json');
+        $json = $this->get('serializer')->serialize($annotations, 'json');
 
         return $this->renderJsonResponse($json);
     }
 
     /**
 
         return $this->renderJsonResponse($json);
     }
 
     /**
-     * Creates a new comment.
+     * Creates a new annotation.
      *
      * @param Entry $entry
      *
      * @ApiDoc(
      *      requirements={
      *          {"name"="ranges", "dataType"="array", "requirement"="\w+", "description"="The range array for the annotation"},
      *
      * @param Entry $entry
      *
      * @ApiDoc(
      *      requirements={
      *          {"name"="ranges", "dataType"="array", "requirement"="\w+", "description"="The range array for the annotation"},
-     *          {"name"="quote", "dataType"="string", "required"=false, "description"="Optional, quote for the comment"},
+     *          {"name"="quote", "dataType"="string", "required"=false, "description"="Optional, quote for the annotation"},
      *          {"name"="text", "dataType"="string", "required"=true, "description"=""},
      *      }
      * )
      *          {"name"="text", "dataType"="string", "required"=true, "description"=""},
      *      }
      * )
@@ -58,75 +58,75 @@ class WallabagCommentController extends FOSRestController
 
         $em = $this->getDoctrine()->getManager();
 
 
         $em = $this->getDoctrine()->getManager();
 
-        $comment = new Comment($this->getUser());
+        $annotation = new Annotation($this->getUser());
 
 
-        $comment->setText($data['text']);
+        $annotation->setText($data['text']);
         if (array_key_exists('quote', $data)) {
         if (array_key_exists('quote', $data)) {
-            $comment->setQuote($data['quote']);
+            $annotation->setQuote($data['quote']);
         }
         if (array_key_exists('ranges', $data)) {
         }
         if (array_key_exists('ranges', $data)) {
-            $comment->setRanges($data['ranges']);
+            $annotation->setRanges($data['ranges']);
         }
 
         }
 
-        $comment->setEntry($entry);
+        $annotation->setEntry($entry);
 
 
-        $em->persist($comment);
+        $em->persist($annotation);
         $em->flush();
 
         $em->flush();
 
-        $json = $this->get('serializer')->serialize($comment, 'json');
+        $json = $this->get('serializer')->serialize($annotation, 'json');
 
         return $this->renderJsonResponse($json);
     }
 
     /**
 
         return $this->renderJsonResponse($json);
     }
 
     /**
-     * Updates a comment.
+     * Updates an annotation.
      *
      * @ApiDoc(
      *      requirements={
      *
      * @ApiDoc(
      *      requirements={
-     *          {"name"="comment", "dataType"="string", "requirement"="\w+", "description"="The comment ID"}
+     *          {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
      *      }
      * )
      *
      *      }
      * )
      *
-     * @ParamConverter("comment", class="WallabagCommentBundle:Comment")
+     * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
      *
      * @return Response
      */
      *
      * @return Response
      */
-    public function putAnnotationAction(Comment $comment, Request $request)
+    public function putAnnotationAction(Annotation $annotation, Request $request)
     {
         $data = json_decode($request->getContent(), true);
 
         if (!is_null($data['text'])) {
     {
         $data = json_decode($request->getContent(), true);
 
         if (!is_null($data['text'])) {
-            $comment->setText($data['text']);
+            $annotation->setText($data['text']);
         }
 
         $em = $this->getDoctrine()->getManager();
         $em->flush();
 
         }
 
         $em = $this->getDoctrine()->getManager();
         $em->flush();
 
-        $json = $this->get('serializer')->serialize($comment, 'json');
+        $json = $this->get('serializer')->serialize($annotation, 'json');
 
         return $this->renderJsonResponse($json);
     }
 
     /**
 
         return $this->renderJsonResponse($json);
     }
 
     /**
-     * Removes a comment.
+     * Removes an annotation.
      *
      * @ApiDoc(
      *      requirements={
      *
      * @ApiDoc(
      *      requirements={
-     *          {"name"="comment", "dataType"="string", "requirement"="\w+", "description"="The comment ID"}
+     *          {"name"="annotation", "dataType"="string", "requirement"="\w+", "description"="The annotation ID"}
      *      }
      * )
      *
      *      }
      * )
      *
-     * @ParamConverter("comment", class="WallabagCommentBundle:Comment")
+     * @ParamConverter("annotation", class="WallabagAnnotationBundle:Annotation")
      *
      * @return Response
      */
      *
      * @return Response
      */
-    public function deleteAnnotationAction(Comment $comment)
+    public function deleteAnnotationAction(Annotation $annotation)
     {
         $em = $this->getDoctrine()->getManager();
     {
         $em = $this->getDoctrine()->getManager();
-        $em->remove($comment);
+        $em->remove($annotation);
         $em->flush();
 
         $em->flush();
 
-        $json = $this->get('serializer')->serialize($comment, 'json');
+        $json = $this->get('serializer')->serialize($annotation, 'json');
 
         return $this->renderJsonResponse($json);
     }
 
         return $this->renderJsonResponse($json);
     }
diff --git a/src/Wallabag/AnnotationBundle/DataFixtures/ORM/LoadAnnotationData.php b/src/Wallabag/AnnotationBundle/DataFixtures/ORM/LoadAnnotationData.php
new file mode 100644 (file)
index 0000000..20e07fa
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+namespace Wallabag\AnnotationBundle\DataFixtures\ORM;
+
+use Doctrine\Common\DataFixtures\AbstractFixture;
+use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
+use Doctrine\Common\Persistence\ObjectManager;
+use Wallabag\AnnotationBundle\Entity\Annotation;
+
+class LoadAnnotationData extends AbstractFixture implements OrderedFixtureInterface
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function load(ObjectManager $manager)
+    {
+        $annotation1 = new Annotation($this->getReference('admin-user'));
+        $annotation1->setEntry($this->getReference('entry1'));
+        $annotation1->setText('This is my annotation /o/');
+        $annotation1->setQuote('content');
+
+        $manager->persist($annotation1);
+
+        $this->addReference('annotation1', $annotation1);
+
+        $annotation2 = new Annotation($this->getReference('admin-user'));
+        $annotation2->setEntry($this->getReference('entry2'));
+        $annotation2->setText('This is my 2nd annotation /o/');
+        $annotation2->setQuote('content');
+
+        $manager->persist($annotation2);
+
+        $this->addReference('annotation2', $annotation2);
+
+        $manager->flush();
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getOrder()
+    {
+        return 35;
+    }
+}
similarity index 74%
rename from src/Wallabag/CommentBundle/DependencyInjection/Configuration.php
rename to src/Wallabag/AnnotationBundle/DependencyInjection/Configuration.php
index bc8d0615cb6473a4b1aed8153aac465010603cfc..5e4e4e9c7255cd7a55cbdd2e0514b393eb7bd131 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
 <?php
 
-namespace Wallabag\CommentBundle\DependencyInjection;
+namespace Wallabag\AnnotationBundle\DependencyInjection;
 
 use Symfony\Component\Config\Definition\Builder\TreeBuilder;
 use Symfony\Component\Config\Definition\ConfigurationInterface;
 
 use Symfony\Component\Config\Definition\Builder\TreeBuilder;
 use Symfony\Component\Config\Definition\ConfigurationInterface;
@@ -13,7 +13,7 @@ class Configuration implements ConfigurationInterface
     public function getConfigTreeBuilder()
     {
         $treeBuilder = new TreeBuilder();
     public function getConfigTreeBuilder()
     {
         $treeBuilder = new TreeBuilder();
-        $rootNode = $treeBuilder->root('wallabag_comment');
+        $rootNode = $treeBuilder->root('wallabag_annotation');
 
         return $treeBuilder;
     }
 
         return $treeBuilder;
     }
similarity index 77%
rename from src/Wallabag/CommentBundle/DependencyInjection/WallabagCommentExtension.php
rename to src/Wallabag/AnnotationBundle/DependencyInjection/WallabagAnnotationExtension.php
index 6b05fa0015b3fbee9e0553b97f59119b9f898e5e..159576d674d05ccb5d7846b760597b79c9a2abe1 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 
 <?php
 
-namespace Wallabag\CommentBundle\DependencyInjection;
+namespace Wallabag\AnnotationBundle\DependencyInjection;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\HttpKernel\DependencyInjection\Extension;
 
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\HttpKernel\DependencyInjection\Extension;
 
-class WallabagCommentExtension extends Extension
+class WallabagAnnotationExtension extends Extension
 {
     /**
      * {@inheritdoc}
 {
     /**
      * {@inheritdoc}
similarity index 91%
rename from src/Wallabag/CommentBundle/Entity/Comment.php
rename to src/Wallabag/AnnotationBundle/Entity/Annotation.php
index a89a2cb39950eec3af884304c1dcef1fede4c22d..db9590b076c526aea25a93efc6d617eb00d6ccc3 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
 <?php
 
-namespace Wallabag\CommentBundle\Entity;
+namespace Wallabag\AnnotationBundle\Entity;
 
 use Doctrine\ORM\Mapping as ORM;
 use JMS\Serializer\Annotation\ExclusionPolicy;
 
 use Doctrine\ORM\Mapping as ORM;
 use JMS\Serializer\Annotation\ExclusionPolicy;
@@ -11,14 +11,14 @@ use Wallabag\UserBundle\Entity\User;
 use Wallabag\CoreBundle\Entity\Entry;
 
 /**
 use Wallabag\CoreBundle\Entity\Entry;
 
 /**
- * Comment.
+ * Annotation.
  *
  *
- * @ORM\Table(name="comment")
- * @ORM\Entity(repositoryClass="Wallabag\CommentBundle\Repository\CommentRepository")
+ * @ORM\Table(name="annotation")
+ * @ORM\Entity(repositoryClass="Wallabag\AnnotationBundle\Repository\AnnotationRepository")
  * @ORM\HasLifecycleCallbacks()
  * @ExclusionPolicy("none")
  */
  * @ORM\HasLifecycleCallbacks()
  * @ExclusionPolicy("none")
  */
-class Comment
+class Annotation
 {
     /**
      * @var int
 {
     /**
      * @var int
@@ -74,7 +74,7 @@ class Comment
     /**
      * @Exclude
      *
     /**
      * @Exclude
      *
-     * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Entry", inversedBy="comments")
+     * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Entry", inversedBy="annotations")
      * @ORM\JoinColumn(name="entry_id", referencedColumnName="id")
      */
     private $entry;
      * @ORM\JoinColumn(name="entry_id", referencedColumnName="id")
      */
     private $entry;
@@ -102,7 +102,7 @@ class Comment
      *
      * @param string $text
      *
      *
      * @param string $text
      *
-     * @return Comment
+     * @return Annotation
      */
     public function setText($text)
     {
      */
     public function setText($text)
     {
@@ -168,7 +168,7 @@ class Comment
      *
      * @param string $quote
      *
      *
      * @param string $quote
      *
-     * @return Comment
+     * @return Annotation
      */
     public function setQuote($quote)
     {
      */
     public function setQuote($quote)
     {
@@ -192,7 +192,7 @@ class Comment
      *
      * @param array $ranges
      *
      *
      * @param array $ranges
      *
-     * @return Comment
+     * @return Annotation
      */
     public function setRanges($ranges)
     {
      */
     public function setRanges($ranges)
     {
@@ -206,7 +206,7 @@ class Comment
      *
      * @param string $user
      *
      *
      * @param string $user
      *
-     * @return Comment
+     * @return Annotation
      */
     public function setUser($user)
     {
      */
     public function setUser($user)
     {
@@ -239,12 +239,12 @@ class Comment
      *
      * @param Entry $entry
      *
      *
      * @param Entry $entry
      *
-     * @return Comment
+     * @return Annotation
      */
     public function setEntry($entry)
     {
         $this->entry = $entry;
      */
     public function setEntry($entry)
     {
         $this->entry = $entry;
-        $entry->setComment($this);
+        $entry->setAnnotation($this);
 
         return $this;
     }
 
         return $this;
     }
diff --git a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
new file mode 100644 (file)
index 0000000..c1c6e63
--- /dev/null
@@ -0,0 +1,91 @@
+<?php
+
+namespace Wallabag\AnnotationBundle\Repository;
+
+use Doctrine\ORM\EntityRepository;
+
+/**
+ * AnnotationRepository.
+ */
+class AnnotationRepository extends EntityRepository
+{
+    /**
+     * Return a query builder to used by other getBuilderFor* method.
+     *
+     * @param int $userId
+     *
+     * @return QueryBuilder
+     */
+    private function getBuilderByUser($userId)
+    {
+        return $this->createQueryBuilder('a')
+            ->leftJoin('a.user', 'u')
+            ->andWhere('u.id = :userId')->setParameter('userId', $userId)
+            ->orderBy('a.id', 'desc')
+        ;
+    }
+
+    /**
+     * Retrieves all annotations for a user.
+     *
+     * @param int $userId
+     *
+     * @return QueryBuilder
+     */
+    public function getBuilderForAllByUser($userId)
+    {
+        return $this
+            ->getBuilderByUser($userId)
+        ;
+    }
+
+    /**
+     * Get annotation for this id.
+     *
+     * @param int $annotationId
+     *
+     * @return array
+     */
+    public function findAnnotationById($annotationId)
+    {
+        return $this->createQueryBuilder('a')
+            ->andWhere('a.id = :annotationId')->setParameter('annotationId', $annotationId)
+            ->getQuery()->getSingleResult()
+        ;
+    }
+
+    /**
+     * Find annotations for entry id.
+     *
+     * @param int $entryId
+     * @param int $userId
+     *
+     * @return array
+     */
+    public function findAnnotationsByPageId($entryId, $userId)
+    {
+        return $this->createQueryBuilder('a')
+            ->where('a.entry = :entryId')->setParameter('entryId', $entryId)
+            ->andwhere('a.user = :userId')->setParameter('userId', $userId)
+            ->getQuery()->getResult()
+        ;
+    }
+
+    /**
+     * Find last annotation for a given entry id. Used only for tests.
+     *
+     * @param int $entryId
+     *
+     * @return array
+     */
+    public function findLastAnnotationByPageId($entryId, $userId)
+    {
+        return $this->createQueryBuilder('a')
+            ->where('a.entry = :entryId')->setParameter('entryId', $entryId)
+            ->andwhere('a.user = :userId')->setParameter('userId', $userId)
+            ->orderBy('a.id', 'DESC')
+            ->setMaxResults(1)
+            ->getQuery()
+            ->getOneOrNullResult();
+    }
+}
diff --git a/src/Wallabag/AnnotationBundle/Resources/config/routing_annotations.yml b/src/Wallabag/AnnotationBundle/Resources/config/routing_annotations.yml
new file mode 100644 (file)
index 0000000..4f3a5c9
--- /dev/null
@@ -0,0 +1,4 @@
+annotations:
+  type: rest
+  resource:     "WallabagAnnotationBundle:WallabagAnnotation"
+  name_prefix:  annotations_
similarity index 55%
rename from src/Wallabag/CommentBundle/Tests/Controller/CommentControllerTest.php
rename to src/Wallabag/AnnotationBundle/Tests/Controller/AnnotationControllerTest.php
index f8b2a56f7bd6f10d3066a89e406c370658a50f95..c0efe272cda7666fff9a647e5ec2f9ff9ee45305 100644 (file)
@@ -1,31 +1,31 @@
 <?php
 
 <?php
 
-namespace Wallabag\CommentBundle\Tests\Controller;
+namespace Wallabag\AnnotationBundle\Tests\Controller;
 
 
-use Wallabag\CommentBundle\Tests\WallabagCommentTestCase;
+use Wallabag\AnnotationBundle\Tests\WallabagAnnotationTestCase;
 
 
-class CommentControllerTest extends WallabagCommentTestCase
+class AnnotationControllerTest extends WallabagAnnotationTestCase
 {
 {
-    public function testGetComments()
+    public function testGetAnnotations()
     {
     {
-        $comment = $this->client->getContainer()
+        $annotation = $this->client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->get('doctrine.orm.entity_manager')
-            ->getRepository('WallabagCommentBundle:Comment')
+            ->getRepository('WallabagAnnotationBundle:Annotation')
             ->findOneBy(array('user' => 1));
 
             ->findOneBy(array('user' => 1));
 
-        if (!$comment) {
+        if (!$annotation) {
             $this->markTestSkipped('No content found in db.');
         }
         $this->logInAs('admin');
             $this->markTestSkipped('No content found in db.');
         }
         $this->logInAs('admin');
-        $crawler = $this->client->request('GET', 'annotations/'.$comment->getEntry()->getId().'.json');
+        $crawler = $this->client->request('GET', 'annotations/'.$annotation->getEntry()->getId().'.json');
         $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
 
         $content = json_decode($this->client->getResponse()->getContent(), true);
         $this->assertEquals(1, $content['total']);
         $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
 
         $content = json_decode($this->client->getResponse()->getContent(), true);
         $this->assertEquals(1, $content['total']);
-        $this->assertEquals($comment->getText(), $content['rows'][0]['text']);
+        $this->assertEquals($annotation->getText(), $content['rows'][0]['text']);
     }
 
     }
 
-    public function testSetcomment()
+    public function testSetAnnotation()
     {
         $this->logInAs('admin');
 
     {
         $this->logInAs('admin');
 
@@ -36,7 +36,7 @@ class CommentControllerTest extends WallabagCommentTestCase
 
         $headers = array('CONTENT_TYPE' => 'application/json');
         $content = json_encode(array(
 
         $headers = array('CONTENT_TYPE' => 'application/json');
         $content = json_encode(array(
-            'text' => 'my comment',
+            'text' => 'my annotation',
             'quote' => 'my quote',
             'range' => '[{"start":"","startOffset":24,"end":"","endOffset":31}]',
             ));
             'quote' => 'my quote',
             'range' => '[{"start":"","startOffset":24,"end":"","endOffset":31}]',
             ));
@@ -44,38 +44,38 @@ class CommentControllerTest extends WallabagCommentTestCase
 
         $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
 
 
         $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
 
-        $comment = $this->client->getContainer()
+        $annotation = $this->client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->get('doctrine.orm.entity_manager')
-            ->getRepository('WallabagCommentBundle:Comment')
-            ->findLastCommentByPageId($entry->getId(), 1);
+            ->getRepository('WallabagAnnotationBundle:Annotation')
+            ->findLastAnnotationByPageId($entry->getId(), 1);
 
 
-        $this->assertEquals('my comment', $comment->getText());
+        $this->assertEquals('my annotation', $annotation->getText());
     }
 
     }
 
-    public function testEditcomment()
+    public function testEditAnnotation()
     {
     {
-        $comment = $this->client->getContainer()
+        $annotation = $this->client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->get('doctrine.orm.entity_manager')
-            ->getRepository('WallabagCommentBundle:Comment')
+            ->getRepository('WallabagAnnotationBundle:Annotation')
             ->findOneBy(array('user' => 1));
 
         $this->logInAs('admin');
 
         $headers = array('CONTENT_TYPE' => 'application/json');
         $content = json_encode(array(
             ->findOneBy(array('user' => 1));
 
         $this->logInAs('admin');
 
         $headers = array('CONTENT_TYPE' => 'application/json');
         $content = json_encode(array(
-            'text' => 'a modified comment',
+            'text' => 'a modified annotation',
             ));
             ));
-        $crawler = $this->client->request('PUT', 'annotations/'.$comment->getId().'.json', array(), array(), $headers, $content);
+        $crawler = $this->client->request('PUT', 'annotations/'.$annotation->getId().'.json', array(), array(), $headers, $content);
         $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
 
         $content = json_decode($this->client->getResponse()->getContent(), true);
 
         $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
 
         $content = json_decode($this->client->getResponse()->getContent(), true);
 
-        $this->assertEquals('a modified comment', $content['text']);
+        $this->assertEquals('a modified annotation', $content['text']);
 
 
-        $commentUpdated = $this->client->getContainer()
+        $annotationUpdated = $this->client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->get('doctrine.orm.entity_manager')
-            ->getRepository('WallabagCommentBundle:Comment')
-            ->findCommentById($comment->getId());
-        $this->assertEquals('a modified comment', $commentUpdated->getText());
+            ->getRepository('WallabagAnnotationBundle:Annotation')
+            ->findAnnotationById($annotation->getId());
+        $this->assertEquals('a modified annotation', $annotationUpdated->getText());
     }
 }
     }
 }
similarity index 94%
rename from src/Wallabag/CommentBundle/Tests/WallabagCommentTestCase.php
rename to src/Wallabag/AnnotationBundle/Tests/WallabagAnnotationTestCase.php
index f4a2ae6c50ac47514ba4202d8219f16d6ead5204..2deff6bfc728c15b98b9b2f48cffb3a83e3f95ba 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 
 <?php
 
-namespace Wallabag\CommentBundle\Tests;
+namespace Wallabag\AnnotationBundle\Tests;
 
 use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
 use Symfony\Component\BrowserKit\Cookie;
 
 
 use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
 use Symfony\Component\BrowserKit\Cookie;
 
-abstract class WallabagCommentTestCase extends WebTestCase
+abstract class WallabagAnnotationTestCase extends WebTestCase
 {
     /**
      * @var Client
 {
     /**
      * @var Client
diff --git a/src/Wallabag/AnnotationBundle/WallabagAnnotationBundle.php b/src/Wallabag/AnnotationBundle/WallabagAnnotationBundle.php
new file mode 100644 (file)
index 0000000..b64920a
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+
+namespace Wallabag\AnnotationBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+class WallabagAnnotationBundle extends Bundle
+{
+}
diff --git a/src/Wallabag/CommentBundle/DataFixtures/ORM/LoadCommentData.php b/src/Wallabag/CommentBundle/DataFixtures/ORM/LoadCommentData.php
deleted file mode 100644 (file)
index 717f486..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-namespace Wallabag\CoreBundle\DataFixtures\ORM;
-
-use Doctrine\Common\DataFixtures\AbstractFixture;
-use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
-use Doctrine\Common\Persistence\ObjectManager;
-use Wallabag\CommentBundle\Entity\Comment;
-
-class LoadCommentData extends AbstractFixture implements OrderedFixtureInterface
-{
-    /**
-     * {@inheritdoc}
-     */
-    public function load(ObjectManager $manager)
-    {
-        $comment1 = new Comment($this->getReference('admin-user'));
-        $comment1->setEntry($this->getReference('entry1'));
-        $comment1->setText('This is my comment /o/');
-        $comment1->setQuote('content');
-
-        $manager->persist($comment1);
-
-        $this->addReference('comment1', $comment1);
-
-        $comment2 = new Comment($this->getReference('admin-user'));
-        $comment2->setEntry($this->getReference('entry2'));
-        $comment2->setText('This is my 2nd comment /o/');
-        $comment2->setQuote('content');
-
-        $manager->persist($comment2);
-
-        $this->addReference('comment2', $comment2);
-
-        $manager->flush();
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function getOrder()
-    {
-        return 35;
-    }
-}
diff --git a/src/Wallabag/CommentBundle/Repository/CommentRepository.php b/src/Wallabag/CommentBundle/Repository/CommentRepository.php
deleted file mode 100644 (file)
index 15acffb..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php
-
-namespace Wallabag\CommentBundle\Repository;
-
-use Doctrine\ORM\EntityRepository;
-
-/**
- * CommentRepository.
- *
- * This class was generated by the Doctrine ORM. Add your own custom
- * repository methods below.
- */
-class CommentRepository extends EntityRepository
-{
-    /**
-     * Return a query builder to used by other getBuilderFor* method.
-     *
-     * @param int $userId
-     *
-     * @return QueryBuilder
-     */
-    private function getBuilderByUser($userId)
-    {
-        return $this->createQueryBuilder('c')
-            ->leftJoin('c.user', 'u')
-            ->andWhere('u.id = :userId')->setParameter('userId', $userId)
-            ->orderBy('c.id', 'desc')
-        ;
-    }
-
-    /**
-     * Retrieves all comments for a user.
-     *
-     * @param int $userId
-     *
-     * @return QueryBuilder
-     */
-    public function getBuilderForAllByUser($userId)
-    {
-        return $this
-            ->getBuilderByUser($userId)
-        ;
-    }
-
-    /**
-     * Get comment for this id.
-     *
-     * @param int $commentId
-     *
-     * @return array
-     */
-    public function findCommentById($commentId)
-    {
-        return $this->createQueryBuilder('c')
-            ->andWhere('c.id = :commentId')->setParameter('commentId', $commentId)
-            ->getQuery()->getSingleResult()
-        ;
-    }
-
-    /**
-     * Find comments for entry id.
-     *
-     * @param int $entryId
-     * @param int $userId
-     *
-     * @return array
-     */
-    public function findCommentsByPageId($entryId, $userId)
-    {
-        return $this->createQueryBuilder('c')
-            ->where('c.entry = :entryId')->setParameter('entryId', $entryId)
-            ->andwhere('c.user = :userId')->setParameter('userId', $userId)
-            ->getQuery()->getResult()
-        ;
-    }
-
-    /**
-     * Find last comment for a given entry id. Used only for tests.
-     *
-     * @param int $entryId
-     *
-     * @return array
-     */
-    public function findLastCommentByPageId($entryId, $userId)
-    {
-        return $this->createQueryBuilder('c')
-            ->where('c.entry = :entryId')->setParameter('entryId', $entryId)
-            ->andwhere('c.user = :userId')->setParameter('userId', $userId)
-            ->orderBy('c.id', 'DESC')
-            ->setMaxResults(1)
-            ->getQuery()
-            ->getOneOrNullResult();
-    }
-}
diff --git a/src/Wallabag/CommentBundle/Resources/config/routing_comments.yml b/src/Wallabag/CommentBundle/Resources/config/routing_comments.yml
deleted file mode 100644 (file)
index 1d3893d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-annotations:
-  type: rest
-  resource:     "WallabagCommentBundle:WallabagComment"
-  name_prefix:  annotations_
diff --git a/src/Wallabag/CommentBundle/WallabagCommentBundle.php b/src/Wallabag/CommentBundle/WallabagCommentBundle.php
deleted file mode 100644 (file)
index 8150034..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-
-namespace Wallabag\CommentBundle;
-
-use Symfony\Component\HttpKernel\Bundle\Bundle;
-
-class WallabagCommentBundle extends Bundle
-{
-}
index 5cf84f03d5ae0b5f779dc4248b63aa348d8e2cdb..bd712a0449c498ed9108bd3aac174a809a13a75d 100644 (file)
@@ -9,7 +9,7 @@ use JMS\Serializer\Annotation\Groups;
 use JMS\Serializer\Annotation\XmlRoot;
 use Symfony\Component\Validator\Constraints as Assert;
 use Wallabag\UserBundle\Entity\User;
 use JMS\Serializer\Annotation\XmlRoot;
 use Symfony\Component\Validator\Constraints as Assert;
 use Wallabag\UserBundle\Entity\User;
-use Wallabag\CommentBundle\Entity\Comment;
+use Wallabag\AnnotationBundle\Entity\Annotation;
 
 /**
  * Entry.
 
 /**
  * Entry.
@@ -99,12 +99,12 @@ class Entry
     private $updatedAt;
 
     /**
     private $updatedAt;
 
     /**
-     * @ORM\OneToMany(targetEntity="Wallabag\CommentBundle\Entity\Comment", mappedBy="entry", cascade={"persist", "remove"})
+     * @ORM\OneToMany(targetEntity="Wallabag\AnnotationBundle\Entity\Annotation", mappedBy="entry", cascade={"persist", "remove"})
      * @ORM\JoinTable
      *
      * @Groups({"entries_for_user", "export_all"})
      */
      * @ORM\JoinTable
      *
      * @Groups({"entries_for_user", "export_all"})
      */
-    private $comments;
+    private $annotations;
 
     /**
      * @var string
 
     /**
      * @var string
@@ -366,19 +366,19 @@ class Entry
     }
 
     /**
     }
 
     /**
-     * @return ArrayCollection<Comment>
+     * @return ArrayCollection<Annotation>
      */
      */
-    public function getComments()
+    public function getAnnotations()
     {
     {
-        return $this->comments;
+        return $this->annotations;
     }
 
     /**
     }
 
     /**
-     * @param Comment $comment
+     * @param Annotation $annotation
      */
      */
-    public function setComment(Comment $comment)
+    public function setAnnotation(Annotation $annotation)
     {
     {
-        $this->comments[] = $comment;
+        $this->annotations[] = $annotation;
     }
 
     /**
     }
 
     /**
index 548a164b969ec726224e9d720ebe1915a6aeef5f..e4935b9e2643f7b8a4357928baf349d03ddd453e 100644 (file)
@@ -98,7 +98,7 @@ Toggle favorite: 'Marquer comme favori'
 Delete: 'Supprimer'
 "{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."
 http://website: "http://siteweb"
 Delete: 'Supprimer'
 "{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."
 http://website: "http://siteweb"
-"{0} No annotations|{1} One annotation|]1,Inf[ %nbComments% annotations": "{0} Aucune annotation|{1} Une annotation|]1,Inf[ %nbComments% annotations"
+"{0} No annotations|{1} One annotation|]1,Inf[ %nbAnnotations% annotations": "{0} Aucune annotation|{1} Une annotation|]1,Inf[ %nbAnnotations% annotations"
 
 # Edit entry
 Edit an entry: "Éditer un article"
 
 # Edit entry
 Edit an entry: "Éditer un article"
index 817e39b8142a7736bbb7f4d6a1982e0d992eba49..9323e7873aa03a6d399363d64cd1f99125830dce 100644 (file)
@@ -29,8 +29,8 @@
             <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>
         </ul>
     </div>
             <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>
         </ul>
     </div>
-        {% set nbComments = entry.comments | length %}
-        <span class="tool link mdi-communication-comment"> {% transchoice nbComments %}{0} No annotations|{1} One annotation|]1,Inf[ %nbComments% annotations{% endtranschoice %}</span>
+        {% set nbAnnotations = entry.annotations | length %}
+        <span class="tool link mdi-communication-comment"> {% transchoice nbAnnotations %}{0} No annotations|{1} One annotation|]1,Inf[ %nbAnnotations% annotations{% endtranschoice %}</span>
         <aside class="tags">
             {% for tag in entry.tags %}
                 <span class="mdi-action-label-outline">{{ tag.label }}</span> <a href="{{ path('remove_tag', { 'entry': entry.id, 'tag': tag.id }) }}"><i>✘</i></a>
         <aside class="tags">
             {% for tag in entry.tags %}
                 <span class="mdi-action-label-outline">{{ tag.label }}</span> <a href="{{ path('remove_tag', { 'entry': entry.id, 'tag': tag.id }) }}"><i>✘</i></a>
             prefix: '',
             urls: {
                 create: '{{ path('annotations_post_annotation', { 'entry': entry.id }) }}',
             prefix: '',
             urls: {
                 create: '{{ path('annotations_post_annotation', { 'entry': entry.id }) }}',
-                update: '{{ path('annotations_put_annotation', { 'comment': 'idComment' }) }}',
-                destroy: '{{ path('annotations_delete_annotation', { 'comment': 'idComment' }) }}',
+                update: '{{ path('annotations_put_annotation', { 'annotation': 'idAnnotation' }) }}',
+                destroy: '{{ path('annotations_delete_annotation', { 'annotation': 'idAnnotation' }) }}',
                 search: '{{ path('annotations_get_annotations', { 'entry': entry.id }) }}'
             }
         });
                 search: '{{ path('annotations_get_annotations', { 'entry': entry.id }) }}'
             }
         });
index 4839c3ea4e72d7c4df9f84f6166e6957f6388a08..6f33da23c1cf0ca9778793aff0e5c8c5f7bc5050 100644 (file)
@@ -187,8 +187,8 @@ main {
         </header>
         <aside>
             <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>
         </header>
         <aside>
             <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>
-            {% set nbComments = entry.comments | length %}
-            <span class="tool link mdi-communication-comment"> {% transchoice nbComments %}{0} No annotations|{1} One annotation|]1,Inf[ %nbComments% annotations{% endtranschoice %}</span>
+            {% set nbAnnotations = entry.annotations | length %}
+            <span class="tool link mdi-communication-comment"> {% transchoice nbAnnotations %}{0} No annotations|{1} One annotation|]1,Inf[ %nbAnnotations% annotations{% endtranschoice %}</span>
             <div id="list">
                 {% for tag in entry.tags %}
                     <div class="chip">
             <div id="list">
                 {% for tag in entry.tags %}
                     <div class="chip">
@@ -221,8 +221,8 @@ app.include(annotator.storage.http, {
     prefix: '',
     urls: {
         create: '{{ path('annotations_post_annotation', { 'entry': entry.id }) }}',
     prefix: '',
     urls: {
         create: '{{ path('annotations_post_annotation', { 'entry': entry.id }) }}',
-        update: '{{ path('annotations_put_annotation', { 'comment': 'idComment' }) }}',
-        destroy: '{{ path('annotations_delete_annotation', { 'comment': 'idComment' }) }}',
+        update: '{{ path('annotations_put_annotation', { 'annotation': 'idAnnotation' }) }}',
+        destroy: '{{ path('annotations_delete_annotation', { 'annotation': 'idAnnotation' }) }}',
         search: '{{ path('annotations_get_annotations', { 'entry': entry.id }) }}'
     }
 });
         search: '{{ path('annotations_get_annotations', { 'entry': entry.id }) }}'
     }
 });