Skip to content

blowmage/disqussion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Disqussion – A library for using the Disqus web API.

Copyright:: © 2010 Mike Moore
License:: Distributes under the same terms as Ruby

Description

Disqussion is a library for using the Disqus API.

Install

[sudo] gem install disqussion

or

[sudo] gem sources -a http://gems.github.com
[sudo] gem install blowmage-disqussion

or

git clone git://github.com/blowmage/disqussion.git
cd disqussion
gem build disqussion.gemspec
[sudo] gem install disqussion-0.2.0.gem

Feeling your way around Disqussion

Disqussion uses the Disqus terminology of Forums, Threads, and Posts.
For the most typical use a Forum is your blog, a Thread is a blog entry, and a post is a comment.

Examples

Create Disqus Session

You need a Disqus account and your Disqus API key to use the Disqussion library.
You can retrieve your Disqus API key here: http://disqus.com/api/get_my_key/

require 'disqussion'

disqus = Disqussion.new 'YWxlaWRzdXRoMzhlbzdydGJna3VhZGpidGdvYThlcnk3YnRvZXVyeWIgb2FlndTh'

Or, you can put your Disqus key in ~./disqus_key and Disqussion will find and use it for you automagically.
The only text in the ~./disqus_key file should be your api key.

require 'disqussion'

disqus = Disqussion.new

Disqussion#new actually retrieves a Disqussion::Session object.
You can call Disqussion::Session#new directly if you like, but Disqussion#new is there to save you from typing more than you need. :)

Finding your Forums

Disqussion lazilly retrieves all the Forums you are allowed to access and keeps them in Session#forums.
Session#forums is an array of Disqus::Forum objects.

require 'disqussion'

puts "My Disqus Sites:"
Disqussion.new.forums.each do |forum|
  puts "  forum: #{forum.id} (#{forum.shortname}) - #{forum.name}"
end

If you want to find a specific Forum you can use the Session#[] helper passing in either the forum ID or the shortname.

require 'disqussion'

disqus     = Disqussion.new
rubiverse  = disqus['123456']
blowmage   = disqus['blowmage']

Finding your Threads

Disqussion lazilly retrieves all the Threads on your Forum.
Forum#threads is an array of Disqus::Thread objects.

require 'disqussion'

puts "My Blog Entries:"
Disqussion.new['blowmage'].threads.each do |thread|
  puts "  thread: #{thread.id} (#{thread.slug}) - #{thread.title}"
end

If you want to find a specific Thread you can use the Forum#[] helper passing in either the thread ID or the slug.

require 'disqussion'

disqus       = Disqussion.new
blowmage     = disqus['blowmage']
random_page  = blowmage['345678']
another_page = blowmage['announcing-disqussion']

Finding your Posts

Disqussion lazilly retrieves all the Posts on your Thread.
Thread#posts is an array of Disqus::Post objects.

require 'disqussion'

puts "My Blog Entry Comments:"
Disqussion.new['blowmage']['announcing-disqussion'].posts.each do |post|
  puts "  post: #{post.id} (#{post.created_at}) - #{post.author.name}"
  puts "  #{post.message}\n"
end

If you want to find a specific Post you can the Thread#[] helper passing in post ID.

require 'disqussion'

disqus   = Disqussion.new
blowmage = disqus['blowmage']
page     = blowmage['announcing-disqussion']
comment  = page.posts['567890']

Calling the Disqus Web API Directly

You can call the Disqus web API directly using Disqussion::API instead of using the Disqussion Forum, Thread, Post, and Author objects.
You can find more information on the class documentation here.

About

Disqussion is a library for using the Disqus API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages