disqus 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2008-2010 Norman Clarke
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,24 +1,26 @@
1
- require 'newgem'
2
- require 'hoe'
1
+ require "rake"
2
+ require "rake/testtask"
3
+ require "rake/gempackagetask"
4
+ require "rake/rdoctask"
5
+ require "rake/clean"
3
6
  require 'lib/disqus/version'
4
7
 
5
- $hoe = Hoe.new("disqus", Disqus::Version::STRING) do |p|
6
- p.rubyforge_name = "disqus"
7
- p.author = ['Norman Clarke', 'Matthew Van Horn']
8
- p.email = ['norman@njclarke.com', 'mattvanhorn@gmail.com']
9
- p.summary = "Integrates Disqus commenting system into your Ruby-powered site."
10
- p.description = 'Integrates Disqus into your Ruby-powered site. Works with any Ruby website, and has view helpers for Rails and Merb.'
11
- p.url = 'http://disqus.rubyforge.org'
12
- p.test_globs = ['test/**/*_test.rb']
13
- p.extra_deps << ['json']
14
- p.extra_dev_deps = [
15
- ['newgem', ">= #{::Newgem::VERSION}"],
16
- ['mocha']
17
- ]
18
- p.rsync_args = '-av --delete --ignore-errors'
19
- changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
20
- p.remote_rdoc_dir = ""
8
+ CLEAN << "pkg" << "doc" << "coverage"
9
+
10
+ Rake::GemPackageTask.new(eval(File.read("disqus.gemspec"))) { |pkg| }
11
+ Rake::TestTask.new(:test) { |t| t.pattern = "test/*_test.rb" }
12
+
13
+ Rake::RDocTask.new do |r|
14
+ r.rdoc_dir = "doc"
15
+ r.rdoc_files.include "lib/**/*.rb"
21
16
  end
22
17
 
23
- require 'newgem/tasks'
24
- Dir['tasks/**/*.rake'].each { |t| load t }
18
+ begin
19
+ require "rcov/rcovtask"
20
+ Rcov::RcovTask.new do |r|
21
+ r.test_files = FileList["test/**/*_test.rb"]
22
+ r.verbose = true
23
+ r.rcov_opts << "--exclude gems/*"
24
+ end
25
+ rescue LoadError
26
+ end
@@ -1,5 +1,7 @@
1
- require 'disqus/widget'
2
-
1
+ %w[api author forum post thread version view_helpers widget].each do |file|
2
+ require File.join(File.dirname(__FILE__), "disqus", file)
3
+ end
4
+
3
5
  # == From the {Disqus Website}[http://disqus.com]:
4
6
 
5
7
  # "Disqus, pronounced "discuss", is a service and tool for web comments and
@@ -19,54 +21,32 @@ require 'disqus/widget'
19
21
  module Disqus
20
22
 
21
23
  @defaults = {
22
- :api_key => "",
23
- :account => "",
24
- :developer => false,
25
- :container_id => 'disqus_thread',
26
- :avatar_size => 48,
27
- :color => "grey",
28
- :default_tab => "popular",
29
- :hide_avatars => false,
30
- :hide_mods => true,
31
- :num_items => 15,
24
+ :api_key => "",
25
+ :account => "",
26
+ :developer => false,
27
+ :container_id => 'disqus_thread',
28
+ :avatar_size => 48,
29
+ :color => "grey",
30
+ :default_tab => "popular",
31
+ :hide_avatars => false,
32
+ :hide_mods => true,
33
+ :num_items => 15,
32
34
  :show_powered_by => true,
33
- :orientation => "horizontal"
35
+ :orientation => "horizontal"
34
36
  }
35
37
 
36
38
  # Disqus defaults:
37
- # :account => "",
38
- # :avatar_size => 48,
39
- # :color => "grey",
40
- # :default_tab => "popular",
41
- # :hide_avatars => false,
42
- # :hide_mods => true,
43
- # :num_items => 15,
39
+ # :account => "",
40
+ # :avatar_size => 48,
41
+ # :color => "grey",
42
+ # :default_tab => "popular",
43
+ # :hide_avatars => false,
44
+ # :hide_mods => true,
45
+ # :num_items => 15,
44
46
  # :show_powered_by => true,
