mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-25 18:41:05 +00:00
Rename CommentBundle with AnnotationBundle
This commit is contained in:
parent
9eab365e28
commit
4dc872238a
22 changed files with 260 additions and 263 deletions
|
@ -35,7 +35,7 @@ class AppKernel extends Kernel
|
|||
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)) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
wallabag_comment:
|
||||
wallabag_annotation:
|
||||
type : rest
|
||||
resource: "@WallabagCommentBundle/Resources/config/routing_comments.yml"
|
||||
resource: "@WallabagAnnotationBundle/Resources/config/routing_annotations.yml"
|
||||
|
||||
wallabag_import:
|
||||
resource: "@WallabagImportBundle/Controller/"
|
||||
|
|
|
@ -3,22 +3,22 @@ Annotations
|
|||
|
||||
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
|
||||
|
||||
Then, write your comment:
|
||||
Then, write your annotation:
|
||||
|
||||
.. image:: ../../img/user/annotations_2.png
|
||||
:alt: Write your comment
|
||||
:alt: Write your annotation
|
||||
: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
|
||||
:alt: Read your comment
|
||||
:alt: Read your annotation
|
||||
:align: center
|
||||
|
||||
You can create as many comments as you wish.
|
||||
You can create as many annotations as you wish.
|
||||
|
|
|
@ -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.
|
||||
|
||||
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
|
||||
:alt: Select your text
|
||||
:alt: Sélectionnez votre texte
|
||||
:align: center
|
||||
|
||||
Ensuite, écrivez votre commentaire :
|
||||
Ensuite, écrivez votre annotation :
|
||||
|
||||
.. image:: ../../img/user/annotations_2.png
|
||||
:alt: Write your comment
|
||||
:alt: Écrivez votre annotation
|
||||
: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
|
||||
:alt: Read your comment
|
||||
:alt: Lisez votre annotation
|
||||
:align: center
|
||||
|
||||
Vous pouvez créer autant de commentaires que vous le souhaitez.
|
||||
Vous pouvez créer autant de annotations que vous le souhaitez.
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
<?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 Wallabag\CommentBundle\Entity\Comment;
|
||||
use Wallabag\AnnotationBundle\Entity\Annotation;
|
||||
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={
|
||||
|
@ -25,27 +25,27 @@ class WallabagCommentController extends FOSRestController
|
|||
*/
|
||||
public function getAnnotationsAction(Entry $entry)
|
||||
{
|
||||
$commentRows = $this
|
||||
$annotationRows = $this
|
||||
->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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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"},
|
||||
* {"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"=""},
|
||||
* }
|
||||
* )
|
||||
|
@ -58,75 +58,75 @@ class WallabagCommentController extends FOSRestController
|
|||
|
||||
$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)) {
|
||||
$comment->setQuote($data['quote']);
|
||||
$annotation->setQuote($data['quote']);
|
||||
}
|
||||
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();
|
||||
|
||||
$json = $this->get('serializer')->serialize($comment, 'json');
|
||||
$json = $this->get('serializer')->serialize($annotation, 'json');
|
||||
|
||||
return $this->renderJsonResponse($json);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a comment.
|
||||
* Updates an annotation.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
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'])) {
|
||||
$comment->setText($data['text']);
|
||||
$annotation->setText($data['text']);
|
||||
}
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->flush();
|
||||
|
||||
$json = $this->get('serializer')->serialize($comment, 'json');
|
||||
$json = $this->get('serializer')->serialize($annotation, 'json');
|
||||
|
||||
return $this->renderJsonResponse($json);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a comment.
|
||||
* Removes an annotation.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public function deleteAnnotationAction(Comment $comment)
|
||||
public function deleteAnnotationAction(Annotation $annotation)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove($comment);
|
||||
$em->remove($annotation);
|
||||
$em->flush();
|
||||
|
||||
$json = $this->get('serializer')->serialize($comment, 'json');
|
||||
$json = $this->get('serializer')->serialize($annotation, 'json');
|
||||
|
||||
return $this->renderJsonResponse($json);
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CommentBundle\DependencyInjection;
|
||||
namespace Wallabag\AnnotationBundle\DependencyInjection;
|
||||
|
||||
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();
|
||||
$rootNode = $treeBuilder->root('wallabag_comment');
|
||||
$rootNode = $treeBuilder->root('wallabag_annotation');
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CommentBundle\DependencyInjection;
|
||||
namespace Wallabag\AnnotationBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
|
||||
class WallabagCommentExtension extends Extension
|
||||
class WallabagAnnotationExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CommentBundle\Entity;
|
||||
namespace Wallabag\AnnotationBundle\Entity;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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")
|
||||
*/
|
||||
class Comment
|
||||
class Annotation
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
|
@ -74,7 +74,7 @@ class Comment
|
|||
/**
|
||||
* @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;
|
||||
|
@ -102,7 +102,7 @@ class Comment
|
|||
*
|
||||
* @param string $text
|
||||
*
|
||||
* @return Comment
|
||||
* @return Annotation
|
||||
*/
|
||||
public function setText($text)
|
||||
{
|
||||
|
@ -168,7 +168,7 @@ class Comment
|
|||
*
|
||||
* @param string $quote
|
||||
*
|
||||
* @return Comment
|
||||
* @return Annotation
|
||||
*/
|
||||
public function setQuote($quote)
|
||||
{
|
||||
|
@ -192,7 +192,7 @@ class Comment
|
|||
*
|
||||
* @param array $ranges
|
||||
*
|
||||
* @return Comment
|
||||
* @return Annotation
|
||||
*/
|
||||
public function setRanges($ranges)
|
||||
{
|
||||
|
@ -206,7 +206,7 @@ class Comment
|
|||
*
|
||||
* @param string $user
|
||||
*
|
||||
* @return Comment
|
||||
* @return Annotation
|
||||
*/
|
||||
public function setUser($user)
|
||||
{
|
||||
|
@ -239,12 +239,12 @@ class Comment
|
|||
*
|
||||
* @param Entry $entry
|
||||
*
|
||||
* @return Comment
|
||||
* @return Annotation
|
||||
*/
|
||||
public function setEntry($entry)
|
||||
{
|
||||
$this->entry = $entry;
|
||||
$entry->setComment($this);
|
||||
$entry->setAnnotation($this);
|
||||
|
||||
return $this;
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
annotations:
|
||||
type: rest
|
||||
resource: "WallabagAnnotationBundle:WallabagAnnotation"
|
||||
name_prefix: annotations_
|
|
@ -1,31 +1,31 @@
|
|||
<?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')
|
||||
->getRepository('WallabagCommentBundle:Comment')
|
||||
->getRepository('WallabagAnnotationBundle:Annotation')
|
||||
->findOneBy(array('user' => 1));
|
||||
|
||||
if (!$comment) {
|
||||
if (!$annotation) {
|
||||
$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($comment->getText(), $content['rows'][0]['text']);
|
||||
$this->assertEquals($annotation->getText(), $content['rows'][0]['text']);
|
||||
}
|
||||
|
||||
public function testSetcomment()
|
||||
public function testSetAnnotation()
|
||||
{
|
||||
$this->logInAs('admin');
|
||||
|
||||
|
@ -36,7 +36,7 @@ class CommentControllerTest extends WallabagCommentTestCase
|
|||
|
||||
$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}]',
|
||||
));
|
||||
|
@ -44,38 +44,38 @@ class CommentControllerTest extends WallabagCommentTestCase
|
|||
|
||||
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
||||
|
||||
$comment = $this->client->getContainer()
|
||||
$annotation = $this->client->getContainer()
|
||||
->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')
|
||||
->getRepository('WallabagCommentBundle:Comment')
|
||||
->getRepository('WallabagAnnotationBundle:Annotation')
|
||||
->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('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')
|
||||
->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());
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CommentBundle\Tests;
|
||||
namespace Wallabag\AnnotationBundle\Tests;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\BrowserKit\Cookie;
|
||||
|
||||
abstract class WallabagCommentTestCase extends WebTestCase
|
||||
abstract class WallabagAnnotationTestCase extends WebTestCase
|
||||
{
|
||||
/**
|
||||
* @var Client
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\AnnotationBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class WallabagAnnotationBundle extends Bundle
|
||||
{
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
annotations:
|
||||
type: rest
|
||||
resource: "WallabagCommentBundle:WallabagComment"
|
||||
name_prefix: annotations_
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CommentBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class WallabagCommentBundle extends Bundle
|
||||
{
|
||||
}
|
|
@ -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 Wallabag\CommentBundle\Entity\Comment;
|
||||
use Wallabag\AnnotationBundle\Entity\Annotation;
|
||||
|
||||
/**
|
||||
* Entry.
|
||||
|
@ -99,12 +99,12 @@ class Entry
|
|||
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"})
|
||||
*/
|
||||
private $comments;
|
||||
private $annotations;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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"
|
||||
"{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"
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
<li><a href="mailto:hello@wallabag.org?subject=Wrong%20display%20in%20wallabag&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>
|
||||
|
@ -117,8 +117,8 @@
|
|||
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 }) }}'
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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>
|
||||
{% 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">
|
||||
|
@ -221,8 +221,8 @@ app.include(annotator.storage.http, {
|
|||
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 }) }}'
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue