mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-20 14:46:41 +00:00
[add] page which lists entries for a tag
This commit is contained in:
parent
74ec445a66
commit
4886ed6d36
6 changed files with 65 additions and 3 deletions
|
@ -258,6 +258,27 @@ class Database {
|
||||||
return $tags;
|
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) {
|
public function retrieveTagsByEntry($entry_id) {
|
||||||
$sql =
|
$sql =
|
||||||
"SELECT * FROM tags
|
"SELECT * FROM tags
|
||||||
|
|
|
@ -437,6 +437,14 @@ class Poche
|
||||||
'tags' => $tags,
|
'tags' => $tags,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case 'tag':
|
||||||
|
$entries = $this->store->retrieveEntriesByTag($id);
|
||||||
|
$tag = $this->store->retrieveTag($id);
|
||||||
|
$tpl_vars = array(
|
||||||
|
'tag' => $tag,
|
||||||
|
'entries' => $entries,
|
||||||
|
);
|
||||||
|
break;
|
||||||
case 'tags':
|
case 'tags':
|
||||||
$tags = $this->store->retrieveAllTags();
|
$tags = $this->store->retrieveAllTags();
|
||||||
$tpl_vars = array(
|
$tpl_vars = array(
|
||||||
|
|
|
@ -90,7 +90,7 @@ class Tools
|
||||||
{
|
{
|
||||||
$views = array(
|
$views = array(
|
||||||
'install', 'import', 'export', 'config', 'tags',
|
'install', 'import', 'export', 'config', 'tags',
|
||||||
'edit-tags', 'view', 'login', 'error'
|
'edit-tags', 'view', 'login', 'error', 'tag'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (in_array($view, $views)) {
|
if (in_array($view, $views)) {
|
||||||
|
|
33
themes/default/tag.twig
Normal file
33
themes/default/tag.twig
Normal 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&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&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&id={{ entry.id|e }}"><span>{% trans "toggle favorite" %}</span></a></li>
|
||||||
|
<li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&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 %}
|
|
@ -4,5 +4,5 @@
|
||||||
{% include '_menu.twig' %}
|
{% include '_menu.twig' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% for tag in tags %}<a href="#">{{ tag.value }}</a> {% endfor %}
|
{% for tag in tags %}<a href="./?view=tag&id={{ tag.id }}">{{ tag.value }}</a> {% endfor %}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -21,7 +21,7 @@
|
||||||
<h1>{{ entry.title|raw }}</h1>
|
<h1>{{ entry.title|raw }}</h1>
|
||||||
</header>
|
</header>
|
||||||
<aside class="tags">
|
<aside class="tags">
|
||||||
tags: {% for tag in tags %}<a href="#">{{ tag.value }}</a> {% endfor %}<a href="./?&view=edit-tags&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&id={{ entry.id|e }}" title="{% trans "edit tags" %}">✎</a>
|
||||||
</aside>
|
</aside>
|
||||||
<article>
|
<article>
|
||||||
{{ content | raw }}
|
{{ content | raw }}
|
||||||
|
|
Loading…
Reference in a new issue