45
- # :orientation => "horizontal"
47
+ # :orientation => "horizontal"
46
48
  def self.defaults
47
49
  @defaults
48
50
  end
49
-
50
- # Load the view helpers if the gem is included in a Rails app.
51
- def self.enable_rails
52
- return if ActionView::Base.instance_methods.include? 'disqus_thread'
53
- require 'disqus/view_helpers'
54
- ActionView::Base.class_eval { include Disqus::ViewHelpers }
55
- end
56
-
57
- # Load the view helpers if the gem is included in a Merb app.
58
- def self.enable_merb
59
- return if Merb::Controller.instance_methods.include? 'disqus_thread'
60
- require 'disqus/view_helpers'
61
- Merb::Controller.class_eval { include Disqus::ViewHelpers }
62
- end
63
-
64
- end
65
51
 
66
- if defined?(Rails) and defined?(ActionView)
67
- Disqus::enable_rails
68
- end
69
-
70
- if defined?(Merb)
71
- Disqus::enable_merb
72
- end
52
+ end
@@ -1,5 +1,4 @@
1
1
  require 'open-uri'
2
- require 'rubygems'
3
2
  require 'json'
4
3
  require 'net/http'
5
4
  require 'uri'
@@ -40,6 +39,7 @@ module Disqus
40
39
  class Api
41
40
 
42
41
  ROOT = 'http://disqus.com/api'
42
+ API_VERSION = '1.1'
43
43
 
44
44
  class << self
45
45
 
@@ -185,7 +185,7 @@ module Disqus
185
185
  # * <tt>:title</tt> - the title of the thread to possibly be created
186
186
  # * <tt>:identifier</tt> - a string of your choosing
187
187
  def thread_by_identifier(opts = {})
