| Class | Tag |
| In: |
app/models/tag.rb
|
| Parent: | ActiveRecord::Base |
Project iboard4 Author Andreas Altendorfer Copyright 2009 by Andreas Altendorfer
Model for Tags assigned polymorphic to any tagable model
# File app/models/tag.rb, line 19
19: def self.get_tag_style(tagname)
20: if !@tagstyle || (@tagstyle[:timestamp] < Time::now-10.minutes)
21: @tagstyle = { :timestamp => Time::now }
22: @cnt_max = 0.0
23: Tag.ascend_by_name.map(&:name).uniq.each do |n|
24: @tagstyle[n] = Tag.name_is(n).count
25: @cnt_max = @tagstyle[n] > @cnt_max ? @tagstyle[n] : @cnt_max
26: end
27: end
28:
29: size_factor = @tagstyle[tagname].to_f/@cnt_max # percent
30: resize = (12 * size_factor).round
31: size = 9+resize
32: return "font-size: #{size}px;"
33: end
# File app/models/tag.rb, line 35
35: def self.title(t)
36: case t.class
37: when Posting
38: t.subject
39: else
40: t.title
41: end
42: end