forked from aaronchi/acts-as-taggable-on
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the helper file to exist with the engine application as opposed
to being a library file.
- Loading branch information
1 parent
1d4b274
commit ae17be7
Showing
3 changed files
with
31 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module ActsAsTaggableOn | ||
module TagsHelper | ||
# See the README for an example using tag_cloud. | ||
def tag_cloud(tags, classes) | ||
tags = tags.all if tags.respond_to?(:all) | ||
|
||
return [] if tags.empty? | ||
|
||
max_count = tags.sort_by(&:count).last.count.to_f | ||
|
||
tags.each do |tag| | ||
index = ((tag.count / max_count) * (classes.size - 1)) | ||
yield tag, classes[index.nan? ? 0 : index.round] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
module ActsAsTaggableOn | ||
module TagsHelper | ||
# See the README for an example using tag_cloud. | ||
def tag_cloud(tags, classes) | ||
tags = tags.all if tags.respond_to?(:all) | ||
#module ActsAsTaggableOn | ||
#module TagsHelper | ||
## See the README for an example using tag_cloud. | ||
#def tag_cloud(tags, classes) | ||
#tags = tags.all if tags.respond_to?(:all) | ||
|
||
return [] if tags.empty? | ||
#return [] if tags.empty? | ||
|
||
max_count = tags.sort_by(&:count).last.count.to_f | ||
#max_count = tags.sort_by(&:count).last.count.to_f | ||
|
||
tags.each do |tag| | ||
index = ((tag.count / max_count) * (classes.size - 1)) | ||
yield tag, classes[index.nan? ? 0 : index.round] | ||
end | ||
end | ||
end | ||
end | ||
#tags.each do |tag| | ||
#index = ((tag.count / max_count) * (classes.size - 1)) | ||
#yield tag, classes[index.nan? ? 0 : index.round] | ||
#end | ||
#end | ||
#end | ||
#end |