aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas.loeuillet@gmail.com>2013-12-06 14:22:29 +0100
committerNicolas Lœuillet <nicolas.loeuillet@gmail.com>2013-12-06 14:22:29 +0100
commit4886ed6d3637df0b3e16e672d58d4ef8f17dc432 (patch)
tree2e4255655a218eb7d42522ff3009a2826b03d002
parent74ec445a662aa31f713bc50e74c9366da336538a (diff)
downloadwallabag-4886ed6d3637df0b3e16e672d58d4ef8f17dc432.tar.gz
wallabag-4886ed6d3637df0b3e16e672d58d4ef8f17dc432.tar.zst
wallabag-4886ed6d3637df0b3e16e672d58d4ef8f17dc432.zip
[add] page which lists entries for a tag
-rw-r--r--inc/poche/Database.class.php21
-rw-r--r--inc/poche/Poche.class.php8
-rw-r--r--inc/poche/Tools.class.php2
-rw-r--r--themes/default/tag.twig33
-rw-r--r--themes/default/tags.twig2
-rw-r--r--themes/default/view.twig2
6 files changed, 65 insertions, 3 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index 8e9ee0b7..a89bce41 100644
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -258,6 +258,27 @@ class Database {
258 return $tags; 258 return $tags;
259 } 259 }
260 260
261 public function retrieveTag($id) {
262 $tag = NULL;
263 $sql = "SELECT * FROM tags WHERE id=?";
264 $params = array(intval($id));
265 $query = $this->executeQuery($sql, $params);
266 $tag = $query->fetchAll();
267
268 return isset($tag[0]) ? $tag[0] : null;
269 }
270
271 public function retrieveEntriesByTag($tag_id) {
272 $sql =
273 "SELECT * FROM entries
274 LEFT JOIN tags_entries ON tags_entries.entry_id=entries.id
275 WHERE tags_entries.tag_id = ?";
276 $query = $this->executeQuery($sql, array($tag_id));
277 $entries = $query->fetchAll();
278
279 return $entries;
280 }
281
261 public function retrieveTagsByEntry($entry_id) { 282 public function retrieveTagsByEntry($entry_id) {
262 $sql = 283 $sql =
263 "SELECT * FROM tags 284 "SELECT * FROM tags
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 5d368842..fefbb02d 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -437,6 +437,14 @@ class Poche
437 'tags' => $tags, 437 'tags' => $tags,
438 ); 438 );
439 break; 439 break;
440 case 'tag':
441 $entries = $this->store->retrieveEntriesByTag($id);
442 $tag = $this->store->retrieveTag($id);
443 $tpl_vars = array(
444 'tag' => $tag,
445 'entries' => $entries,
446 );
447 break;
440 case 'tags': 448 case 'tags':
441 $tags = $this->store->retrieveAllTags(); 449 $tags = $this->store->retrieveAllTags();
442 $tpl_vars = array( 450 $tpl_vars = array(
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php
index b0ef55f5..6da53023 100644
--- a/inc/poche/Tools.class.php
+++ b/inc/poche/Tools.class.php
@@ -90,7 +90,7 @@ class Tools
90 { 90 {
91 $views = array( 91 $views = array(
92 'install', 'import', 'export', 'config', 'tags', 92 'install', 'import', 'export', 'config', 'tags',
93 'edit-tags', 'view', 'login', 'error' 93 'edit-tags', 'view', 'login', 'error', 'tag'
94 ); 94 );
95 95
96 if (in_array($view, $views)) { 96 if (in_array($view, $views)) {
diff --git a/themes/default/tag.twig b/themes/default/tag.twig
new file mode 100644
index 00000000..364c7cd4
--- /dev/null
+++ b/themes/default/tag.twig
@@ -0,0 +1,33 @@
1{% extends "layout.twig" %}
2{% block title %}tag {% endblock %}
3{% block menu %}
4{% include '_menu.twig' %}
5{% endblock %}
6{% block content %}
7 <h3>{% trans "Tag" %} {{ tag.value }}</h3>
8 {% if entries is empty %}
9 <div class="messages warning"><p>{% trans "No link available here!" %}</p></div>
10 {% else %}
11 {% block pager %}
12 {% if nb_results > 1 %}
13 <div class="results">
14 <div class="nb-results">{{ nb_results }} {% trans "results" %}</div>
15 {{ page_links | raw }}
16 </div>
17 {% endif %}
18 {% endblock %}
19 {% for entry in entries %}
20 <div id="entry-{{ entry.id|e }}" class="entrie">
21 <h2><a href="index.php?view=view&amp;id={{ entry.id|e }}">{{ entry.title|raw }}</a></h2>
22 <ul class="tools">
23 <li><a title="{% trans "toggle mark as read" %}" class="tool {% if entry.is_read == 0 %}archive-off{% else %}archive{% endif %}" href="./?action=toggle_archive&amp;id={{ entry.id|e }}"><span>{% trans "toggle mark as read" %}</span></a></li>
24 <li><a title="{% trans "toggle favorite" %}" class="tool {% if entry.is_fav == 0 %}fav-off{% else %}fav{% endif %}" href="./?action=toggle_fav&amp;id={{ entry.id|e }}"><span>{% trans "toggle favorite" %}</span></a></li>
25 <li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&amp;id={{ entry.id|e }}"><span>{% trans "delete" %}</span></a></li>
26 <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}" class="tool link"><span>{{ entry.url | e | getDomain }}</span></a></li>
27 <li><a target="_blank" title="{% trans "estimated reading time:" %} {{ entry.content| getReadingTime }} min" class="reading-time"><span>{{ entry.content| getReadingTime }} min</span></a></li>
28 </ul>
29 <p>{{ entry.content|striptags|slice(0, 300) }}...</p>
30 </div>
31 {% endfor %}
32 {% endif %}
33{% endblock %} \ No newline at end of file
diff --git a/themes/default/tags.twig b/themes/default/tags.twig
index 9421fe3e..e179143d 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="#">{{ tag.value }}</a> {% endfor %} 7{% for tag in tags %}<a href="./?view=tag&amp;id={{ tag.id }}">{{ tag.value }}</a> {% endfor %}
8{% endblock %} \ No newline at end of file 8{% endblock %} \ No newline at end of file
diff --git a/themes/default/view.twig b/themes/default/view.twig
index 9f9e23c8..7e096a95 100644
--- a/themes/default/view.twig
+++ b/themes/default/view.twig
@@ -21,7 +21,7 @@
21 <h1>{{ entry.title|raw }}</h1> 21 <h1>{{ entry.title|raw }}</h1>
22 </header> 22 </header>
23 <aside class="tags"> 23 <aside class="tags">
24 tags: {% for tag in tags %}<a href="#">{{ tag.value }}</a> {% endfor %}<a href="./?&amp;view=edit-tags&amp;id={{ entry.id|e }}" title="{% trans "edit tags" %}">✎</a> 24 tags: {% for tag in tags %}<a href="#">{{ tag.value }}</a> {% endfor %}<a href="./?view=edit-tags&amp;id={{ entry.id|e }}" title="{% trans "edit tags" %}">✎</a>
25 </aside> 25 </aside>
26 <article> 26 <article>
27 {{ content | raw }} 27 {{ content | raw }}