From ad4d1caa9e744af57ca58a4e57576533eb682d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 23 Jan 2015 16:28:37 +0100 Subject: move WallabagBundle into Wallabag:CoreBundle --- .../CoreBundle/Controller/EntryController.php | 184 +++++++++++++++++ .../CoreBundle/Controller/StaticController.php | 20 ++ .../DependencyInjection/WallabagCoreExtension.php | 22 ++ src/Wallabag/CoreBundle/Entity/Config.php | 95 +++++++++ src/Wallabag/CoreBundle/Entity/Config.php~ | 95 +++++++++ src/Wallabag/CoreBundle/Entity/Entries.php | 230 +++++++++++++++++++++ src/Wallabag/CoreBundle/Entity/Entries.php~ | 215 +++++++++++++++++++ src/Wallabag/CoreBundle/Entity/Entry.php~ | 74 +++++++ src/Wallabag/CoreBundle/Entity/Tags.php | 65 ++++++ src/Wallabag/CoreBundle/Entity/Tags.php~ | 65 ++++++ src/Wallabag/CoreBundle/Entity/TagsEntries.php | 95 +++++++++ src/Wallabag/CoreBundle/Entity/TagsEntries.php~ | 95 +++++++++ src/Wallabag/CoreBundle/Entity/Users.php | 155 ++++++++++++++ src/Wallabag/CoreBundle/Entity/Users.php~ | 155 ++++++++++++++ src/Wallabag/CoreBundle/Entity/UsersConfig.php | 125 +++++++++++ src/Wallabag/CoreBundle/Entity/UsersConfig.php~ | 125 +++++++++++ .../CoreBundle/Repository/EntriesRepository.php | 79 +++++++ .../CoreBundle/Resources/config/routing.yml | 3 + .../CoreBundle/Resources/config/services.xml | 17 ++ .../Resources/views/Entry/entries.html.twig | 47 +++++ .../Resources/views/Entry/entry.html.twig | 104 ++++++++++ .../CoreBundle/Resources/views/Entry/new.html.twig | 11 + .../Resources/views/Static/about.html.twig | 51 +++++ .../Resources/views/_bookmarklet.html.twig | 3 + .../CoreBundle/Resources/views/_footer.html.twig | 3 + .../CoreBundle/Resources/views/_head.html.twig | 40 ++++ .../CoreBundle/Resources/views/_menu.html.twig | 15 ++ .../CoreBundle/Resources/views/_messages.html.twig | 0 .../Resources/views/_save_form.html.twig | 10 + .../Resources/views/_search_form.html.twig | 9 + .../CoreBundle/Resources/views/_top.html.twig | 5 + .../CoreBundle/Resources/views/layout.html.twig | 33 +++ .../Tests/Controller/DefaultControllerTest.php | 18 ++ .../Twig/Extension/WallabagExtension.php | 41 ++++ src/Wallabag/CoreBundle/WallabagCoreBundle.php | 9 + src/Wallabag/Wallabag/Database.php | 2 +- 36 files changed, 2314 insertions(+), 1 deletion(-) create mode 100644 src/Wallabag/CoreBundle/Controller/EntryController.php create mode 100644 src/Wallabag/CoreBundle/Controller/StaticController.php create mode 100644 src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php create mode 100644 src/Wallabag/CoreBundle/Entity/Config.php create mode 100644 src/Wallabag/CoreBundle/Entity/Config.php~ create mode 100644 src/Wallabag/CoreBundle/Entity/Entries.php create mode 100644 src/Wallabag/CoreBundle/Entity/Entries.php~ create mode 100644 src/Wallabag/CoreBundle/Entity/Entry.php~ create mode 100644 src/Wallabag/CoreBundle/Entity/Tags.php create mode 100644 src/Wallabag/CoreBundle/Entity/Tags.php~ create mode 100644 src/Wallabag/CoreBundle/Entity/TagsEntries.php create mode 100644 src/Wallabag/CoreBundle/Entity/TagsEntries.php~ create mode 100644 src/Wallabag/CoreBundle/Entity/Users.php create mode 100644 src/Wallabag/CoreBundle/Entity/Users.php~ create mode 100644 src/Wallabag/CoreBundle/Entity/UsersConfig.php create mode 100644 src/Wallabag/CoreBundle/Entity/UsersConfig.php~ create mode 100644 src/Wallabag/CoreBundle/Repository/EntriesRepository.php create mode 100644 src/Wallabag/CoreBundle/Resources/config/routing.yml create mode 100644 src/Wallabag/CoreBundle/Resources/config/services.xml create mode 100644 src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig create mode 100644 src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig create mode 100644 src/Wallabag/CoreBundle/Resources/views/Entry/new.html.twig create mode 100755 src/Wallabag/CoreBundle/Resources/views/Static/about.html.twig create mode 100644 src/Wallabag/CoreBundle/Resources/views/_bookmarklet.html.twig create mode 100644 src/Wallabag/CoreBundle/Resources/views/_footer.html.twig create mode 100755 src/Wallabag/CoreBundle/Resources/views/_head.html.twig create mode 100644 src/Wallabag/CoreBundle/Resources/views/_menu.html.twig create mode 100644 src/Wallabag/CoreBundle/Resources/views/_messages.html.twig create mode 100755 src/Wallabag/CoreBundle/Resources/views/_save_form.html.twig create mode 100644 src/Wallabag/CoreBundle/Resources/views/_search_form.html.twig create mode 100755 src/Wallabag/CoreBundle/Resources/views/_top.html.twig create mode 100644 src/Wallabag/CoreBundle/Resources/views/layout.html.twig create mode 100644 src/Wallabag/CoreBundle/Tests/Controller/DefaultControllerTest.php create mode 100644 src/Wallabag/CoreBundle/Twig/Extension/WallabagExtension.php create mode 100644 src/Wallabag/CoreBundle/WallabagCoreBundle.php (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php new file mode 100644 index 00000000..2ebb416c --- /dev/null +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -0,0 +1,184 @@ +setUserId(1); + + $form = $this->createFormBuilder($entry) + ->add('url', 'url') + ->add('save', 'submit') + ->getForm(); + + $form->handleRequest($request); + + if ($form->isValid()) { + + $content = Tools::getPageContent(new Url($entry->getUrl())); + var_dump($content);die; + + $em = $this->getDoctrine()->getEntityManager(); + $em->persist($entry); + $em->flush(); + + $this->get('session')->getFlashBag()->add( + 'notice', + 'Entry saved' + ); + + return $this->redirect($this->generateUrl('homepage')); + } + + return $this->render('WallabagCoreBundle:Entry:new.html.twig', array( + 'form' => $form->createView(), + )); + } + + /** + * Shows unread entries for current user + * + * @Route("/unread", name="unread") + * @return \Symfony\Component\HttpFoundation\Response + */ + public function showUnreadAction() + { + $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entries'); + $entries = $repository->findUnreadByUser(1, 0); + + return $this->render( + 'WallabagCoreBundle:Entry:entries.html.twig', + array('entries' => $entries) + ); + } + + /** + * Shows read entries for current user + * + * @Route("/archive", name="archive") + * @return \Symfony\Component\HttpFoundation\Response + */ + public function showArchiveAction() + { + $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entries'); + $entries = $repository->findArchiveByUser(1, 0); + + return $this->render( + 'WallabagCoreBundle:Entry:entries.html.twig', + array('entries' => $entries) + ); + } + + /** + * Shows starred entries for current user + * + * @Route("/starred", name="starred") + * @return \Symfony\Component\HttpFoundation\Response + */ + public function showStarredAction() + { + $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entries'); + $entries = $repository->findStarredByUser(1, 0); + + return $this->render( + 'WallabagCoreBundle:Entry:entries.html.twig', + array('entries' => $entries) + ); + } + + /** + * Shows entry content + * + * @param Entries $entry + * @Route("/view/{id}", requirements={"id" = "\d+"}, name="view") + * @return \Symfony\Component\HttpFoundation\Response + */ + public function viewAction(Entries $entry) + { + return $this->render( + 'WallabagCoreBundle:Entry:entry.html.twig', + array('entry' => $entry) + ); + } + + /** + * Changes read status for an entry + * + * @param Request $request + * @param Entries $entry + * @Route("/archive/{id}", requirements={"id" = "\d+"}, name="archive_entry") + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + public function toggleArchiveAction(Request $request, Entries $entry) + { + $entry->toggleArchive(); + $this->getDoctrine()->getManager()->flush(); + + $this->get('session')->getFlashBag()->add( + 'notice', + 'Entry archived' + ); + + return $this->redirect($request->headers->get('referer')); + } + + /** + * Changes favorite status for an entry + * + * @param Request $request + * @param Entries $entry + * @Route("/star/{id}", requirements={"id" = "\d+"}, name="star_entry") + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + public function toggleStarAction(Request $request, Entries $entry) + { + $entry->toggleStar(); + $this->getDoctrine()->getManager()->flush(); + + $this->get('session')->getFlashBag()->add( + 'notice', + 'Entry starred' + ); + + return $this->redirect($request->headers->get('referer')); + } + + /** + * Deletes entry + * + * @param Request $request + * @param Entries $entry + * @Route("/delete/{id}", requirements={"id" = "\d+"}, name="delete_entry") + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + public function deleteEntryAction(Request $request, Entries $entry) + { + $em = $this->getDoctrine()->getEntityManager(); + $em->remove($entry); + $em->flush(); + + $this->get('session')->getFlashBag()->add( + 'notice', + 'Entry deleted' + ); + + return $this->redirect($request->headers->get('referer')); + } +} diff --git a/src/Wallabag/CoreBundle/Controller/StaticController.php b/src/Wallabag/CoreBundle/Controller/StaticController.php new file mode 100644 index 00000000..0fd19d65 --- /dev/null +++ b/src/Wallabag/CoreBundle/Controller/StaticController.php @@ -0,0 +1,20 @@ +render( + 'WallabagCoreBundle:Static:about.html.twig', + array() + ); + } +} diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php new file mode 100644 index 00000000..7cc4165e --- /dev/null +++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php @@ -0,0 +1,22 @@ +load('services.xml'); + } + + public function getAlias() + { + return 'wallabag_core'; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php new file mode 100644 index 00000000..d60b2df0 --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/Config.php @@ -0,0 +1,95 @@ +id; + } + + /** + * Set name + * + * @param string $name + * @return Config + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set value + * + * @param string $value + * @return Config + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + return $this->value; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/Config.php~ b/src/Wallabag/CoreBundle/Entity/Config.php~ new file mode 100644 index 00000000..8b692cef --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/Config.php~ @@ -0,0 +1,95 @@ +id; + } + + /** + * Set name + * + * @param string $name + * @return Config + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set value + * + * @param string $value + * @return Config + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + return $this->value; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/Entries.php b/src/Wallabag/CoreBundle/Entity/Entries.php new file mode 100644 index 00000000..712ff126 --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/Entries.php @@ -0,0 +1,230 @@ +id; + } + + /** + * Set title + * + * @param string $title + * @return Entries + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set url + * + * @param string $url + * @return Entries + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * Get url + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set isRead + * + * @param string $isRead + * @return Entries + */ + public function setIsRead($isRead) + { + $this->isRead = $isRead; + + return $this; + } + + /** + * Get isRead + * + * @return string + */ + public function getIsRead() + { + return $this->isRead; + } + + public function toggleArchive() + { + $this->isRead = $this->getIsRead() ^ 1; + return $this; + } + + /** + * Set isFav + * + * @param string $isFav + * @return Entries + */ + public function setIsFav($isFav) + { + $this->isFav = $isFav; + + return $this; + } + + /** + * Get isFav + * + * @return string + */ + public function getIsFav() + { + return $this->isFav; + } + + public function toggleStar() + { + $this->isFav = $this->getIsFav() ^ 1; + + return $this; + } + + /** + * Set content + * + * @param string $content + * @return Entries + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set userId + * + * @param string $userId + * @return Entries + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return string + */ + public function getUserId() + { + return $this->userId; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/Entries.php~ b/src/Wallabag/CoreBundle/Entity/Entries.php~ new file mode 100644 index 00000000..69c6be0d --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/Entries.php~ @@ -0,0 +1,215 @@ +id; + } + + /** + * Set title + * + * @param string $title + * @return Entries + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set url + * + * @param string $url + * @return Entries + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * Get url + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set isRead + * + * @param string $isRead + * @return Entries + */ + public function setIsRead($isRead) + { + $this->isRead = $isRead; + + return $this; + } + + /** + * Get isRead + * + * @return string + */ + public function getIsRead() + { + return $this->isRead; + } + + /** + * Set isFav + * + * @param string $isFav + * @return Entries + */ + public function setIsFav($isFav) + { + $this->isFav = $isFav; + + return $this; + } + + /** + * Get isFav + * + * @return string + */ + public function getIsFav() + { + return $this->isFav; + } + + /** + * Set content + * + * @param string $content + * @return Entries + */ + public function setContent($content) + { + $this->content = $content; + + return $this; + } + + /** + * Get content + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Set userId + * + * @param string $userId + * @return Entries + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return string + */ + public function getUserId() + { + return $this->userId; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php~ b/src/Wallabag/CoreBundle/Entity/Entry.php~ new file mode 100644 index 00000000..ebcdf53a --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/Entry.php~ @@ -0,0 +1,74 @@ +id; + } + + /** + * Set value + * + * @param string $value + * @return Tags + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + return $this->value; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/Tags.php~ b/src/Wallabag/CoreBundle/Entity/Tags.php~ new file mode 100644 index 00000000..c0c78ee5 --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/Tags.php~ @@ -0,0 +1,65 @@ +id; + } + + /** + * Set value + * + * @param string $value + * @return Tags + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + return $this->value; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/TagsEntries.php b/src/Wallabag/CoreBundle/Entity/TagsEntries.php new file mode 100644 index 00000000..ad01cf57 --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/TagsEntries.php @@ -0,0 +1,95 @@ +id; + } + + /** + * Set entryId + * + * @param integer $entryId + * @return TagsEntries + */ + public function setEntryId($entryId) + { + $this->entryId = $entryId; + + return $this; + } + + /** + * Get entryId + * + * @return integer + */ + public function getEntryId() + { + return $this->entryId; + } + + /** + * Set tagId + * + * @param integer $tagId + * @return TagsEntries + */ + public function setTagId($tagId) + { + $this->tagId = $tagId; + + return $this; + } + + /** + * Get tagId + * + * @return integer + */ + public function getTagId() + { + return $this->tagId; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/TagsEntries.php~ b/src/Wallabag/CoreBundle/Entity/TagsEntries.php~ new file mode 100644 index 00000000..448c54fa --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/TagsEntries.php~ @@ -0,0 +1,95 @@ +id; + } + + /** + * Set entryId + * + * @param integer $entryId + * @return TagsEntries + */ + public function setEntryId($entryId) + { + $this->entryId = $entryId; + + return $this; + } + + /** + * Get entryId + * + * @return integer + */ + public function getEntryId() + { + return $this->entryId; + } + + /** + * Set tagId + * + * @param integer $tagId + * @return TagsEntries + */ + public function setTagId($tagId) + { + $this->tagId = $tagId; + + return $this; + } + + /** + * Get tagId + * + * @return integer + */ + public function getTagId() + { + return $this->tagId; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/Users.php b/src/Wallabag/CoreBundle/Entity/Users.php new file mode 100644 index 00000000..3db4a3fd --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/Users.php @@ -0,0 +1,155 @@ +id; + } + + /** + * Set username + * + * @param string $username + * @return Users + */ + public function setUsername($username) + { + $this->username = $username; + + return $this; + } + + /** + * Get username + * + * @return string + */ + public function getUsername() + { + return $this->username; + } + + /** + * Set password + * + * @param string $password + * @return Users + */ + public function setPassword($password) + { + $this->password = $password; + + return $this; + } + + /** + * Get password + * + * @return string + */ + public function getPassword() + { + return $this->password; + } + + /** + * Set name + * + * @param string $name + * @return Users + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set email + * + * @param string $email + * @return Users + */ + public function setEmail($email) + { + $this->email = $email; + + return $this; + } + + /** + * Get email + * + * @return string + */ + public function getEmail() + { + return $this->email; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/Users.php~ b/src/Wallabag/CoreBundle/Entity/Users.php~ new file mode 100644 index 00000000..a48f2240 --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/Users.php~ @@ -0,0 +1,155 @@ +id; + } + + /** + * Set username + * + * @param string $username + * @return Users + */ + public function setUsername($username) + { + $this->username = $username; + + return $this; + } + + /** + * Get username + * + * @return string + */ + public function getUsername() + { + return $this->username; + } + + /** + * Set password + * + * @param string $password + * @return Users + */ + public function setPassword($password) + { + $this->password = $password; + + return $this; + } + + /** + * Get password + * + * @return string + */ + public function getPassword() + { + return $this->password; + } + + /** + * Set name + * + * @param string $name + * @return Users + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set email + * + * @param string $email + * @return Users + */ + public function setEmail($email) + { + $this->email = $email; + + return $this; + } + + /** + * Get email + * + * @return string + */ + public function getEmail() + { + return $this->email; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/UsersConfig.php b/src/Wallabag/CoreBundle/Entity/UsersConfig.php new file mode 100644 index 00000000..26fb44ee --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/UsersConfig.php @@ -0,0 +1,125 @@ +id; + } + + /** + * Set userId + * + * @param string $userId + * @return UsersConfig + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return string + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set name + * + * @param string $name + * @return UsersConfig + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set value + * + * @param string $value + * @return UsersConfig + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + return $this->value; + } +} diff --git a/src/Wallabag/CoreBundle/Entity/UsersConfig.php~ b/src/Wallabag/CoreBundle/Entity/UsersConfig.php~ new file mode 100644 index 00000000..8af283cc --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/UsersConfig.php~ @@ -0,0 +1,125 @@ +id; + } + + /** + * Set userId + * + * @param string $userId + * @return UsersConfig + */ + public function setUserId($userId) + { + $this->userId = $userId; + + return $this; + } + + /** + * Get userId + * + * @return string + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set name + * + * @param string $name + * @return UsersConfig + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set value + * + * @param string $value + * @return UsersConfig + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * Get value + * + * @return string + */ + public function getValue() + { + return $this->value; + } +} diff --git a/src/Wallabag/CoreBundle/Repository/EntriesRepository.php b/src/Wallabag/CoreBundle/Repository/EntriesRepository.php new file mode 100644 index 00000000..5a71b9ef --- /dev/null +++ b/src/Wallabag/CoreBundle/Repository/EntriesRepository.php @@ -0,0 +1,79 @@ +createQueryBuilder('e') + ->select('e') + ->setFirstResult($firstResult) + ->setMaxResults($maxResults) + ->where('e.isRead = 0') + ->andWhere('e.userId =:userId')->setParameter('userId', $userId) + ->getQuery(); + + $paginator = new Paginator($qb); + + return $paginator; + } + + /** + * Retrieves read entries for a user + * + * @param $userId + * @param $firstResult + * @param int $maxResults + * @return Paginator + */ + public function findArchiveByUser($userId, $firstResult, $maxResults = 12) + { + $qb = $this->createQueryBuilder('e') + ->select('e') + ->setFirstResult($firstResult) + ->setMaxResults($maxResults) + ->where('e.isRead = 1') + ->andWhere('e.userId =:userId')->setParameter('userId', $userId) + ->getQuery(); + + $paginator = new Paginator($qb); + + return $paginator; + } + + /** + * Retrieves starred entries for a user + * + * @param $userId + * @param $firstResult + * @param int $maxResults + * @return Paginator + */ + public function findStarredByUser($userId, $firstResult, $maxResults = 12) + { + $qb = $this->createQueryBuilder('e') + ->select('e') + ->setFirstResult($firstResult) + ->setMaxResults($maxResults) + ->where('e.isFav = 1') + ->andWhere('e.userId =:userId')->setParameter('userId', $userId) + ->getQuery(); + + $paginator = new Paginator($qb); + + return $paginator; + } +} diff --git a/src/Wallabag/CoreBundle/Resources/config/routing.yml b/src/Wallabag/CoreBundle/Resources/config/routing.yml new file mode 100644 index 00000000..327d49d8 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/config/routing.yml @@ -0,0 +1,3 @@ +_wllbg: + resource: "@WallabagCoreBundle/Controller/EntryController.php" + type: annotation \ No newline at end of file diff --git a/src/Wallabag/CoreBundle/Resources/config/services.xml b/src/Wallabag/CoreBundle/Resources/config/services.xml new file mode 100644 index 00000000..02308e6a --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/config/services.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig new file mode 100644 index 00000000..2f8423d7 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig @@ -0,0 +1,47 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title "Unread" %} + +{% block menu %} + {% include "WallabagCoreBundle::_menu.html.twig" %} +{% endblock %} + +{% block content %} + {% block pager %} + {% if entries is not empty %} +
+
{{ entries.count }} {% trans %}entries{% endtrans %}
+ +
+ {% endif %} + {% endblock %} + + {% if entries is empty %} +

{% trans %}No articles found.{% endtrans %}

+ {% else %} + {% for entry in entries %} +
+

{{ entry.title|raw }}

+ {% if entry.content| readingTime > 0 %} +
{% trans %}estimated reading time :{% endtrans %} {{ entry.content| readingTime }} min
+ {% else %} +
{% trans %}estimated reading time :{% endtrans %} < 1 min
+ {% endif %} + + +

{{ entry.content|striptags|slice(0, 300) }}...

+
+ {% endfor %} + {% endif %} +{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig new file mode 100644 index 00000000..78dfa7c0 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig @@ -0,0 +1,104 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{{ entry.title|raw }} ({{ entry.url | e | domainName }}){% endblock %} + +{% block menu %} + {% include "WallabagCoreBundle::_menu.html.twig" %} +{% endblock %} + +{% block content %} +
+ +
+
+
+

{{ entry.title|raw }}

+
+ +
+ {{ entry.content | raw }} +
+
+ + +{% endblock %} \ No newline at end of file diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/new.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/new.html.twig new file mode 100644 index 00000000..df6926a0 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/Entry/new.html.twig @@ -0,0 +1,11 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{% trans %}Save new entry{% endtrans %}{% endblock %} + +{% block menu %} + {% include "WallabagCoreBundle::_menu.html.twig" %} +{% endblock %} + +{% block content %} + {{ form(form) }} +{% endblock %} \ No newline at end of file diff --git a/src/Wallabag/CoreBundle/Resources/views/Static/about.html.twig b/src/Wallabag/CoreBundle/Resources/views/Static/about.html.twig new file mode 100755 index 00000000..0585ecca --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/Static/about.html.twig @@ -0,0 +1,51 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title %}{% trans %}About{% endtrans %}{% endblock %} +{% block menu %} +{% include "WallabagCoreBundle::_menu.html.twig" %} +{% endblock %} +{% block content %} +

{% trans %}About wallabag{% endtrans %}

+ +
+
{% trans %}Project website{% endtrans %}
+
https://www.wallabag.org
+ +
{% trans %}Main developer{% endtrans %}
+
Nicolas Lœuillet{% trans %}website{% endtrans %}
+ +
{% trans %}Contributors ♥:{% endtrans %}
+
{% trans %}on Github{% endtrans %}
+ +
{% trans %}Bug reports{% endtrans %}
+
{% trans %}On our support website{% endtrans %} {% trans %}or{% endtrans %} {% trans %}on Github{% endtrans %}
+ +
{% trans %}License{% endtrans %}
+
MIT
+ +
{% trans %}Version{% endtrans %}
+
{{ version }}
+
+ +

{% trans %}wallabag is a read-it-later application: you can save a web page by keeping only content. Elements like ads or menus are deleted.{% endtrans %}

+ +

{% trans %}Getting help{% endtrans %}

+ +
+
{% trans %}Documentation{% endtrans %}
+
Online documentation
+ +
{% trans %}Support{% endtrans %}
+
http://support.wallabag.org/
+
+ +

{% trans %}Helping wallabag{% endtrans %}

+ +

{% trans %}wallabag is free and opensource. You can help us:{% endtrans %}

+ +
+
{% trans %}via Paypal{% endtrans %}
+ +
{% trans %}via Flattr{% endtrans %}
+
+{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/_bookmarklet.html.twig b/src/Wallabag/CoreBundle/Resources/views/_bookmarklet.html.twig new file mode 100644 index 00000000..d432909a --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/_bookmarklet.html.twig @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/src/Wallabag/CoreBundle/Resources/views/_footer.html.twig b/src/Wallabag/CoreBundle/Resources/views/_footer.html.twig new file mode 100644 index 00000000..c897a97e --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/_footer.html.twig @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/src/Wallabag/CoreBundle/Resources/views/_head.html.twig b/src/Wallabag/CoreBundle/Resources/views/_head.html.twig new file mode 100755 index 00000000..7ef79a2f --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/_head.html.twig @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Wallabag/CoreBundle/Resources/views/_menu.html.twig b/src/Wallabag/CoreBundle/Resources/views/_menu.html.twig new file mode 100644 index 00000000..d4560e84 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/_menu.html.twig @@ -0,0 +1,15 @@ + + + diff --git a/src/Wallabag/CoreBundle/Resources/views/_messages.html.twig b/src/Wallabag/CoreBundle/Resources/views/_messages.html.twig new file mode 100644 index 00000000..e69de29b diff --git a/src/Wallabag/CoreBundle/Resources/views/_save_form.html.twig b/src/Wallabag/CoreBundle/Resources/views/_save_form.html.twig new file mode 100755 index 00000000..acaa5dbc --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/_save_form.html.twig @@ -0,0 +1,10 @@ + diff --git a/src/Wallabag/CoreBundle/Resources/views/_search_form.html.twig b/src/Wallabag/CoreBundle/Resources/views/_search_form.html.twig new file mode 100644 index 00000000..7eb1b67d --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/_search_form.html.twig @@ -0,0 +1,9 @@ + diff --git a/src/Wallabag/CoreBundle/Resources/views/_top.html.twig b/src/Wallabag/CoreBundle/Resources/views/_top.html.twig new file mode 100755 index 00000000..34d925df --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/_top.html.twig @@ -0,0 +1,5 @@ +
+

+ {% block logo %}wallabag logo{% endblock %} +

+
diff --git a/src/Wallabag/CoreBundle/Resources/views/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/layout.html.twig new file mode 100644 index 00000000..83830a4a --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/layout.html.twig @@ -0,0 +1,33 @@ + + + + + + + + + + + {% block title %}{% endblock %} - wallabag + {% include "WallabagCoreBundle::_head.html.twig" %} + {% include "WallabagCoreBundle::_bookmarklet.html.twig" %} + + +{% include "WallabagCoreBundle::_top.html.twig" %} +
+ {% block menu %}{% endblock %} + {% block precontent %}{% endblock %} + {% for flashMessage in app.session.flashbag.get('notice') %} +
+ {{ flashMessage }} +
+ {% endfor %} +
+ {% block content %}{% endblock %} +
+
+{% include "WallabagCoreBundle::_footer.html.twig" %} + + \ No newline at end of file diff --git a/src/Wallabag/CoreBundle/Tests/Controller/DefaultControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/DefaultControllerTest.php new file mode 100644 index 00000000..af20f31f --- /dev/null +++ b/src/Wallabag/CoreBundle/Tests/Controller/DefaultControllerTest.php @@ -0,0 +1,18 @@ +request('GET', '/app/index'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertTrue($crawler->filter('html:contains("Homepage")')->count() > 0); + } +} diff --git a/src/Wallabag/CoreBundle/Twig/Extension/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/Extension/WallabagExtension.php new file mode 100644 index 00000000..0b004a30 --- /dev/null +++ b/src/Wallabag/CoreBundle/Twig/Extension/WallabagExtension.php @@ -0,0 +1,41 @@ +