Skip to content

Commit

Permalink
Update the helper file to exist with the engine application as opposed
Browse files Browse the repository at this point in the history
to being a library file.
  • Loading branch information
thedelchop committed Mar 1, 2012
1 parent 1d4b274 commit ae17be7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
17 changes: 17 additions & 0 deletions app/helpers/acts_as_taggable_on/tags_helper.rb
@@ -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
6 changes: 0 additions & 6 deletions lib/acts_as_taggable_on/engine.rb
Expand Up @@ -5,11 +5,5 @@ class Engine < Rails::Engine
ActiveRecord::Base.extend ActsAsTaggableOn::Taggable
ActiveRecord::Base.send :include, ActsAsTaggableOn::Tagger
end

#initializer 'ActsAsTaggableOn AcrtionView' do |app|
#ActiveSupport.on_load(:action_view) do
#include ActsAsTaggableOn::TagsHelper
#end
#end
end
end
28 changes: 14 additions & 14 deletions lib/acts_as_taggable_on/tags_helper.rb
@@ -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

0 comments on commit ae17be7

Please sign in to comment.