]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
[add] rss for tag
authorNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Fri, 6 Dec 2013 13:37:42 +0000 (14:37 +0100)
committerNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Fri, 6 Dec 2013 13:37:42 +0000 (14:37 +0100)
inc/poche/Poche.class.php
index.php
themes/default/img/default/rss.png [new file with mode: 0644]
themes/default/tags.twig

index fefbb02dd24d3a5c25c90ff8910d84f278cb2065..68f56d623999c5f1c2ed7a6143f4ebc39e1d4b9f 100644 (file)
@@ -446,8 +446,11 @@ class Poche
                 );
                 break;
             case 'tags':
+                $token = $this->user->getConfigValue('token');
                 $tags = $this->store->retrieveAllTags();
                 $tpl_vars = array(
+                    'token' => $token,
+                    'user_id' => $this->user->getId(),
                     'tags' => $tags,
                 );
                 break;
@@ -884,9 +887,9 @@ class Poche
         $_SESSION['poche_user']->setConfig($currentConfig);
     }
 
-    public function generateFeeds($token, $user_id, $type = 'home')
+    public function generateFeeds($token, $user_id, $tag_id, $type = 'home')
     {
-        $allowed_types = array('home', 'fav', 'archive');
+        $allowed_types = array('home', 'fav', 'archive', 'tag');
         $config = $this->store->getConfigUser($user_id);
 
         if (!in_array($type, $allowed_types) ||
@@ -901,7 +904,13 @@ class Poche
         $feed->setChannelElement('updated', date(DATE_RSS , time()));
         $feed->setChannelElement('author', 'poche');
 
-        $entries = $this->store->getEntriesByView($type, $user_id);
+        if ($type == 'tag') {
+            $entries = $this->store->retrieveEntriesByTag($tag_id);
+        }
+        else {
+            $entries = $this->store->getEntriesByView($type, $user_id);
+        }
+
         if (count($entries) > 0) {
             foreach ($entries as $entry) {
                 $newItem = $feed->createNewItem();
index 96f28a72936368b47352e875eb08de6fd76cb7e1..836730bfcfb1be02ed91e8df82e824b85c710ba7 100644 (file)
--- a/index.php
+++ b/index.php
@@ -75,7 +75,8 @@ if (isset($_GET['login'])) {
         $poche->generateToken();
     }
     else {
-        $poche->generateFeeds($_GET['token'], $_GET['user_id'], $_GET['type']);
+        $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0);
+        $poche->generateFeeds($_GET['token'], $_GET['user_id'], $tag_id, $_GET['type']);
     }
 }
 
diff --git a/themes/default/img/default/rss.png b/themes/default/img/default/rss.png
new file mode 100644 (file)
index 0000000..21bad1a
Binary files /dev/null and b/themes/default/img/default/rss.png differ
index e179143df9408e8598a2e5b1915140e65df2b0db..cff6b1d74c13430de365c45fbbfd27b9c70ea2c4 100644 (file)
@@ -4,5 +4,5 @@
 {% include '_menu.twig' %}
 {% endblock %}
 {% block content %}
-{% for tag in tags %}<a href="./?view=tag&amp;id={{ tag.id }}">{{ tag.value }}</a> {% endfor %}
+{% for tag in tags %}<a href="./?view=tag&amp;id={{ tag.id }}">{{ tag.value }}</a> {% if token != '' %}<a href="?feed&amp;type=tag&amp;user_id={{ user_id }}&amp;tag_id={{ tag.id }}&amp;token={{ token }}" target="_blank"><img src="{{ poche_url }}/themes/{{ theme }}/img/{{ theme }}/rss.png" /></a>{% endif %} {% endfor %}
 {% endblock %}
\ No newline at end of file