]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
tag cloud is present, #1122 is implemented
authorThomas Citharel <tcit@tcit.fr>
Sun, 8 Mar 2015 13:47:22 +0000 (14:47 +0100)
committerThomas Citharel <tcit@tcit.fr>
Sun, 8 Mar 2015 13:47:22 +0000 (14:47 +0100)
inc/poche/Poche.class.php
themes/_global/js/autoCompleteTags.js
themes/baggy/css/main.css
themes/baggy/edit-tags.twig
themes/default/css/style.css
themes/default/edit-tags.twig

index bf323c49ce3c98f901ee8f7ca9c034ad67fc6f6f..4ec724f9f49ce7811d52f68df81bac102fe481f3 100755 (executable)
@@ -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,
index 986e71d15a22d236609b047b64ad0e7b1e1b1aa8..8b32f8ca8bf0e661fd596e8e1972fd13325ba7ec 100755 (executable)
@@ -48,6 +48,9 @@ jQuery(function($) {
     var value = input.val();
     var tag = $(this).text();
     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
       value += tag + ",";
       input.val(value);
index 5319fd681a7c962768ea5fe5daddf71a760a1bd5..91c1ab9f369c8d0e1a258a1a9f7f7e8a5dde4217 100755 (executable)
@@ -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
index ae6684f2a00170d9d71d2a58105d3168e1794cb4..3b829eaedb12ad915ee4625b79063adaeab9f2ec 100755 (executable)
@@ -26,6 +26,6 @@
     {% trans "You can enter multiple tags, separated by commas." %}</p>
 </form>
 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>
 {% endblock %}
index a122dc546b2d7f8e1fb80772cb750eb8901a704f..58d908ee3647046cd492a63af32d0df380b93496 100755 (executable)
@@ -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;
+}
index c29427e0a0cabe4e0c910b0bb04ab80f119b59e8..61cc94f1474f1ad31ef69380c5ebd60022609779 100755 (executable)
@@ -19,7 +19,7 @@
 {% trans "no tags" %}
 {% endif %}
 <ul>
-{% for tag in tags %}<li>{{ tag.value }} <a href="./?action=remove_tag&amp;tag_id={{ tag.id }}&amp;id={{ entry_id }}">✘</a></li>{% endfor %}
+{% for tag in tags %}<li><span class="alreadytagged">{{ tag.value }}</span> <a href="./?action=remove_tag&amp;tag_id={{ tag.id }}&amp;id={{ entry_id }}">✘</a></li>{% endfor %}
 </ul>
 <form method="post" action="./?action=add_tag" id="editTags">
     <input type="hidden" name="entry_id" value="{{ entry_id }}" />
@@ -30,6 +30,7 @@
     {% trans "You can enter multiple tags, separated by commas." %}</p>
 
 </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 }}">&laquo; {% trans "return to article" %}</a>
 {% endblock %}