An add-on to ActsAsTaggableOn that allows for creating tag clouds using colour to indicate tag counts
Ruby JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
config
lib
script
spec
.gitignore
.rspec
Gemfile
Gemfile.lock
MIT-LICENSE.md
README.md
Rakefile
tinted_tags.gemspec

README.md

TintedTags

This plugin is to be used with acts_as_taggable_on. TintedTags allows you to create a tag cloud where tag popularity is illustrated with colour. It achieves this by adding a :tint attribute to the Tag model, and allows you to calculate a colour (in the form of a hex code) for each tag based on its popularity. These hex codes are added to the tags in the view via inline-css.

Tags are updated via an after_save filter on a TintedTags object.

Installation

Rails 3.x

To use it, add it to your Gemfile:

gem 'acts-as-taggable-on', '~> 2.3.1'
gem 'tinted_tags'

Post Installation

rails generate tinted_tags:migration
rake db:migrate

Usage

Model

acts_as_taggable_on
tinted_tags base: '#ffffff', tint: '#000000'

Controller

@tags = Post.tag_counts_on(:tags).order('count desc')

Views

tinted_tag_cloud

returns ..

<ul class="tinted-tag-cloud">
  <li style="background-color: #ffffff">one</li>
  <li style="background-color: #7f7f7f">two</li>
</ul>

Author

Copyright (c) Ben Woodward (http://benw.me/) Copyright Released under the MIT license