aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorAlexandr Danilov <bitbucket@modos189.ru>2015-08-10 12:27:12 +0300
committerAlexandr Danilov <bitbucket@modos189.ru>2015-08-10 12:27:12 +0300
commit4919584b8758b23e127536b686776c1c41b3d215 (patch)
tree80288df2d6588fd84d0d028fe0ea652131a48c9a /src/Wallabag
parent946d6a512470613aa5ffa556b6547397064dd89f (diff)
parent47cadf36c8f7c20ba1edf26e184637d33a52cf35 (diff)
downloadwallabag-4919584b8758b23e127536b686776c1c41b3d215.tar.gz
wallabag-4919584b8758b23e127536b686776c1c41b3d215.tar.zst
wallabag-4919584b8758b23e127536b686776c1c41b3d215.zip
Merge remote-tracking branch 'origin/v2' into v2_fix_material
# Conflicts: # src/Wallabag/CoreBundle/Resources/views/themes/material/base.html.twig
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php31
-rw-r--r--src/Wallabag/CoreBundle/Repository/TagRepository.php18
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig13
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/base.html.twig2
-rw-r--r--src/Wallabag/CoreBundle/Service/Extractor.php2
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php19
6 files changed, 83 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
new file mode 100644
index 00000000..e448cea1
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -0,0 +1,31 @@
1<?php
2
3namespace Wallabag\CoreBundle\Controller;
4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
8class TagController extends Controller
9{
10 /**
11 * Shows tags for current user.
12 *
13 * @Route("/tag/list", name="tag")
14 *
15 * @return \Symfony\Component\HttpFoundation\Response
16 */
17 public function showTagAction()
18 {
19 $tags = $this->getDoctrine()
20 ->getRepository('WallabagCoreBundle:Tag')
21 ->findTags($this->getUser()->getId());
22
23 return $this->render(
24 'WallabagCoreBundle:Tag:tags.html.twig',
25 array(
26 'tags' => $tags
27 )
28 );
29 }
30
31}
diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php
index 52f319f1..51f1cd42 100644
--- a/src/Wallabag/CoreBundle/Repository/TagRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php
@@ -3,7 +3,25 @@
3namespace Wallabag\CoreBundle\Repository; 3namespace Wallabag\CoreBundle\Repository;
4 4
5use Doctrine\ORM\EntityRepository; 5use Doctrine\ORM\EntityRepository;
6use Pagerfanta\Adapter\DoctrineORMAdapter;
7use Pagerfanta\Pagerfanta;
6 8
7class TagRepository extends EntityRepository 9class TagRepository extends EntityRepository
8{ 10{
11 /**
12 * Find Tags.
13 *
14 * @param int $userId
15 *
16 * @return array
17 */
18 public function findTags($userId)
19 {
20 $qb = $this->createQueryBuilder('t')
21 ->where('t.user =:userId')->setParameter('userId', $userId);
22
23 $pagerAdapter = new DoctrineORMAdapter($qb);
24
25 return new Pagerfanta($pagerAdapter);
26 }
9} 27}
diff --git a/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig b/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig
new file mode 100644
index 00000000..c2a461b8
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig
@@ -0,0 +1,13 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title "Tags" %}
4
5{% block content %}
6 {% if tags is empty %}
7 <div class="messages warning"><p>{% trans %}No tags found.{% endtrans %}</p></div>
8 {% else %}
9 {% for tag in tags %}
10 {{tag.label}}
11 {% endfor %}
12 {% endif %}
13{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig
index f17feedd..162fb463 100644
--- a/src/Wallabag/CoreBundle/Resources/views/base.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig
@@ -71,7 +71,7 @@
71 <li><a href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li> 71 <li><a href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li>
72 <li><a href="{{ path('starred') }}">{% trans %}favorites{% endtrans %}</a></li> 72 <li><a href="{{ path('starred') }}">{% trans %}favorites{% endtrans %}</a></li>
73 <li><a href="{{ path('archive') }}"}>{% trans %}archive{% endtrans %}</a></li> 73 <li><a href="{{ path('archive') }}"}>{% trans %}archive{% endtrans %}</a></li>
74 <li><a href="?view=tags">{% trans %}tags{% endtrans %}</a></li> 74 <li><a href="{{ path ('tag') }}">{% trans %}tags{% endtrans %}</a></li>
75 <li><a href="{{ path('new_entry') }}">{% trans %}save a link{% endtrans %}</a></li> 75 <li><a href="{{ path('new_entry') }}">{% trans %}save a link{% endtrans %}</a></li>
76 <li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a> 76 <li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a>
77 <div id="search-form" class="messages info popup-form"> 77 <div id="search-form" class="messages info popup-form">
diff --git a/src/Wallabag/CoreBundle/Service/Extractor.php b/src/Wallabag/CoreBundle/Service/Extractor.php
index 6d43a1da..961ac20a 100644
--- a/src/Wallabag/CoreBundle/Service/Extractor.php
+++ b/src/Wallabag/CoreBundle/Service/Extractor.php
@@ -10,7 +10,7 @@ final class Extractor
10 public static function extract($url) 10 public static function extract($url)
11 { 11 {
12 $pageContent = self::getPageContent(new Url(base64_encode($url))); 12 $pageContent = self::getPageContent(new Url(base64_encode($url)));
13 $title = $pageContent['rss']['channel']['item']['title'] ?: 'Untitled'; 13 $title = $pageContent['rss']['channel']['item']['title'] ?: parse_url($url, PHP_URL_HOST);
14 $body = $pageContent['rss']['channel']['item']['description']; 14 $body = $pageContent['rss']['channel']['item']['description'];
15 15
16 $content = new Content(); 16 $content = new Content();
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php
new file mode 100644
index 00000000..34faf709
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php
@@ -0,0 +1,19 @@
1<?php
2
3namespace Wallabag\CoreBundle\Tests\Controller;
4
5use Wallabag\CoreBundle\Tests\WallabagCoreTestCase;
6use Doctrine\ORM\AbstractQuery;
7
8class TagControllerTest extends WallabagCoreTestCase
9{
10 public function testList()
11 {
12 $this->logInAs('admin');
13 $client = $this->getClient();
14
15 $client->request('GET', '/tag/list');
16
17 $this->assertEquals(200, $client->getResponse()->getStatusCode());
18 }
19}