governor_tags

Governor[http://carpeliam.github.com/governor/] (named after Rod Blagojevich) is the pluggable blogging platform for Rails, built for people who want to build their blog into their website, not build their website into their blog.

governor_tags is a plugin for Governor, allowing you to add and remove tags to/from your articles.

Dependencies

  • Governor.

  • ActiveRecord

Setting Up

First, install Governor. Then, in your Gemfile, add the following:

gem 'governor_tags'

Once you’ve installed the gem into your app, you need to run the generator:

rails generate governor:create_tags [RESOURCE]

If you’ve only created one type of resource (which is typical), then you won’t need any arguments. Otherwise, you’ll need to specify which model you want to add tags to. This will create a Tag class and associated migration.

Usage

Now, when you modify an article, you’ll see places to add tags right in the page.

If you’d like to display a list of tags with links to each tag as a helper (maybe as part of a sidebar), you can call the following helper:

<%= tag_list @your_tags %>

where @your_tags is an array of tags.

Also, if you’d like to have a JSON-searchable list of tags, perhaps for use with an autocomplete feature, you can pass your query on to /:resources/tags/query, where :resources corresponds to the resource type you chose above. If you’re using the default Governor resource type, this would be /articles/tags/query. Here’s a snippet, if you’re using jQuery:

$.getJSON("/articles/tags/query", {query: request.term.split(/,\s*/).pop()}, response);

Contributing to governor_tags

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2011 Liam Morley. See LICENSE.txt for further details.