aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-12-06 14:37:42 +0100
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-12-06 14:37:42 +0100
commitf778e47283c9691d2992045e0fbcdfc6685f157f (patch)
tree00671a8b3bae635e795cbd971267da37afcbf13b
parent4886ed6d3637df0b3e16e672d58d4ef8f17dc432 (diff)
downloadwallabag-f778e47283c9691d2992045e0fbcdfc6685f157f.tar.gz
wallabag-f778e47283c9691d2992045e0fbcdfc6685f157f.tar.zst
wallabag-f778e47283c9691d2992045e0fbcdfc6685f157f.zip
[add] rss for tag
-rw-r--r--inc/poche/Poche.class.php15
-rw-r--r--index.php3
-rw-r--r--themes/default/img/default/rss.pngbin0 -> 288 bytes
-rw-r--r--themes/default/tags.twig2
4 files changed, 15 insertions, 5 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index fefbb02d..68f56d62 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -446,8 +446,11 @@ class Poche
446 ); 446 );
447 break; 447 break;
448 case 'tags': 448 case 'tags':
449 $token = $this->user->getConfigValue('token');
449 $tags = $this->store->retrieveAllTags(); 450 $tags = $this->store->retrieveAllTags();
450 $tpl_vars = array( 451 $tpl_vars = array(
452 'token' => $token,
453 'user_id' => $this->user->getId(),
451 'tags' => $tags, 454 'tags' => $tags,
452 ); 455 );
453 break; 456 break;
@@ -884,9 +887,9 @@ class Poche
884 $_SESSION['poche_user']->setConfig($currentConfig); 887 $_SESSION['poche_user']->setConfig($currentConfig);
885 } 888 }
886 889
887 public function generateFeeds($token, $user_id, $type = 'home') 890 public function generateFeeds($token, $user_id, $tag_id, $type = 'home')
888 { 891 {
889 $allowed_types = array('home', 'fav', 'archive'); 892 $allowed_types = array('home', 'fav', 'archive', 'tag');
890 $config = $this->store->getConfigUser($user_id); 893 $config = $this->store->getConfigUser($user_id);
891 894
892 if (!in_array($type, $allowed_types) || 895 if (!in_array($type, $allowed_types) ||
@@ -901,7 +904,13 @@ class Poche
901 $feed->setChannelElement('updated', date(DATE_RSS , time())); 904 $feed->setChannelElement('updated', date(DATE_RSS , time()));
902 $feed->setChannelElement('author', 'poche'); 905 $feed->setChannelElement('author', 'poche');
903 906
904 $entries = $this->store->getEntriesByView($type, $user_id); 907 if ($type == 'tag') {
908 $entries = $this->store->retrieveEntriesByTag($tag_id);
909 }
910 else {
911 $entries = $this->store->getEntriesByView($type, $user_id);
912 }
913
905 if (count($entries) > 0) { 914 if (count($entries) > 0) {
906 foreach ($entries as $entry) { 915 foreach ($entries as $entry) {
907 $newItem = $feed->createNewItem(); 916 $newItem = $feed->createNewItem();
diff --git a/index.php b/index.php
index 96f28a72..836730bf 100644
--- a/index.php
+++ b/index.php
@@ -75,7 +75,8 @@ if (isset($_GET['login'])) {
75 $poche->generateToken(); 75 $poche->generateToken();
76 } 76 }
77 else { 77 else {
78 $poche->generateFeeds($_GET['token'], $_GET['user_id'], $_GET['type']); 78 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0);
79 $poche->generateFeeds($_GET['token'], $_GET['user_id'], $tag_id, $_GET['type']);
79 } 80 }
80} 81}
81 82
diff --git a/themes/default/img/default/rss.png b/themes/default/img/default/rss.png
new file mode 100644
index 00000000..21bad1a1
--- /dev/null
+++ b/themes/default/img/default/rss.png
Binary files differ
diff --git a/themes/default/tags.twig b/themes/default/tags.twig
index e179143d..cff6b1d7 100644
--- a/themes/default/tags.twig
+++ b/themes/default/tags.twig
@@ -4,5 +4,5 @@
4{% include '_menu.twig' %} 4{% include '_menu.twig' %}
5{% endblock %} 5{% endblock %}
6{% block content %} 6{% block content %}
7{% for tag in tags %}<a href="./?view=tag&amp;id={{ tag.id }}">{{ tag.value }}</a> {% endfor %} 7{% 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 %}
8{% endblock %} \ No newline at end of file 8{% endblock %} \ No newline at end of file