From ab87a7fe6934b5fa0f06964c67a27826774126b4 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 8 Mar 2015 14:47:22 +0100 Subject: [PATCH] tag cloud is present, #1122 is implemented --- inc/poche/Poche.class.php | 20 ++++++++++++++++++ themes/_global/js/autoCompleteTags.js | 3 +++ themes/baggy/css/main.css | 29 ++++++++++++++++++++++++++ themes/baggy/edit-tags.twig | 2 +- themes/default/css/style.css | 30 +++++++++++++++++++++++++++ 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 } $tags = $this->store->retrieveTagsByEntry($id); $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( 'entry_id' => $id, '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($) { var value = input.val(); var tag = $(this).text(); var terms = value.split(','); // tags into the + $(".alreadytagged").each(function(index) { + terms.push($(this).text() ); + }); if (jQuery.inArray(tag, terms) == -1 ) { // if the tag hasn't already been added value += tag + ","; 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 { 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 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 @@ {% trans "You can enter multiple tags, separated by commas." %}

All existing tags : - + {% trans "return to article" %} {% 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 { border: 1px solid #ddd; 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; +} 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 @@ {% trans "no tags" %} {% endif %}
@@ -30,6 +30,7 @@ {% trans "You can enter multiple tags, separated by commas." %}

-
+All existing tags : + « {% trans "return to article" %} {% endblock %} -- 2.41.0