Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit eebfe4e4d76897fed98291848d3e17f96872e0c1 @bhuga committed Mar 5, 2010
Showing with 1,758 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +6 −0 README.md
  3. +24 −0 UNLICENSE
  4. +8 −0 db.yml.example
  5. +9 −0 disable_old_comments.rb
  6. +6 −0 disqus/.gitignore
  7. +15 −0 disqus/History.txt
  8. +20 −0 disqus/MIT-LICENSE
  9. +37 −0 disqus/Manifest.txt
  10. +143 −0 disqus/README.rdoc
  11. +24 −0 disqus/Rakefile
  12. +2 −0 disqus/config/website.yml
  13. +7 −0 disqus/init.rb
  14. +72 −0 disqus/lib/disqus.rb
  15. +264 −0 disqus/lib/disqus/api.rb
  16. +27 −0 disqus/lib/disqus/author.rb
  17. +126 −0 disqus/lib/disqus/forum.rb
  18. +51 −0 disqus/lib/disqus/post.rb
  19. +73 −0 disqus/lib/disqus/thread.rb
  20. +8 −0 disqus/lib/disqus/version.rb
  21. +45 −0 disqus/lib/disqus/view_helpers.rb
  22. +185 −0 disqus/lib/disqus/widget.rb
  23. +23 −0 disqus/tasks/rcov.rake
  24. +80 −0 disqus/test/api_test.rb
  25. +3 −0 disqus/test/config.yml.sample
  26. +70 −0 disqus/test/forum_test.rb
  27. +15 −0 disqus/test/merb_test.rb
  28. +18 −0 disqus/test/post_test.rb
  29. +18 −0 disqus/test/rails_test.rb
  30. +1 −0 disqus/test/responses/bad_api_key.json
  31. +23 −0 disqus/test/responses/create_post.json
  32. +1 −0 disqus/test/responses/get_forum_api_key.json
  33. +12 −0 disqus/test/responses/get_forum_list.json
  34. +11 −0 disqus/test/responses/get_num_posts.json
  35. +18 −0 disqus/test/responses/get_thread_by_url.json
  36. +16 −0 disqus/test/responses/get_thread_list.json
  37. +37 −0 disqus/test/responses/get_thread_posts.json
  38. +17 −0 disqus/test/responses/thread_by_identifier.json
  39. +5 −0 disqus/test/responses/update_thread.json
  40. +32 −0 disqus/test/test_helper.rb
  41. +28 −0 disqus/test/thread_test.rb
  42. +37 −0 disqus/test/view_helpers_test.rb
  43. +58 −0 disqus/test/widget_test.rb
  44. +82 −0 import_comments.rb
