diff options
Diffstat (limited to 'app/helpers')
| -rw-r--r-- | app/helpers/tags_helper.rb | 11 |
1 files changed, 11 insertions, 0 deletions
| diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb new file mode 100644 index 0000000..9643834 --- /dev/null +++ b/app/helpers/tags_helper.rb | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | module TagsHelper | ||
| 2 | |||
| 3 | def tag_cloud(tags, classes) | ||
| 4 | max = tags.sort_by(&:taggings_count).last | ||
| 5 | tags.each do |tag| | ||
| 6 | index = tag.taggings_count.to_f / max.taggings_count * (classes.size - 1) | ||
| 7 | yield(tag, classes[index.round]) | ||
| 8 | end | ||
| 9 | end | ||
| 10 | |||
| 11 | end | ||
