Commit 2c129046

mo k <mo@mokhan.ca>
2013-01-26 04:28:19
add tag cloud
1 parent ed7b321
Changed files (2)
app
app/helpers/tutorials_helper.rb
@@ -0,0 +1,3 @@
+module TutorialsHelper
+  include ActsAsTaggableOn::TagsHelper
+end
app/views/tutorials/index.html.erb
@@ -12,10 +12,16 @@
   });
 </script>
 <% end -%>
+<style>
+.css1 { font-size: 1.0em; }
+.css2 { font-size: 1.2em; }
+.css3 { font-size: 1.4em; }
+.css4 { font-size: 1.6em; }
+</style>
 <% content_for :page_header do -%>
   <%= link_to 'Add Tutorial', new_tutorial_path, :class => "btn btn-primary pull-right" %>
-  <% Tutorial.tag_counts.each do |tag| %>
-    <a href="?tags=<%= tag.name %>"><span class="label"><%= tag.name %></span></a>
+  <% tag_cloud(Tutorial.tag_counts_on(:tags), %w(css1 css2 css3 css4)) do |tag, css_class| %>
+    <a href="?tags=<%= tag.name %>"><span class="label <%= css_class %>"><%= tag.name %></span></a>
   <% end %>
 <% end -%>
 <div id="tutorials-div" class="row">