@@ -0,0 +1 @@
+db.yml
@@ -0,0 +1,6 @@
+# Migrate from Drupal comments to Disqus
+
+This is a simple script to migrate a basic use case Drupal 6 site to Disqus.
+It talks to the database directly, rather than mess around with Drupal APIs,
+which means complicated use cases are probably not well represented.
+
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
@@ -0,0 +1,8 @@
+---
+:database: database_name
+:host: database.example.com
+:user: database_username
+:password: database_password
+:adapter: mysql
+:forum_shortname: disqus_shortname
+:api_key: disqus_api_key
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+require 'rubygems'
+require 'sequel'
+
+opts = YAML.load_file 'db.yml'
+
+db = Sequel.connect opts
+puts db[:node].first.inspect
+db[:node].update(:comment => 0)
@@ -0,0 +1,6 @@
+.DS_Store
+package
+coverage
+test/config.yml
+docs
+pkg
@@ -0,0 +1,15 @@
+== 1.0.2 2009-10-05
+ 2 bug fixes:
+ * The Disqus::API.post method now returns the response body rather than the response object (Nat Budin)
+ * Disqus::API.create_post now complies with DISQUS's API requirements (Nat Budin)
+
+== 1.0.1 2009-01-19
+ 2 minor enhancements:
+ * Improve docs (Quin Hoxie)
+ * Add developer and container_id options for comment threads. (Quin Hoxie)
+
+== 1.0.0 2009-01-05
+* 1 major enhancement:
+ * Support for Disqus API added (Matthew Van Horn)
+* 1 minor enhancement:
+ * Reorganized gem to use newgem
@@ -0,0 +1,20 @@
+Copyright (c) 2008 [name of plugin creator]
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,37 @@
+History.txt
+MIT-LICENSE
+Manifest.txt
+README.rdoc
+Rakefile
+config/website.yml
+init.rb
+lib/disqus.rb
+lib/disqus/api.rb
+lib/disqus/author.rb
+lib/disqus/forum.rb
+lib/disqus/post.rb
+lib/disqus/thread.rb
+lib/disqus/version.rb
+lib/disqus/view_helpers.rb
+lib/disqus/widget.rb
+tasks/rcov.rake
+test/api_test.rb
+test/config.yml.sample
+test/forum_test.rb
+test/merb_test.rb
+test/post_test.rb
+test/rails_test.rb
+test/responses/bad_api_key.json
+test/responses/create_post.json
+test/responses/get_forum_api_key.json
+test/responses/get_forum_list.json
+test/responses/get_num_posts.json
+test/responses/get_thread_by_url.json
+test/responses/get_thread_list.json
+test/responses/get_thread_posts.json
+test/responses/thread_by_identifier.json
+test/responses/update_thread.json
+test/test_helper.rb
+test/thread_test.rb
+test/view_helpers_test.rb
+test/widget_test.rb
@@ -0,0 +1,143 @@
+== Disqus Ruby Gem
+
+The Disqus Gem helps you easily integrate the {Disqus}[http://disqus.com]
+commenting system into your website. It works for any site programmed in Ruby,
+and has view helpers for Rails and Merb.
+
+Support for the Disqus Javascript widgets is stable. Disqus API support is
+"beta."
+
+=== What is Disqus?
+
+From the Disqus website:
+
+"Disqus, pronounced "discuss", is a service and tool for web comments and
+discussions. The Disqus comment system can be plugged into any website, blog,
+or application. Disqus makes commenting easier and more interactive, while
+connecting websites and commenters across a thriving discussion community."
+
+"Disqus is a free service to the general public with absolutely no inline advertisements."
+
+=== Get it
+
+ gem install disqus
+
+==== Bleeding Edge
+
+ gem install norman-disqus --source http://gems.github.com
+
+=== Use it:
+
+==== Configure it:
+
+===== Generic example:
+
+ Disqus::defaults[:account] = "my_disqus_account"
+ # Optional, only if you're using the API
+ Disqus::defaults[:api_key] = "my_disqus_api_key"
+
+===== Rails example:
+
+ # in config/development.rb (or production.rb, test.rb, etc.)
+ config.after_initialize do
+ Disqus::defaults[:account] = "my_disqus_account"
+ # Optional, only if you're using the API
+ Disqus::defaults[:api_key] = "my_disqus_api_key"
+ end
+
+Note that here the "after initialize" is necessary, otherwise your settings
+won't be set properly.
+
+===== Merb example:
+
+ # in config/init.rb
+ Merb::BootLoader.after_app_loads do
+ Disqus::defaults[:account] = "my_disqus_account"
+ # Optional, only if you're using the API
+ Disqus::defaults[:api_key] = "my_disqus_api_key"
+ end
+
+Note that here the "after_app_loads" is necessary, otherwise your settings
+won't be set properly.
+
+===== Options
+
+ :api_key => "" # your api key
+ :account => "", # your disqus account
+ :developer => false, # allows for threads to work on localhost
+ :container_id => 'disqus_thread', # desired thread container
+ :avatar_size => 48, # squared pixel size of avatars
+ :color => "grey", # theme color
+ :default_tab => "popular", # default widget tab
+ :hide_avatars => false, # hide or show avatars
+ :hide_mods => true, # hide or show moderation
+ :num_items => 15, # number of comments to display
+ :show_powered_by => true, # show or hide powered by line
+ :orientation => "horizontal" # comment orientation
+
+==== Show the comment threads widget on a post page:
+
+ # Loads the commenting system
+ disqus_thread
+
+ # Or if you're not using Rails/Merb:
+ Disqus::Widget::thread
+
+ # Sets the inner html to the comment count for any links on the page that
+ # have the anchor "disqus_thread". For example, "View Comments" below would
+ # be replaced by "1 comment" or "23 comments" etc.
+ # <a href="http://my.website/article-permalink#disqus_thread">View Comments</a>
+ # <a href="http://my.website/different-permalink#disqus_thread">View Comments</a>
+ disqus_comment_counts
+
+ # Or if you're not using Rails/Merb:
+ Disqus::Widget::comment_counts
+
+==== Show the combo widget on a post page:
+
+ disqus_combo(:color => "blue", :hide_mods => false, :num_items => 20)
+
+ # Or for non-Rails/Merb:
+ Disqus::Widget::combo(:color => "blue", :hide_mods => false, :num_items => 20)
+
+==== Show the comment count on a permalink:
+
+ link_to("Permalink", post_path(@post, :anchor => "disqus_thread"))
+ ...
+ disqus_comment_counts
+
+ # Or for non-Rails/Merb:
+ Disqus::Widget::comment_counts
+
+==== Work with the Disqus API:
+
+See the Disqus::Api class for more info on the Disqus API. You can also read
+the {Disqus developer info here}[http://disqus.com/docs/api/].
+
+=== Hack it:
+
+Github repository:
+
+ http://github.com/norman/disqus
+
+=== Submit bug reports:
+
+Please use our {Lighthouse}[http://randomba.lighthouseapp.com/projects/16065-disqus/].
+
+=== Learn more about Disqus:
+
+{http://disqus.com}[http://disqus.com]
+
+=== Thanks to the following contributors:
+
+* {Matt Van Horn}[http://github.com/mattvanhorn] - Disqus API
+* {Quin Hoxie}[http://github.com/qhoxie] - Merb support
+
+=== Legal Stuff
+
+The Disqus Ruby gem was not created by, nor is officially supported by
+Disqus.com or Big Head Labs, Inc. Use it at your own risk and your own
+responsibility under the terms of the MIT License.
+
+Copyright (c) 2008 {Norman Clarke}[mailto:norman@randomba.org], released under
+the MIT license
@@ -0,0 +1,24 @@
+require 'newgem'
+require 'hoe'
+require 'lib/disqus/version'
+
+$hoe = Hoe.new("disqus", Disqus::Version::STRING) do |p|
+ p.rubyforge_name = "disqus"
+ p.author = ['Norman Clarke', 'Matthew Van Horn']
+ p.email = ['norman@njclarke.com', 'mattvanhorn@gmail.com']
+ p.summary = "Integrates Disqus commenting system into your Ruby-powered site."
+ p.description = 'Integrates Disqus into your Ruby-powered site. Works with any Ruby website, and has view helpers for Rails and Merb.'
+ p.url = 'http://disqus.rubyforge.org'
+ p.test_globs = ['test/**/*_test.rb']
+ p.extra_deps << ['json']
+ p.extra_dev_deps = [
+ ['newgem', ">= #{::Newgem::VERSION}"],
+ ['mocha']
+ ]
+ p.rsync_args = '-av --delete --ignore-errors'
+ changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
+ p.remote_rdoc_dir = ""
+end
+
+require 'newgem/tasks'
+Dir['tasks/**/*.rake'].each { |t| load t }
@@ -0,0 +1,2 @@
+host: compay@rubyforge.org
+remote_dir: /var/www/gforge-projects/disqus
@@ -0,0 +1,7 @@
+require 'disqus'
+require 'disqus/api'
+require 'disqus/author'
+require 'disqus/forum'
+require 'disqus/post'
+require 'disqus/thread'
+require 'disqus/version'
@@ -0,0 +1,72 @@
+require 'disqus/widget'
+
+# == From the {Disqus Website}[http://disqus.com]:
+
+# "Disqus, pronounced "discuss", is a service and tool for web comments and
+# discussions. The Disqus comment system can be plugged into any website, blog,
+# or application. Disqus makes commenting easier and more interactive, while
+# connecting websites and commenters across a thriving discussion community."
+#
+# "Disqus is a free service to the general public with absolutely no inline
+# advertisements."
+
+# The Disqus gem helps you quickly and easily integrate Disqus's Javascript
+# widgets into your Ruby-based website. Adding Disqus to your site literally
+# takes only a few minutes. The Disqus gem also provides a complete
+# implementation of the Disqus API for more complex applications.
+
+# To use this code, please first create an account on Disqus[http://disqus.com].
+module Disqus
+
+ @defaults = {
+ :api_key => "",
+ :account => "",
+ :developer => false,
+ :container_id => 'disqus_thread',
+ :avatar_size => 48,
+ :color => "grey",
+ :default_tab => "popular",
+ :hide_avatars => false,
+ :hide_mods => true,
+ :num_items => 15,
+ :show_powered_by => true,
+ :orientation => "horizontal"
+ }
+
+ # Disqus defaults:
+ # :account => "",
+ # :avatar_size => 48,
+ # :color => "grey",
+ # :default_tab => "popular",
+ # :hide_avatars => false,
+ # :hide_mods => true,
+ # :num_items => 15,
+ # :show_powered_by => true,
+ # :orientation => "horizontal"
+ def self.defaults
+ @defaults
+ end
+
+ # Load the view helpers if the gem is included in a Rails app.
+ def self.enable_rails
+ return if ActionView::Base.instance_methods.include? 'disqus_thread'
+ require 'disqus/view_helpers'
+ ActionView::Base.class_eval { include Disqus::ViewHelpers }
+ end
+
+ # Load the view helpers if the gem is included in a Merb app.
+ def self.enable_merb
+ return if Merb::Controller.instance_methods.include? 'disqus_thread'
+ require 'disqus/view_helpers'
+ Merb::Controller.class_eval { include Disqus::ViewHelpers }
+ end
+
+end
+
+if defined?(Rails) and defined?(ActionView)
+ Disqus::enable_rails
+end
+
+if defined?(Merb)
+ Disqus::enable_merb
+end
Oops, something went wrong.

0 comments on commit eebfe4e

Please sign in to comment.