diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-13 12:50:33 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-13 12:50:33 -0400 |
| commit | 250ef8b5d4f6cb457c4976528f72f6ea7bf5f6cc (patch) | |
| tree | 21dba266c2d0b6c39a7202fbaf119d6a0b7cecf0 /app/helpers | |
| parent | 27482983496cd0b8b6fa7dc943a1b05959735835 (diff) | |
| download | thoughts-250ef8b5d4f6cb457c4976528f72f6ea7bf5f6cc.tar.gz thoughts-250ef8b5d4f6cb457c4976528f72f6ea7bf5f6cc.tar.bz2 thoughts-250ef8b5d4f6cb457c4976528f72f6ea7bf5f6cc.zip | |
Tag cloud
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 | ||
