mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-05 18:41:02 +00:00
tag cloud is present, #1122 is implemented
This commit is contained in:
parent
512ff18015
commit
ab87a7fe69
6 changed files with 86 additions and 3 deletions
|
@ -466,6 +466,26 @@ class Poche
|
||||||
}
|
}
|
||||||
$tags = $this->store->retrieveTagsByEntry($id);
|
$tags = $this->store->retrieveTagsByEntry($id);
|
||||||
$all_tags = $this->store->retrieveAllTags($this->user->getId());
|
$all_tags = $this->store->retrieveAllTags($this->user->getId());
|
||||||
|
$maximus = 0;
|
||||||
|
foreach ($all_tags as $eachtag) { // search for the most times a tag is present
|
||||||
|
if ($eachtag["entriescount"] > $maximus) $maximus = $eachtag["entriescount"];
|
||||||
|
}
|
||||||
|
foreach ($all_tags as $key => $eachtag) { // get the percentage of presence of each tag
|
||||||
|
$percent = floor(($eachtag["entriescount"] / $maximus) * 100);
|
||||||
|
|
||||||
|
if ($percent < 20): // assign a css class, depending on the number of entries count
|
||||||
|
$cssclass = 'smallesttag';
|
||||||
|
elseif ($percent >= 20 and $percent < 40):
|
||||||
|
$cssclass = 'smalltag';
|
||||||
|
elseif ($percent >= 40 and $percent < 60):
|
||||||
|
$cssclass = 'mediumtag';
|
||||||
|
elseif ($percent >= 60 and $percent < 80):
|
||||||
|
$cssclass = 'largetag';
|
||||||
|
else:
|
||||||
|
$cssclass = 'largesttag';
|
||||||
|
endif;
|
||||||
|
$all_tags[$key]['cssclass'] = $cssclass;
|
||||||
|
}
|
||||||
$tpl_vars = array(
|
$tpl_vars = array(
|
||||||
'entry_id' => $id,
|
'entry_id' => $id,
|
||||||
'tags' => $tags,
|
'tags' => $tags,
|
||||||
|
|
|
@ -48,6 +48,9 @@ jQuery(function($) {
|
||||||
var value = input.val();
|
var value = input.val();
|
||||||
var tag = $(this).text();
|
var tag = $(this).text();
|
||||||
var terms = value.split(','); // tags into the <input>
|
var terms = value.split(','); // tags into the <input>
|
||||||
|
$(".alreadytagged").each(function(index) {
|
||||||
|
terms.push($(this).text() );
|
||||||
|
});
|
||||||
if (jQuery.inArray(tag, terms) == -1 ) { // if the tag hasn't already been added
|
if (jQuery.inArray(tag, terms) == -1 ) { // if the tag hasn't already been added
|
||||||
value += tag + ",";
|
value += tag + ",";
|
||||||
input.val(value);
|
input.val(value);
|
||||||
|
|
|
@ -960,6 +960,35 @@ pre code {
|
||||||
font-size: 0.96em;
|
font-size: 0.96em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
5.1 = Tags-related styles
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
.suggestedtag {
|
||||||
|
padding: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tagcloud .smallesttag {
|
||||||
|
font-size: x-small;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tagcloud .smalltag {
|
||||||
|
font-size: small;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tagcloud .mediumtag {
|
||||||
|
font-size:medium;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tagcloud .largetag {
|
||||||
|
font-size:large;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tagcloud .largesttag {
|
||||||
|
font-size:larger;
|
||||||
|
}
|
||||||
|
|
||||||
/* ==========================================================================
|
/* ==========================================================================
|
||||||
6 = Media Queries
|
6 = Media Queries
|
||||||
|
|
|
@ -26,6 +26,6 @@
|
||||||
{% trans "You can enter multiple tags, separated by commas." %}</p>
|
{% trans "You can enter multiple tags, separated by commas." %}</p>
|
||||||
</form>
|
</form>
|
||||||
All existing tags :
|
All existing tags :
|
||||||
<ul>{% for eachtag in alltags %}<li class="suggestedtag" style="display: inline-block; margin:10px;">{{ eachtag.value }}</li>{% endfor %}</ul>
|
<ul id="tagcloud">{% for eachtag in alltags %}<li class="suggestedtag {{ eachtag.cssclass }}">{{ eachtag.value }}</li>{% endfor %}</ul>
|
||||||
<a class="icon icon-reply return" href="./?view=view&id={{ entry_id }}">{% trans "return to article" %}</a>
|
<a class="icon icon-reply return" href="./?view=view&id={{ entry_id }}">{% trans "return to article" %}</a>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -455,3 +455,33 @@ pre code {
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
font-size: 0.96em;
|
font-size: 0.96em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ==========================================================================
|
||||||
|
Tags-related styles
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
.suggestedtag {
|
||||||
|
padding: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tagcloud .smallesttag {
|
||||||
|
font-size: x-small;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tagcloud .smalltag {
|
||||||
|
font-size: small;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tagcloud .mediumtag {
|
||||||
|
font-size:medium;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tagcloud .largetag {
|
||||||
|
font-size:large;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tagcloud .largesttag {
|
||||||
|
font-size:larger;
|
||||||
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
{% trans "no tags" %}
|
{% trans "no tags" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for tag in tags %}<li>{{ tag.value }} <a href="./?action=remove_tag&tag_id={{ tag.id }}&id={{ entry_id }}">✘</a></li>{% endfor %}
|
{% for tag in tags %}<li><span class="alreadytagged">{{ tag.value }}</span> <a href="./?action=remove_tag&tag_id={{ tag.id }}&id={{ entry_id }}">✘</a></li>{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<form method="post" action="./?action=add_tag" id="editTags">
|
<form method="post" action="./?action=add_tag" id="editTags">
|
||||||
<input type="hidden" name="entry_id" value="{{ entry_id }}" />
|
<input type="hidden" name="entry_id" value="{{ entry_id }}" />
|
||||||
|
@ -30,6 +30,7 @@
|
||||||
{% trans "You can enter multiple tags, separated by commas." %}</p>
|
{% trans "You can enter multiple tags, separated by commas." %}</p>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
<br>
|
All existing tags :
|
||||||
|
<ul id="tagcloud">{% for eachtag in alltags %}<li class="suggestedtag {{ eachtag.cssclass }}">{{ eachtag.value }}</li>{% endfor %}</ul>
|
||||||
<a href="./?view=view&id={{ entry_id }}">« {% trans "return to article" %}</a>
|
<a href="./?view=view&id={{ entry_id }}">« {% trans "return to article" %}</a>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue