diff options
author | Thomas Citharel <tcit@tcit.fr> | 2015-03-08 14:47:22 +0100 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2015-03-08 14:47:22 +0100 |
commit | ab87a7fe6934b5fa0f06964c67a27826774126b4 (patch) | |
tree | e8f20b190b69ff47276731446544d98ac8c84dea | |
parent | 512ff18015919bf3119509d1a8b8cf87b3b86f5f (diff) | |
download | wallabag-ab87a7fe6934b5fa0f06964c67a27826774126b4.tar.gz wallabag-ab87a7fe6934b5fa0f06964c67a27826774126b4.tar.zst wallabag-ab87a7fe6934b5fa0f06964c67a27826774126b4.zip |
tag cloud is present, #1122 is implemented
-rwxr-xr-x | inc/poche/Poche.class.php | 20 | ||||
-rwxr-xr-x | themes/_global/js/autoCompleteTags.js | 3 | ||||
-rwxr-xr-x | themes/baggy/css/main.css | 29 | ||||
-rwxr-xr-x | themes/baggy/edit-tags.twig | 2 | ||||
-rwxr-xr-x | themes/default/css/style.css | 30 | ||||
-rwxr-xr-x | themes/default/edit-tags.twig | 5 |
6 files changed, 86 insertions, 3 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index bf323c49..4ec724f9 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -466,6 +466,26 @@ class Poche | |||
466 | } | 466 | } |
467 | $tags = $this->store->retrieveTagsByEntry($id); | 467 | $tags = $this->store->retrieveTagsByEntry($id); |
468 | $all_tags = $this->store->retrieveAllTags($this->user->getId()); | 468 | $all_tags = $this->store->retrieveAllTags($this->user->getId()); |
469 | $maximus = 0; | ||
470 | foreach ($all_tags as $eachtag) { // search for the most times a tag is present | ||
471 | if ($eachtag["entriescount"] > $maximus) $maximus = $eachtag["entriescount"]; | ||
472 | } | ||
473 | foreach ($all_tags as $key => $eachtag) { // get the percentage of presence of each tag | ||
474 | $percent = floor(($eachtag["entriescount"] / $maximus) * 100); | ||
475 | |||
476 | if ($percent < 20): // assign a css class, depending on the number of entries count | ||
477 | $cssclass = 'smallesttag'; | ||
478 | elseif ($percent >= 20 and $percent < 40): | ||
479 | $cssclass = 'smalltag'; | ||
480 | elseif ($percent >= 40 and $percent < 60): | ||
481 | $cssclass = 'mediumtag'; | ||
482 | elseif ($percent >= 60 and $percent < 80): | ||
483 | $cssclass = 'largetag'; | ||
484 | else: | ||
485 | $cssclass = 'largesttag'; | ||
486 | endif; | ||
487 | $all_tags[$key]['cssclass'] = $cssclass; | ||
488 | } | ||
469 | $tpl_vars = array( | 489 | $tpl_vars = array( |
470 | 'entry_id' => $id, | 490 | 'entry_id' => $id, |
471 | 'tags' => $tags, | 491 | 'tags' => $tags, |
diff --git a/themes/_global/js/autoCompleteTags.js b/themes/_global/js/autoCompleteTags.js index 986e71d1..8b32f8ca 100755 --- a/themes/_global/js/autoCompleteTags.js +++ b/themes/_global/js/autoCompleteTags.js | |||
@@ -48,6 +48,9 @@ jQuery(function($) { | |||
48 | var value = input.val(); | 48 | var value = input.val(); |
49 | var tag = $(this).text(); | 49 | var tag = $(this).text(); |
50 | var terms = value.split(','); // tags into the <input> | 50 | var terms = value.split(','); // tags into the <input> |
51 | $(".alreadytagged").each(function(index) { | ||
52 | terms.push($(this).text() ); | ||
53 | }); | ||
51 | if (jQuery.inArray(tag, terms) == -1 ) { // if the tag hasn't already been added | 54 | if (jQuery.inArray(tag, terms) == -1 ) { // if the tag hasn't already been added |
52 | value += tag + ","; | 55 | value += tag + ","; |
53 | input.val(value); | 56 | input.val(value); |
diff --git a/themes/baggy/css/main.css b/themes/baggy/css/main.css index 5319fd68..91c1ab9f 100755 --- a/themes/baggy/css/main.css +++ b/themes/baggy/css/main.css | |||
@@ -960,6 +960,35 @@ pre code { | |||
960 | font-size: 0.96em; | 960 | font-size: 0.96em; |
961 | } | 961 | } |
962 | 962 | ||
963 | /* ========================================================================== | ||
964 | 5.1 = Tags-related styles | ||
965 | ========================================================================== */ | ||
966 | |||
967 | .suggestedtag { | ||
968 | padding: 4px; | ||
969 | cursor: pointer; | ||
970 | display: inline-block; | ||
971 | } | ||
972 | |||
973 | #tagcloud .smallesttag { | ||
974 | font-size: x-small; | ||
975 | } | ||
976 | |||
977 | #tagcloud .smalltag { | ||
978 | font-size: small; | ||
979 | } | ||
980 | |||
981 | #tagcloud .mediumtag { | ||
982 | font-size:medium; | ||
983 | } | ||
984 | |||
985 | #tagcloud .largetag { | ||
986 | font-size:large; | ||
987 | } | ||
988 | |||
989 | #tagcloud .largesttag { | ||
990 | font-size:larger; | ||
991 | } | ||
963 | 992 | ||
964 | /* ========================================================================== | 993 | /* ========================================================================== |
965 | 6 = Media Queries | 994 | 6 = Media Queries |
diff --git a/themes/baggy/edit-tags.twig b/themes/baggy/edit-tags.twig index ae6684f2..3b829eae 100755 --- a/themes/baggy/edit-tags.twig +++ b/themes/baggy/edit-tags.twig | |||
@@ -26,6 +26,6 @@ | |||
26 | {% trans "You can enter multiple tags, separated by commas." %}</p> | 26 | {% trans "You can enter multiple tags, separated by commas." %}</p> |
27 | </form> | 27 | </form> |
28 | All existing tags : | 28 | All existing tags : |
29 | <ul>{% for eachtag in alltags %}<li class="suggestedtag" style="display: inline-block; margin:10px;">{{ eachtag.value }}</li>{% endfor %}</ul> | 29 | <ul id="tagcloud">{% for eachtag in alltags %}<li class="suggestedtag {{ eachtag.cssclass }}">{{ eachtag.value }}</li>{% endfor %}</ul> |
30 | <a class="icon icon-reply return" href="./?view=view&id={{ entry_id }}">{% trans "return to article" %}</a> | 30 | <a class="icon icon-reply return" href="./?view=view&id={{ entry_id }}">{% trans "return to article" %}</a> |
31 | {% endblock %} | 31 | {% endblock %} |
diff --git a/themes/default/css/style.css b/themes/default/css/style.css index a122dc54..58d908ee 100755 --- a/themes/default/css/style.css +++ b/themes/default/css/style.css | |||
@@ -455,3 +455,33 @@ pre code { | |||
455 | border: 1px solid #ddd; | 455 | border: 1px solid #ddd; |
456 | font-size: 0.96em; | 456 | font-size: 0.96em; |
457 | } | 457 | } |
458 | |||
459 | /* ========================================================================== | ||
460 | Tags-related styles | ||
461 | ========================================================================== */ | ||
462 | |||
463 | .suggestedtag { | ||
464 | padding: 4px; | ||
465 | cursor: pointer; | ||
466 | display: inline-block; | ||
467 | } | ||
468 | |||
469 | #tagcloud .smallesttag { | ||
470 | font-size: x-small; | ||
471 | } | ||
472 | |||
473 | #tagcloud .smalltag { | ||
474 | font-size: small; | ||
475 | } | ||
476 | |||
477 | #tagcloud .mediumtag { | ||
478 | font-size:medium; | ||
479 | } | ||
480 | |||
481 | #tagcloud .largetag { | ||
482 | font-size:large; | ||
483 | } | ||
484 | |||
485 | #tagcloud .largesttag { | ||
486 | font-size:larger; | ||
487 | } | ||
diff --git a/themes/default/edit-tags.twig b/themes/default/edit-tags.twig index c29427e0..61cc94f1 100755 --- a/themes/default/edit-tags.twig +++ b/themes/default/edit-tags.twig | |||
@@ -19,7 +19,7 @@ | |||
19 | {% trans "no tags" %} | 19 | {% trans "no tags" %} |
20 | {% endif %} | 20 | {% endif %} |
21 | <ul> | 21 | <ul> |
22 | {% for tag in tags %}<li>{{ tag.value }} <a href="./?action=remove_tag&tag_id={{ tag.id }}&id={{ entry_id }}">✘</a></li>{% endfor %} | 22 | {% 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 %} |
23 | </ul> | 23 | </ul> |
24 | <form method="post" action="./?action=add_tag" id="editTags"> | 24 | <form method="post" action="./?action=add_tag" id="editTags"> |
25 | <input type="hidden" name="entry_id" value="{{ entry_id }}" /> | 25 | <input type="hidden" name="entry_id" value="{{ entry_id }}" /> |
@@ -30,6 +30,7 @@ | |||
30 | {% trans "You can enter multiple tags, separated by commas." %}</p> | 30 | {% trans "You can enter multiple tags, separated by commas." %}</p> |
31 | 31 | ||
32 | </form> | 32 | </form> |
33 | <br> | 33 | All existing tags : |
34 | <ul id="tagcloud">{% for eachtag in alltags %}<li class="suggestedtag {{ eachtag.cssclass }}">{{ eachtag.value }}</li>{% endfor %}</ul> | ||
34 | <a href="./?view=view&id={{ entry_id }}">« {% trans "return to article" %}</a> | 35 | <a href="./?view=view&id={{ entry_id }}">« {% trans "return to article" %}</a> |
35 | {% endblock %} | 36 | {% endblock %} |