diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb
index 82cc8be..6bdeee7 100644
--- a/app/helpers/tags_helper.rb
+++ b/app/helpers/tags_helper.rb
@@ -53,9 +53,14 @@ module TagsHelper
"top: #{ -(delta/2) - (v * (delta/2)).round }px;"
destination = url.kind_of?(Hash) ? url_for(url.merge(tagname_option => tag)) : (url.to_s + tag)
- display_count = options[:show_count] ? "(#{count})" : ""
+ if options[:show_count]
+ display_count = options[:show_count] ? "(#{count})" : ""
+ link_to tag + display_count, destination, :style => style
+ else
+ link_to tag , destination, :style => style,
+ :title => n_( 'one item', '%d items', count ) % count
+ end
- link_to tag + display_count, destination, :style => style
end.join("\n")
end
diff --git a/app/models/tags_block.rb b/app/models/tags_block.rb
index 1f7aa08..6a7e575 100644
--- a/app/models/tags_block.rb
+++ b/app/models/tags_block.rb
@@ -4,6 +4,8 @@ class TagsBlock < Block
include BlockHelper
include ActionController::UrlWriter
+ settings_items :limit, :type => :integer, :default => 12
+
def self.description
_('Block listing content count by tag')
end
@@ -21,6 +23,12 @@ class TagsBlock < Block
tags = owner.article_tags
return '' if tags.empty?
+ if limit
+ tags_tmp = tags.sort_by{ |k,v| -v }[0..(limit-1)]
+ tags = {}
+ tags_tmp.map{ |k,v| tags[k] = v }
+ end
+
block_title(title) +
"\n
\n"+
tag_cloud( tags, :id,
@@ -29,6 +37,13 @@ class TagsBlock < Block
"\n
\n";
end
+ def footer
+ owner_id = owner.identifier
+ lambda do
+ link_to s_('tags|View all'), :profile => owner_id, :controller => 'profile', :action => 'tags'
+ end
+ end
+
def timeout
15.minutes
end
diff --git a/app/views/box_organizer/_tags_block.rhtml b/app/views/box_organizer/_tags_block.rhtml
new file mode 100644
index 0000000..4d49a3e
--- /dev/null
+++ b/app/views/box_organizer/_tags_block.rhtml
@@ -0,0 +1,3 @@
+
+ <%= labelled_form_field _('Limit of tags to display:'), text_field(:block, :limit, :size => 3) %>
+
diff --git a/app/views/profile/tags.rhtml b/app/views/profile/tags.rhtml
index dd7f754..ab023d5 100644
--- a/app/views/profile/tags.rhtml
+++ b/app/views/profile/tags.rhtml
@@ -1,5 +1,7 @@
<%= _("%s's tags") % @profile.name %>
+
<% cache_timeout(@tags_cache_key, 4.hour.from_now) do %>
- <%= tag_cloud(@tags, :id, { :action => :tag}, {:show_count => true} ) %>
+ <%= tag_cloud @tags, :id, { :action => :tag}, {:show_count => true} %>
<% end %>
+
diff --git a/app/views/search/tags.rhtml b/app/views/search/tags.rhtml
index ba88e0f..ec9e7f0 100644
--- a/app/views/search/tags.rhtml
+++ b/app/views/search/tags.rhtml
@@ -1,5 +1,7 @@
-<%= _('Tag cloud') %>
+<%= _('Tag cloud') %>
+
<% cache_timeout(@tags_cache_key, 4.hour.from_now) do %>
- <%= tag_cloud(@tags, :tag, :action => 'tag') %>
+ <%= tag_cloud @tags, :tag, {:action => 'tag'}, {:show_count => true} %>
<% end %>
+
--
libgit2 0.21.2