Permalink
Browse files

Converted README to markdown

  • Loading branch information...
cmer committed Mar 1, 2012
1 parent 75e40c3 commit dd7c00cba92a8372bd2d8214f2494c9c311fc773
Showing with 232 additions and 195 deletions.
  1. +232 −0 README.md
  2. +0 −195 README.rdoc
View
232 README.md
@@ -0,0 +1,232 @@
+# Socialization
+
+Socialization is a Ruby Gem that allows any model to `Follow`, `Like` and/or `Mention` any other model. This is accomplished through double polymorphic relationships, but you don't need to know that since all the complexity is hidden from you.
+
+The Follow feature is similar to Twitter's follow. For example, John follows Jane. Unlike Facebook's "friendship", Follow is a one-way concept. The fact that John follows Jane doesn't mean that Jane follows John.
+
+The Like feature works just like a Facebook Like. For example, John likes Pulp Fiction.
+
+The Mention feature was written with Facebook mentions in mind. For example, John mentions Jane in a comment. Typically, Jane would be highlighted in the comment user interface and possibly notified that John mentioned her. This Facebook feature is occasionally called Tagging, although tagging is generally something [entirely different](http://en.wikipedia.org/wiki/Tag_(metadata).
+
+[![Build Status](https://secure.travis-ci.org/cmer/socialization.png?branch=master)](http://travis-ci.org/cmer/socialization)
+
+## Installation
+
+### Rails 3
+
+Add the gem to the gemfile:
+`gem "socialization"`
+
+Run the generator:
+`rails generate socialization -s`
+
+This will generate three migration files and three models named Follow, Like and Mention. You may delete the Follow, Like or Mention model and migration if you don't need that functionality in your application.
+
+### Rails 2.3.x Support
+
+This gem requires Rails 3 or better. Sorry!
+
+## Usage
+
+### Setup
+
+Allow a model to be followed:
+
+ class Celebrity < ActiveRecord::Base
+ ...
+ acts_as_followable
+ ...
+ end
+
+Allow a model to be a follower:
+
+ class User < ActiveRecord::Base
+ ...
+ acts_as_follower
+ ...
+ end
+
+
+Allow a model to be liked:
+
+ class Movie < ActiveRecord::Base
+ ...
+ acts_as_likeable
+ ...
+ end
+
+Allow a model to like:
+
+ class User < ActiveRecord::Base
+ ...
+ acts_as_liker
+ ...
+ end
+
+Allow a model to be mentioned:
+
+ class User < ActiveRecord::Base
+ ...
+ acts_as_mentionable
+ ...
+ end
+
+Allow a model to mention:
+
+ class Comment < ActiveRecord::Base
+ ...
+ acts_as_mentioner
+ ...
+ end
+
+Or a more complex case where users can like and follow each other:
+
+ class User < ActiveRecord::Base
+ ...
+ acts_as_follower
+ acts_as_followable
+ acts_as_liker
+ acts_as_likeable
+ acts_as_mentionable
+ ...
+ end
+
+***
+
+
+### acts_as_follower Methods
+
+Follow something
+
+ user.follow!(celebrity)
+
+Stop following
+
+ user.unfollow!(celebrity)
+
+Toggle
+
+ user.toggle_follow!(celebrity)
+
+Is following?
+
+ user.follows?(celebrity)
+
+
+***
+
+
+### acts_as_followable Methods
+
+Find out if an objects follows
+
+ celebrity.followed_by?(user)
+
+All followers
+
+ celebrity.followers(User)
+
+
+***
+
+
+### acts_as_liker Methods
+
+Like something
+
+ user.like!(movie)
+
+Stop liking
+
+ user.unlike!(movie)
+
+Toggle
+
+ user.toggle_like!(celebrity)
+
+Likes?
+
+ user.likes?(movie)
+
+***
+
+
+### acts_as_likeable Methods
+
+Find out if an objects likes
+
+ movie.liked_by?(user)
+
+All likers
+
+ movie.likers(User)
+
+***
+
+
+### acts_as_mentioner Methods
+
+**Note that a "mentioner" is the object containing the mention and not necessarily the actor. For example, John mentions Jane in a comment. The mentioner is the comment object, NOT John.**
+
+Mention something
+
+ comment.mention!(user)
+
+Remove mention
+
+ comment.unmention!(user)
+
+Toggle
+
+ user.toggle_mention!(celebrity)
+
+Mentions?
+
+ comment.mentions?(user)
+
+
+***
+
+
+### acts_as_mentionable Methods
+
+Find out if an objects mentions
+
+ user.mentioned_by?(comment)
+
+All mentioners
+
+ user.mentioners(Comment)
+
+
+***
+
+
+## Demo App
+
+For your convenience, I have added a demo app in demo/demo_app. It does not have a web UI, but you can play with Socialization in the Rails console. It should also help you figure out hown to use Socialization in the Real World.
+
+To use the demo app:
+
+ $ cd demo/demo_app
+ $ bundle
+ $ rake db:migrate
+ $ rake db:seed
+ $ rails console
+
+
+## Note on Patches/Pull Requests
+
+* Fork the project.
+* Make your feature addition or bug fix.
+* Add tests for it. This is important so I don't break it in a future version unintentionally.
+* Send me a pull request. Bonus points for topic branches.
+
+## Similar Projects
+
+[acts_as_follower](https://github.com/tcocca/acts_as_follower) is a similar project that I only discovered when I was 95% finished writing the first version of Socialization. I initially intended to name this project acts_as_follower only to find out the name was taken. You might want to check it out as well so see which one suits your needs better. Socialization is simpler, supports "Likes" and "Mentions" and easilly extendable; acts_as_follower has more "Follow" features, however.
+
+
+## Copyright
+
+Copyright (c) 2012 Carl Mercier -- Released under the MIT license.
Oops, something went wrong.

0 comments on commit dd7c00c

Please sign in to comment.