From 250ef8b5d4f6cb457c4976528f72f6ea7bf5f6cc Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 13 Oct 2023 12:50:33 -0400 Subject: Tag cloud --- app/helpers/tags_helper.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 app/helpers/tags_helper.rb (limited to 'app/helpers') 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 @@ +module TagsHelper + + def tag_cloud(tags, classes) + max = tags.sort_by(&:taggings_count).last + tags.each do |tag| + index = tag.taggings_count.to_f / max.taggings_count * (classes.size - 1) + yield(tag, classes[index.round]) + end + end + +end -- cgit 1.4.1