Topical can be added to any rails app that uses some sort of User model. Topical really doesn’t give a shit what you use for
an authentication plugin, just as long as you use one and that you have SOME KIND of “current_user” type of method and a method that checks to see if a user is “logged_in?”. E.g., in Clearance you use “current_user” and “signed_in?” respectively.
You can even have two different ‘types’ of user models within the same app, say an Account and a User, and both models can access your forum with ease.
Remember: You should already have a USER model.
1. Now, do the usual github plugin install:
script/plugin install git://github.com/pjammer/topical.git
2. Copy the migration files using
rake topical:sync
3. Change the two methods in lib/topical.rb based on the methods you use for user authentication plugin or gem. These methods are:
def logged_in?
#put signed_in? here
end
def posting_user
#put current_user here
end
4. Adjust your User model (and any other model you’d like to access the forum, who need verification) to the following example:
class User < ActiveRecord::Base has_many :topics, :through => :nickname has_one :nickname, :as => :nameable has_many :messages, :through => :nickname attr_accessible :nickname_attributes accepts_nested_attributes_for :nickname, :allow_destroy => trueend
5. You need to add this to your config.environment for now (i’ll make this better soon)
config.plugin_paths << [“#{RAILS_ROOT}/vendor/plugins/topical/vendor/plugins”]and stick this code snippet in application_controller.rb (Note: you may be using this helper_method line already, so just add the three below to it)
helper_method :logged_in?, :time_ago_or_time_stamp, :can_edit?# include all helpers, all the time
6. Topical has included a topical.css stylesheet for you, which you can use by including it in your layout file, or just cut and paste into your existing stylesheets. Whatever man, just do something with it.
Because Topical doesn’t care about which Auth Plugin you use, it also can’t predict what admin area protection you use. Remember to add something to make sure cretins can’t get at your Admin area shit.
Use the github issues area for any bugs/features you’d like fixed/requested. Update the Wiki too, if you would like to help other users out.
Thanks. Oh and this code started out as code which was lifted from Eldorado in late 2007, which was BEAST code, if i’m not mistaken. So I’ll be using this as a refactor exercise eventually, but as always thanks to trevor turk and the Beast guys.