188
- JSON.parse(post('thread_by_identifier', :forum_api_key => opts[:forum_api_key],
188
+ JSON.parse(post('thread_by_identifier/', :forum_api_key => opts[:forum_api_key],
189
189
  :identifier => opts[:identifier],
190
190
  :title => opts[:title] ))
191
191
  end
@@ -206,15 +206,7 @@ module Disqus
206
206
  # * <tt>:url</tt> - the URL this thread is on, if known.
207
207
  # * <tt>:allow_comment</tt> - whether this thread is open to new comments
208
208
  def update_thread(opts = {})
209
- raise opts.inspect
210
- JSON.parse(post('update_thread',
211
- :forum_api_key => opts[:forum_api_key],
212
- :thread_id => opts[:thread_id],
213
- :title => opts[:title],
214
- :slug => opts[:slug],
215
- :url => opts[:url],
216
- :allow_comments => opts[:allow_comments])
217
- )
209
+ JSON.parse(post('update_thread/', opts))
218
210
  end
219
211
 
220
212
  # Widget to includes a comment form suitable for use with the Disqus
@@ -237,10 +229,12 @@ module Disqus
237
229
  end
238
230
 
239
231
  def get(*args)
232
+ args << { :api_version => API_VERSION }
240
233
  open(make_url(*args)) {|u| u.read }
241
234
  end
242
235
 
243
236
  def post(*args)
237
+ args << { :api_version => API_VERSION }
244
238
  url = ROOT + '/' + args.shift
245
239
  post_params = {}
246
240
  args.shift.each { |k, v| post_params[k.to_s]=v.to_s }
@@ -1,8 +1,8 @@
1
- module Disqus #:nodoc:
2
- module Version #:nodoc:
1
+ module Disqus
2
+ module Version
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 3
6
6
  STRING = [MAJOR, MINOR, TINY].join('.')
7
7
  end
8
- end
8
+ end
@@ -1,45 +1,9 @@
1
- module Disqus
2
-
3
- # Shortcuts to access the widgets as simple functions as opposed to using
4
- # their full qualified names. These helpers are loaded automatically in
5
- # Rails and Merb apps.
6
- #
7
- # For Sinatra, Camping, Nitro or other frameworks, you can include the
8
- # helper if you wish, or use the fully-qualified names. Really this is just
9
- # here for aesthetic purposes and to make it less likely to step on anyone's
10
- # namespace.
11
- module ViewHelpers
12
-
13
- # See Disqus::Widget.thread
14
- def disqus_thread(options = {})
15
- Disqus::Widget::thread(options)
16
- end
17
-
18
- # See Disqus::Widget.comment_counts
19
- def disqus_comment_counts(options = {})
20
- Disqus::Widget::comment_counts(options)
21
- end
22
-
23
- # See Disqus::Widget.top_commenters
24
- def disqus_top_commenters(options = {})
25
- Disqus::Widget::top_commenters(options)
26
- end
27
-
28
- # See Disqus::Widget.popular_threads
29
- def disqus_popular_threads(options = {})
30
- Disqus::Widget::popular_threads(options)
31
- end
32
-
33
- # See Disqus::Widget.recent_comments
34
- def disqus_recent_comments(options = {})
35
- Disqus::Widget::recent_comments(options)
36
- end
37
-
38
- # See Disqus::Widget.combo
39
- def disqus_combo(options = {})
40
- Disqus::Widget::combo(options)
41
- end
42
-
43
- end
44
-
1
+ # Shortcuts to access the widgets as simple functions as opposed to using
2
+ # their full qualified names.
3
+ %w[combo comment_counts popular_threads recent_comments thread top_commenters].each do |method|
4
+ eval(<<-EOM)
5
+ def disqus_#{method}(options = {})
6
+ Disqus::Widget.#{method}(options)
7
+ end
8
+ EOM
45
9
  end
@@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/test_helper'
3
3
  class ApiTest < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
- require 'disqus'
7
6
  Disqus.defaults[:api_key] = DISQUS_TEST["api_key"]
8
7
  end
9
8
 
@@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/test_helper'
3
3
  class ForumTest < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
- require 'disqus'
7
6
  Disqus.defaults[:api_key] = DISQUS_TEST["api_key"]
8
7
  stub_api_call(:get_forum_api_key).returns("FAKE_FORUM_API_KEY")
9
8
  end
@@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/test_helper'
3
3
  class PostTest < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
- require 'disqus'
7
6
  Disqus.defaults[:api_key] = DISQUS_TEST["api_key"]
8
7
  end
9
8
 
@@ -1,13 +1,14 @@
1
+ require 'rubygems'
1
2
  require 'test/unit'
2
3
  require 'yaml'
3
- require 'disqus/api'
4
- require 'disqus/forum'
5
- require 'disqus/thread'
6
- require 'disqus/post'
7
- require 'disqus/author'
8
4
  require 'mocha'
5
+ require File.join(File.dirname(__FILE__), "..", "lib", "disqus")
9
6
 
10
- DISQUS_TEST = YAML.load(File.read(File.dirname(__FILE__) + "/config.yml"))
7
+ DISQUS_TEST = {
8
+ # Only if you want to run against a live server. Not generally useful, you
9
+ # should be using stubs.
10
+ :api_key => "YOUR API KEY GOES HERE"
11
+ }
11
12
 
12
13
  def create_forum
13
14
  forum = Disqus::Forum.new(1234, "disqus-test", "Disqus Test", "2008-01-03 14:44:07.627492")
@@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/test_helper'
3
3
  class ThreadTest < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
- require 'disqus'
7
6
  Disqus.defaults[:api_key] = DISQUS_TEST["api_key"]
8
7
  stub_api_call(:get_forum_api_key)
9
8
  end
@@ -1,6 +1,3 @@
1
- require 'test/unit'
2
- require 'disqus'
3
-
4
1
  class DisqusWidgetTest < Test::Unit::TestCase
5
2
 
6
3
  def setup
@@ -8,50 +5,50 @@ class DisqusWidgetTest < Test::Unit::TestCase
8
5
  end
9
6
 
10
7
  def test_thread
11
- assert Disqus::Widget::thread
8
+ assert disqus_thread
12
9
  end
13
10
 
14
11
  def test_comment_counts
15
- assert Disqus::Widget::comment_counts
12
+ assert disqus_comment_counts
16
13
  end
17
14
 
18
15
  def test_combo
19
- assert Disqus::Widget::combo
16
+ assert disqus_combo
20
17
  end
21
18
 
22
19
  def test_recent_comments
23
- assert Disqus::Widget::recent_comments
20
+ assert disqus_recent_comments
24
21
  end
25
22
 
26
23
  def test_popular_threads
27
- assert Disqus::Widget::popular_threads
24
+ assert disqus_popular_threads
28
25
  end
29
26
 
30
27
  def test_top_commenters
31
- assert Disqus::Widget::top_commenters
28
+ assert disqus_top_commenters
32
29
  end
33
30
 
34
31
  def test_invalid_default_tab
35
32
  assert_raises ArgumentError do
36
- Disqus::Widget::combo(:default_tab => "test")
33
+ disqus_combo(:default_tab => "test")
37
34
  end
38
35
  end
39
36
 
40
37
  def test_invalid_color
41
38
  assert_raises ArgumentError do
42
- Disqus::Widget::combo(:color => "test")
39
+ disqus_combo(:color => "test")
43
40
  end
44
41
  end
45
42
 
46
43
  def test_invalid_num_items
47
44
  assert_raises ArgumentError do
48
- Disqus::Widget::combo(:num_items => 100)
45
+ disqus_combo(:num_items => 100)
49
46
  end
50
47
  end
51
48
 
52
49
  def test_invalid_avatar_size
53
50
  assert_raises ArgumentError do
54
- Disqus::Widget::top_commenters(:avatar_size => 100)
51
+ disqus_top_commenters(:avatar_size => 100)
55
52
  end
56
53
  end
57
54
 
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disqus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 3
9
+ version: 1.0.3
5
10
  platform: ruby
6
11
  authors:
7
12
  - Norman Clarke
@@ -10,49 +15,33 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2009-10-19 00:00:00 -03:00
18
+ date: 2010-03-30 00:00:00 -03:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
17
22
  name: json
18
- type: :runtime
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
24
30
  version: "0"
25
- version:
26
- - !ruby/object:Gem::Dependency
27
- name: newgem
28
- type: :development
29
- version_requirement:
30
- version_requirements: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 1.5.2
35
- version:
31
+ type: :runtime
32
+ version_requirements: *id001
36
33
  - !ruby/object:Gem::Dependency
37
34
  name: mocha
38
- type: :development
39
- version_requirement:
40
- version_requirements: !ruby/object:Gem::Requirement
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
41
37
  requirements:
42
38
  - - ">="
43
39
  - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
44
42
  version: "0"
45
- version:
46
- - !ruby/object:Gem::Dependency
47
- name: hoe
48
43
  type: :development
49
- version_requirement:
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 2.3.3
55
- version:
44
+ version_requirements: *id002
56
45
  description: Integrates Disqus into your Ruby-powered site. Works with any Ruby website, and has view helpers for Rails and Merb.
57
46
  email:
58
47
  - norman@njclarke.com
@@ -61,18 +50,9 @@ executables: []
61
50
 
62
51
  extensions: []
63
52
 
64
- extra_rdoc_files:
65
- - History.txt
66
- - Manifest.txt
53
+ extra_rdoc_files: []
54
+
67
55
  files:
68
- - History.txt
69
- - MIT-LICENSE
70
- - Manifest.txt
71
- - README.rdoc
72
- - Rakefile
73
- - config/website.yml
74
- - init.rb
75
- - lib/disqus.rb
76
56
  - lib/disqus/api.rb
77
57
  - lib/disqus/author.rb
78
58
  - lib/disqus/forum.rb
@@ -81,13 +61,12 @@ files:
81
61
  - lib/disqus/version.rb
82
62
  - lib/disqus/view_helpers.rb
83
63
  - lib/disqus/widget.rb
84
- - tasks/rcov.rake
64
+ - lib/disqus.rb
65
+ - LICENSE
66
+ - Rakefile
85
67
  - test/api_test.rb
86
- - test/config.yml.sample
87
68
  - test/forum_test.rb
88
- - test/merb_test.rb
89
69
  - test/post_test.rb
90
- - test/rails_test.rb
91
70
  - test/responses/bad_api_key.json
92
71
  - test/responses/create_post.json
93
72
  - test/responses/get_forum_api_key.json
@@ -100,43 +79,40 @@ files:
100
79
  - test/responses/update_thread.json
101
80
  - test/test_helper.rb
102
81
  - test/thread_test.rb
103
- - test/view_helpers_test.rb
104
82
  - test/widget_test.rb
105
83
  has_rdoc: true
106
- homepage: http://disqus.rubyforge.org
84
+ homepage: http://github.com/norman/disqus
107
85
  licenses: []
108
86
 
109
87
  post_install_message:
110
- rdoc_options:
111
- - --main
112
- - README.txt
88
+ rdoc_options: []
89
+
113
90
  require_paths:
114
91
  - lib
115
92
  required_ruby_version: !ruby/object:Gem::Requirement
116
93
  requirements:
117
94
  - - ">="
118
95
  - !ruby/object:Gem::Version
96
+ segments:
97
+ - 0
119
98
  version: "0"
120
- version:
121
99
  required_rubygems_version: !ruby/object:Gem::Requirement
122
100
  requirements:
123
101
  - - ">="
124
102
  - !ruby/object:Gem::Version
103
+ segments:
104
+ - 0
125
105
  version: "0"
126
- version:
127
106
  requirements: []
128
107
 
129
108
  rubyforge_project: disqus
130
- rubygems_version: 1.3.5
109
+ rubygems_version: 1.3.6
131
110
  signing_key:
132
111
  specification_version: 3
133
112
  summary: Integrates Disqus commenting system into your Ruby-powered site.
134
113
  test_files:
135
114
  - test/api_test.rb
136
115
  - test/forum_test.rb
137
- - test/merb_test.rb
138
116
  - test/post_test.rb
139
- - test/rails_test.rb
140
117
  - test/thread_test.rb
141
- - test/view_helpers_test.rb
142
118
  - test/widget_test.rb
@@ -1,15 +0,0 @@
1
- == 1.0.2 2009-10-05
2
- 2 bug fixes:
3
- * The Disqus::API.post method now returns the response body rather than the response object (Nat Budin)
4
- * Disqus::API.create_post now complies with DISQUS's API requirements (Nat Budin)
5
-
6
- == 1.0.1 2009-01-19
7
- 2 minor enhancements:
8
- * Improve docs (Quin Hoxie)
9
- * Add developer and container_id options for comment threads. (Quin Hoxie)
10
-
11
- == 1.0.0 2009-01-05
12
- * 1 major enhancement:
13
- * Support for Disqus API added (Matthew Van Horn)
14
- * 1 minor enhancement:
15
- * Reorganized gem to use newgem
@@ -1,20 +0,0 @@
1
- Copyright (c) 2008 [name of plugin creator]
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,37 +0,0 @@
1
- History.txt
2
- MIT-LICENSE
3
- Manifest.txt
4
- README.rdoc
5
- Rakefile
6
- config/website.yml
7
- init.rb
8
- lib/disqus.rb
9
- lib/disqus/api.rb
10
- lib/disqus/author.rb
11
- lib/disqus/forum.rb
12
- lib/disqus/post.rb
13
- lib/disqus/thread.rb
14
- lib/disqus/version.rb
15
- lib/disqus/view_helpers.rb
16
- lib/disqus/widget.rb
17
- tasks/rcov.rake
18
- test/api_test.rb
19
- test/config.yml.sample
20
- test/forum_test.rb
21
- test/merb_test.rb
22
- test/post_test.rb
23
- test/rails_test.rb
24
- test/responses/bad_api_key.json
25
- test/responses/create_post.json
26
- test/responses/get_forum_api_key.json
27
- test/responses/get_forum_list.json
28
- test/responses/get_num_posts.json
29
- test/responses/get_thread_by_url.json
30
- test/responses/get_thread_list.json
31
- test/responses/get_thread_posts.json
32
- test/responses/thread_by_identifier.json
33
- test/responses/update_thread.json
34
- test/test_helper.rb
35
- test/thread_test.rb
36
- test/view_helpers_test.rb
37
- test/widget_test.rb
@@ -1,143 +0,0 @@
1
- == Disqus Ruby Gem
2
-
3
- The Disqus Gem helps you easily integrate the {Disqus}[http://disqus.com]
4
- commenting system into your website. It works for any site programmed in Ruby,
5
- and has view helpers for Rails and Merb.
6
-
7
- Support for the Disqus Javascript widgets is stable. Disqus API support is
8
- "beta."
9
-
10
- === What is Disqus?
11
-
12
- From the Disqus website:
13
-
14
- "Disqus, pronounced "discuss", is a service and tool for web comments and
15
- discussions. The Disqus comment system can be plugged into any website, blog,
16
- or application. Disqus makes commenting easier and more interactive, while
17
- connecting websites and commenters across a thriving discussion community."
18
-
19
- "Disqus is a free service to the general public with absolutely no inline advertisements."
20
-
21
- === Get it
22
-
23
- gem install disqus
24
-
25
- ==== Bleeding Edge
26
-
27
- gem install norman-disqus --source http://gems.github.com
28
-
29
- === Use it:
30
-
31
- ==== Configure it:
32
-
33
- ===== Generic example:
34
-
35
- Disqus::defaults[:account] = "my_disqus_account"
36
- # Optional, only if you're using the API
37
- Disqus::defaults[:api_key] = "my_disqus_api_key"
38
-
39
- ===== Rails example:
40
-
41
- # in config/development.rb (or production.rb, test.rb, etc.)
42
- config.after_initialize do
43
- Disqus::defaults[:account] = "my_disqus_account"
44
- # Optional, only if you're using the API
45
- Disqus::defaults[:api_key] = "my_disqus_api_key"
46
- end
47
-
48
- Note that here the "after initialize" is necessary, otherwise your settings
49
- won't be set properly.
50
-
51
- ===== Merb example:
52
-
53
- # in config/init.rb
54
- Merb::BootLoader.after_app_loads do
55
- Disqus::defaults[:account] = "my_disqus_account"
56
- # Optional, only if you're using the API
57
- Disqus::defaults[:api_key] = "my_disqus_api_key"
58
- end
59
-
60
- Note that here the "after_app_loads" is necessary, otherwise your settings
61
- won't be set properly.
62
-
63
- ===== Options
64
-
65
- :api_key => "" # your api key
66
- :account => "", # your disqus account
67
- :developer => false, # allows for threads to work on localhost
68
- :container_id => 'disqus_thread', # desired thread container
69
- :avatar_size => 48, # squared pixel size of avatars
70
- :color => "grey", # theme color
71
- :default_tab => "popular", # default widget tab
72
- :hide_avatars => false, # hide or show avatars
73
- :hide_mods => true, # hide or show moderation
74
- :num_items => 15, # number of comments to display
75
- :show_powered_by => true, # show or hide powered by line
76
- :orientation => "horizontal" # comment orientation
77
-
78
- ==== Show the comment threads widget on a post page:
79
-
80
- # Loads the commenting system
81
- disqus_thread
82
-
83
- # Or if you're not using Rails/Merb:
84
- Disqus::Widget::thread
85
-
86
- # Sets the inner html to the comment count for any links on the page that
87
- # have the anchor "disqus_thread". For example, "View Comments" below would
88
- # be replaced by "1 comment" or "23 comments" etc.
89
- # <a href="http://my.website/article-permalink#disqus_thread">View Comments</a>
90
- # <a href="http://my.website/different-permalink#disqus_thread">View Comments</a>
91
- disqus_comment_counts
92
-
93
- # Or if you're not using Rails/Merb:
94
- Disqus::Widget::comment_counts
95
-
96
- ==== Show the combo widget on a post page:
97
-
98
- disqus_combo(:color => "blue", :hide_mods => false, :num_items => 20)
99
-
100
- # Or for non-Rails/Merb:
101
- Disqus::Widget::combo(:color => "blue", :hide_mods => false, :num_items => 20)
102
-
103
- ==== Show the comment count on a permalink:
104
-
105
- link_to("Permalink", post_path(@post, :anchor => "disqus_thread"))
106
- ...
107
- disqus_comment_counts
108
-
109
- # Or for non-Rails/Merb:
110
- Disqus::Widget::comment_counts
111
-
112
- ==== Work with the Disqus API:
113
-
114
- See the Disqus::Api class for more info on the Disqus API. You can also read
115
- the {Disqus developer info here}[http://disqus.com/docs/api/].
116
-
117
- === Hack it:
118
-
119
- Github repository:
120
-
121
- http://github.com/norman/disqus
122
-
123
- === Submit bug reports:
124
-
125
- Please use our {Lighthouse}[http://randomba.lighthouseapp.com/projects/16065-disqus/].
126
-
127
- === Learn more about Disqus:
128
-
129
- {http://disqus.com}[http://disqus.com]
130
-
131
- === Thanks to the following contributors:
132
-
133
- * {Matt Van Horn}[http://github.com/mattvanhorn] - Disqus API
134
- * {Quin Hoxie}[http://github.com/qhoxie] - Merb support
135
-
136
- === Legal Stuff
137
-
138
- The Disqus Ruby gem was not created by, nor is officially supported by
139
- Disqus.com or Big Head Labs, Inc. Use it at your own risk and your own
140
- responsibility under the terms of the MIT License.
141
-
142
- Copyright (c) 2008 {Norman Clarke}[mailto:norman@randomba.org], released under
143
- the MIT license
@@ -1,2 +0,0 @@
1
- host: compay@rubyforge.org
2
- remote_dir: /var/www/gforge-projects/disqus
data/init.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'disqus'
2
- require 'disqus/api'
3
- require 'disqus/author'
4
- require 'disqus/forum'
5
- require 'disqus/post'
6
- require 'disqus/thread'
7
- require 'disqus/version'
@@ -1,23 +0,0 @@
1
- desc "Run RCov"
2
- task :rcov do
3
- run_coverage Dir["test/**/*_test.rb"]
4
- end
5
-
6
- def run_coverage(files)
7
- rm_f "coverage"
8
- rm_f "coverage.data"
9
- if files.length == 0
10
- puts "No files were specified for testing"
11
- return
12
- end
13
- files = files.join(" ")
14
- if PLATFORM =~ /darwin/
15
- exclude = '--exclude "gems/"'
16
- else
17
- exclude = '--exclude "rubygems"'
18
- end
19
- rcov = "rcov -Ilib:test --sort coverage --text-report #{exclude} --no-validator-links"
20
- cmd = "#{rcov} #{files}"
21
- puts cmd
22
- sh cmd
23
- end
@@ -1,3 +0,0 @@
1
- # This can be used to do actual calls to the API rather than use mocks during
2
- # testing. This can be useful to verify tests against API changes.
3
- api_key: 'YOUR DISQUS USER API KEY GOES HERE'
@@ -1,15 +0,0 @@
1
- require 'test/unit'
2
-
3
- module Merb
4
- class Controller
5
- end
6
- end
7
-
8
- class MerbTest < Test::Unit::TestCase
9
-
10
- def test_view_helpers_should_be_included
11
- require 'disqus'
12
- assert Merb::Controller.new.disqus_thread
13
- end
14
-
15
- end
@@ -1,18 +0,0 @@
1
- require 'test/unit'
2
-
3
- class Rails
4
- end
5
-
6
- module ActionView
7
- class Base
8
- end
9
- end
10
-
11
- class RailsTest < Test::Unit::TestCase
12
-
13
- def test_view_helpers_should_be_included
14
- require 'disqus'
15
- assert ActionView::Base.new.disqus_thread
16
- end
17
-
18
- end
@@ -1,37 +0,0 @@
1
- require 'test/unit'
2
- require 'disqus'
3
- require 'disqus/view_helpers'
4
-
5
- class ViewHelpersTest < Test::Unit::TestCase
6
-
7
- include Disqus::ViewHelpers
8
-
9
- def setup
10
- Disqus::defaults[:account] = "tests"
11
- end
12
-
13
- def test_disqus_thread
14
- assert disqus_thread
15
- end
16
-
17
- def test_disqus_comment_counts
18
- assert disqus_comment_counts
19
- end
20
-
21
- def test_disqus_top_commenters
22
- assert disqus_top_commenters
23
- end
24
-
25
- def test_disqus_popular_threads
26
- assert disqus_popular_threads
27
- end
28
-
29
- def test_disqus_recent_comments
30
- assert disqus_recent_comments
31
- end
32
-
33
- def test_disqus_combo
34
- assert disqus_combo
35
- end
36
-
37
- end