Use tag cloud objects in view

This allows us to not set the individual instance variables for the tag
cloud attributes.
This commit is contained in:
Katrina Owen 2013-02-28 22:00:23 -05:00
parent 61e04a8258
commit b5868d5c70
3 changed files with 11 additions and 19 deletions

View file

@ -552,16 +552,8 @@ class StatsController < ApplicationController
end end
def get_stats_tags def get_stats_tags
cloud = Stats::TagCloud.new(current_user) @tag_cloud = Stats::TagCloud.new(current_user)
@tag_cloud_90days = Stats::TagCloud.new(current_user, @cut_off_3months)
@tags_for_cloud = cloud.tags
@tags_min = cloud.min
@tags_divisor = cloud.divisor
cloud = Stats::TagCloud.new(current_user, @cut_off_3months)
@tags_for_cloud_90days = cloud.tags
@tags_min_90days = cloud.min
@tags_divisor_90days = cloud.divisor
end end
def get_ids_from (actions, week_from, week_to, at_end) def get_ids_from (actions, week_from, week_to, at_end)

View file

@ -3,12 +3,12 @@
<p><%= t('stats.tag_cloud_description') %></p> <p><%= t('stats.tag_cloud_description') %></p>
<p> <p>
<% if @tags_for_cloud.size < 1 <% if tag_cloud.tags.size < 1
t('stats.no_tags_available') t('stats.no_tags_available')
else else
@tags_for_cloud.each do |t| %> tag_cloud.tags.each do |t| %>
<%= link_to t.name, tag_path(t.name), { <%= link_to t.name, tag_path(t.name), {
:style => "font-size: " + (9 + 2*(t.count.to_i-@tags_min)/@tags_divisor).to_s + "pt", :style => "font-size: " + (9 + 2*(t.count.to_i-tag_cloud.min)/tag_cloud.divisor).to_s + "pt",
:title => t.count.to_s+" #{t('common.actions_midsentence', :count => t.count)}"} :title => t.count.to_s+" #{t('common.actions_midsentence', :count => t.count)}"}
-%> <% -%> <%
end end
@ -20,15 +20,15 @@
<h3><%= t('stats.tag_cloud_90days_title') %></h3> <h3><%= t('stats.tag_cloud_90days_title') %></h3>
<p><%= t('stats.tag_cloud_90days_description') %></p> <p><%= t('stats.tag_cloud_90days_description') %></p>
<p> <p>
<% if @tags_for_cloud_90days.size < 1 <% if tag_cloud_90days.tags.size < 1
t('stats.no_tags_available') t('stats.no_tags_available')
else else
@tags_for_cloud_90days.each do |t| %> tag_cloud_90days.tags.each do |t| %>
<%= link_to t.name, tag_path(t.name), { <%= link_to t.name, tag_path(t.name), {
:style => "font-size: " + (9 + 2*(t.count.to_i-@tags_min_90days)/@tags_divisor_90days).to_s + "pt", :style => "font-size: " + (9 + 2*(t.count.to_i-tag_cloud_90days.min)/tag_cloud_90days.divisor).to_s + "pt",
:title => t.count.to_s+" #{t('common.actions_midsentence', :count => t.count)}"} :title => t.count.to_s+" #{t('common.actions_midsentence', :count => t.count)}"}
-%> <% -%> <%
end end
end-%> end-%>
</p> </p>
</div> </div>

View file

@ -15,7 +15,7 @@
<%= render :partial => 'projects' -%> <%= render :partial => 'projects' -%>
<h2><%= t('stats.tags') %></h2> <h2><%= t('stats.tags') %></h2>
<%= render :partial => 'tags' -%> <%= render :partial => 'tags', :locals => {:tag_cloud => @tag_cloud, :tag_cloud_90days => @tag_cloud_90days} -%>
<% else -%> <% else -%>
@ -23,4 +23,4 @@
<% end -%> <% end -%>
</div> </div>