]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
[add] page which lists entries for a tag
authorNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Fri, 6 Dec 2013 13:22:29 +0000 (14:22 +0100)
committerNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Fri, 6 Dec 2013 13:22:29 +0000 (14:22 +0100)
inc/poche/Database.class.php
inc/poche/Poche.class.php
inc/poche/Tools.class.php
themes/default/tag.twig [new file with mode: 0644]
themes/default/tags.twig
themes/default/view.twig

index 8e9ee0b7e7be8592aec535a633ee5b0f7c6edc11..a89bce41af00450f530dc3439047516f4a8fd96c 100644 (file)
@@ -258,6 +258,27 @@ class Database {
         return $tags;
     }
 
+    public function retrieveTag($id) {
+        $tag  = NULL;
+        $sql    = "SELECT * FROM tags WHERE id=?";
+        $params = array(intval($id));
+        $query  = $this->executeQuery($sql, $params);
+        $tag  = $query->fetchAll();
+
+        return isset($tag[0]) ? $tag[0] : null;
+    }
+
+    public function retrieveEntriesByTag($tag_id) {
+        $sql = 
+            "SELECT * FROM entries
+            LEFT JOIN tags_entries ON tags_entries.entry_id=entries.id
+            WHERE tags_entries.tag_id = ?";
+        $query = $this->executeQuery($sql, array($tag_id));
+        $entries = $query->fetchAll();
+
+        return $entries;
+    }
+
     public function retrieveTagsByEntry($entry_id) {
         $sql = 
             "SELECT * FROM tags
index 5d36884273ce677ee63163a184da484fcff9ea3e..fefbb02dd24d3a5c25c90ff8910d84f278cb2065 100644 (file)
@@ -437,6 +437,14 @@ class Poche
                     'tags' => $tags,
                 );
                 break;
+            case 'tag':
+                $entries = $this->store->retrieveEntriesByTag($id);
+                $tag = $this->store->retrieveTag($id);
+                $tpl_vars = array(
+                    'tag' => $tag,
+                    'entries' => $entries,
+                );
+                break;
             case 'tags':
                 $tags = $this->store->retrieveAllTags();
                 $tpl_vars = array(
index b0ef55f53a7bc334c739aab8b9373cc6de0852d5..6da530235a0c24ddc6b7a53b2cd9afcc696b00a5 100644 (file)
@@ -90,7 +90,7 @@ class Tools
     {
         $views = array(
             'install', 'import', 'export', 'config', 'tags',
-            'edit-tags', 'view', 'login', 'error'
+            'edit-tags', 'view', 'login', 'error', 'tag'
             );
 
         if (in_array($view, $views)) {
diff --git a/themes/default/tag.twig b/themes/default/tag.twig
new file mode 100644 (file)
index 0000000..364c7cd
--- /dev/null
@@ -0,0 +1,33 @@
+{% extends "layout.twig" %}
+{% block title %}tag {% endblock %}
+{% block menu %}
+{% include '_menu.twig' %}
+{% endblock %}
+{% block content %}
+    <h3>{% trans "Tag" %} {{ tag.value }}</h3>
+    {% if entries is empty %}
+    <div class="messages warning"><p>{% trans "No link available here!" %}</p></div>
+    {% else %}
+        {% block pager %}
+            {% if nb_results > 1 %}
+        <div class="results">
+            <div class="nb-results">{{ nb_results }} {% trans "results" %}</div>
+                {{ page_links | raw }}
+        </div>
+            {% endif %}
+        {% endblock %}
+        {% for entry in entries %}
+    <div id="entry-{{ entry.id|e }}" class="entrie">
+        <h2><a href="index.php?view=view&amp;id={{ entry.id|e }}">{{ entry.title|raw }}</a></h2>
+        <ul class="tools">
+            <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>
+            <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>
+            <li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&amp;id={{ entry.id|e }}"><span>{% trans "delete" %}</span></a></li>
+            <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>
+            <li><a target="_blank" title="{% trans "estimated reading time:" %} {{ entry.content| getReadingTime }} min" class="reading-time"><span>{{ entry.content| getReadingTime }} min</span></a></li>
+        </ul>
+        <p>{{ entry.content|striptags|slice(0, 300) }}...</p>
+    </div>
+        {% endfor %}
+    {% endif %}
+{% endblock %}
\ No newline at end of file
index 9421fe3eab40699f039e443d2bc52c6f9048a1aa..e179143df9408e8598a2e5b1915140e65df2b0db 100644 (file)
@@ -4,5 +4,5 @@
 {% include '_menu.twig' %}
 {% endblock %}
 {% block content %}
-{% for tag in tags %}<a href="#">{{ tag.value }}</a> {% endfor %}
+{% for tag in tags %}<a href="./?view=tag&amp;id={{ tag.id }}">{{ tag.value }}</a> {% endfor %}
 {% endblock %}
\ No newline at end of file
index 9f9e23c8166b8a55d2d73dd0bebdfc3b48101f07..7e096a95c0e8fb4e5d1a64a716e554a264e30f3d 100644 (file)
@@ -21,7 +21,7 @@
                 <h1>{{ entry.title|raw }}</h1>
             </header>
             <aside class="tags">
-                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>
+                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>
             </aside>
             <article>
                 {{ content | raw }}