Permalink
Browse files

tags cloud for gallery partial

  • Loading branch information...
1 parent 868bbef commit 5dfe09fab7d97f5c49cc98aed6d81686b9bf7938 @rilian committed May 12, 2012
Showing with 18 additions and 0 deletions.
  1. +8 −0 app/helpers/application_helper.rb
  2. +10 −0 app/views/images/_gallery.html.erb
@@ -1,2 +1,10 @@
module ApplicationHelper
+ ##
+ # Returns array of weighted tags, extracted from all Image
+ #
+ def get_tags_cloud
+ tags_cloud = Hash.new(0)
+ Image.published.map(&:tags).flatten.each { |tag| tags_cloud[tag] += 1 }
+ tags_cloud.sort {|a, b| rand <=> rand }
+ end
end
@@ -1,4 +1,14 @@
<ul class="thumbnails">
+ <% get_tags_cloud.each do |tag, count| %>
+ <li>
+ <h<%= [(6-count), 2].max %>>
+ <%= link_to tag, root_path(:q => {:title_or_desc_or_tags_cache_or_album_title_cont => tag}) %>
+ </h<%= [(6-count), 2].max %>>
+ </li>
+ <% end %>
+</ul>
+
+<ul class="thumbnails">
<% images.each do |image| %>
<li class="span2">
<div>

0 comments on commit 5dfe09f

Please sign in to comment.