1
0
mirror of https://github.com/moparisthebest/wallabag synced 2024-12-24 00:08:57 -05:00

[add] page which lists entries for a tag

This commit is contained in:
Nicolas Lœuillet 2013-12-06 14:22:29 +01:00
parent 74ec445a66
commit 4886ed6d36
6 changed files with 65 additions and 3 deletions

View 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

View 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(

View 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)) {

33
themes/default/tag.twig Normal file
View File

@ -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 %}

View 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 %}

View 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 }}