sinatra-disqus 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aff92a05e2278aae7766e0922c7bd66a7528caf1
4
+ data.tar.gz: 5d2a66a4f66c40893ee2d53c1e1a9f4697e06bad
5
+ SHA512:
6
+ metadata.gz: abddbc3a2aee65a721099063f51c8758a843d89623bbc18756e8ad0aa3a288c3ee25f001dadec74de663b2878e25cb9e4bc9f7ea1bd2373a243e151762360513
7
+ data.tar.gz: 400f9a79bc6e6a73ee740c430c87aa95f1122573352d87e8bdf55db8f25a86bad49d144f3d30c91470e63c61c0fadbe8c4bf26e6a3338cd90406715204c64a26
data/.gitignore CHANGED
@@ -16,4 +16,5 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  bin/
19
- vendor/
19
+ vendor/
20
+ vendor.noindex/
data/CHANGES.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## CH-CH-CH-CH-CHANGES! ##
2
2
 
3
+ ### Wednesday the 4th of November 2015, v2.1.0 ###
4
+
5
+ * Added setting for host, as an alternative to the one in the request. Useful when running on localhost but still want the request to output a domain.
6
+ * Chopped up the script into smaller pieces to make dealing with it easier (internal).
7
+
8
+ ----
9
+
10
+
3
11
  ### Friday the 28th of June 2013, v2.0.0 ###
4
12
 
5
13
  * Disqus has dropped support for developer mode. Updated to reflect this.
data/README.md CHANGED
@@ -49,7 +49,7 @@ Note: It used to be that you were able to put Disqus into "development mode", [t
49
49
  %p
50
50
  Now for some comments:
51
51
  #comments
52
- inject_disqus
52
+ = inject_disqus
53
53
 
54
54
  #### Modular style ####
55
55
 
@@ -94,7 +94,7 @@ Note: It used to be that you were able to put Disqus into "development mode", [t
94
94
  %p
95
95
  Now for some comments:
96
96
  #comments
97
- inject_disqus # you'd probably do this at the bottom of a view instead.
97
+ = inject_disqus # you'd probably do this at the bottom of a view instead.
98
98
 
99
99
  ### Version numbering ###
100
100
 
@@ -15,14 +15,19 @@ module Sinatra
15
15
  //<![CDATA[
16
16
  TOP
17
17
 
18
- # The bottom bit of the sandwich we're making.
19
- Disqus_output_bottom = <<BOTTOM
18
+ Disqus_output_function_top = <<FUNCTOP
20
19
  (function() {
21
20
  var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
22
- dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
21
+ FUNCTOP
22
+
23
+ Disqus_output_function_bot = <<FUNCBOT
23
24
  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
24
25
  })();
25
26
  //]]>
27
+ FUNCBOT
28
+
29
+ # The bottom bit of the sandwich we're making.
30
+ Disqus_output_bottom = <<BOTTOM
26
31
  </script>
27
32
  <noscript>
28
33
  Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a>
@@ -57,6 +62,7 @@ BOTTOM
57
62
  var disqus_url = '#{opts[:request_url]}';
58
63
  STR
59
64
  end
65
+
60
66
  end
61
67
 
62
68
 
@@ -65,7 +71,17 @@ STR
65
71
 
66
72
  # @return [String] Returns the bit of HTML/javascript to stick in the page.
67
73
  def inject_disqus
68
- "#{Disqus_output_top}#{Private.build_vars(request_url: uri(request.path_info), disqus_shortname: settings.disqus_shortname, title: @title, disqus_identifier: Private.disqus_identifier(request.path))}#{Disqus_output_bottom}"
74
+ req_url = settings.disqus_host ?
75
+ File.join(settings.disqus_host,request.path_info) :
76
+ request.url
77
+
78
+ options = {
79
+ request_url: req_url,
80
+ disqus_shortname: settings.disqus_shortname,
81
+ title: @title,
82
+ disqus_identifier: Private.disqus_identifier(request.path)
83
+ }
84
+ "#{Disqus_output_top}#{Private.build_vars(options)}#{Disqus_output_function_top} dsq.src = '//#{settings.disqus_shortname}.disqus.com/embed.js';\n#{Disqus_output_function_bot}#{Disqus_output_bottom}"
69
85
  end
70
86
 
71
87
  end
@@ -78,6 +94,11 @@ STR
78
94
  # @param [String] s The short name of the site (e.g. example.org )
79
95
  app.set :disqus_shortname, nil
80
96
 
97
+ # @param [String] s Alternative host to the one in the request. Useful when running on localhost but still want the request to output a domain.
98
+ # @example
99
+ # set :disqus_host, "//example.org"
100
+ app.set :disqus_host, nil
101
+
81
102
  end # registered
82
103
  end
83
104
  register Disqus
@@ -3,6 +3,6 @@
3
3
  module Sinatra
4
4
  module Disqus
5
5
  # This library's version.
6
- VERSION = "2.0.0"
6
+ VERSION = "2.1.0"
7
7
  end
8
8
  end
data/spec/disqus_spec.rb CHANGED
@@ -5,11 +5,12 @@ require "rspec_helper"
5
5
  require_relative "../lib/sinatra/Disqus.rb"
6
6
 
7
7
  describe "Disqus" do
8
- before{ get '/' }
9
- include_context "All pages"
10
- it_should_behave_like "Any route"
11
- context "Output" do
12
- let(:expected) { <<STR
8
+ context "General" do
9
+ before{ get '/' }
10
+ include_context "All pages"
11
+ it_should_behave_like "Any route"
12
+ context "Output" do
13
+ let(:expected) { <<STR
13
14
  <div id='disqus_thread'></div>
14
15
  <script type='text/javascript'>
15
16
  //<![CDATA[
@@ -19,7 +20,7 @@ describe "Disqus" do
19
20
  var disqus_url = 'http://example.org/';
20
21
  (function() {
21
22
  var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
22
- dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
23
+ dsq.src = '//example.org.disqus.com/embed.js';
23
24
  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
24
25
  })();
25
26
  //]]>
@@ -29,8 +30,55 @@ describe "Disqus" do
29
30
  </noscript>
30
31
  <a href="//disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
31
32
  STR
32
- }
33
- subject{ last_response.body }
34
- it { should == expected }
33
+ }
34
+ subject{ last_response.body }
35
+ it { should == expected }
36
+ end
37
+ end
38
+
39
+ context "settings.disqus_host" do
40
+ include Rack::Test::Methods
41
+ def app
42
+ app = Sinatra.new do
43
+ register Sinatra::Disqus
44
+
45
+ configure do
46
+ set :disqus_shortname, "example.org"
47
+ set :disqus_host, "//localhost:4567"
48
+ end
49
+
50
+ get "/" do
51
+ @title = "Home"
52
+ inject_disqus
53
+ end
54
+ end
55
+ end
56
+ before{ get '/' }
57
+ context "Output" do
58
+ let(:expected) { <<STR
59
+ <div id='disqus_thread'></div>
60
+ <script type='text/javascript'>
61
+ //<![CDATA[
62
+ var disqus_title = "Home";
63
+ var disqus_shortname = 'example.org';
64
+ var disqus_identifier = '6666cd76f96956469e7be39d750cc7d9';
65
+ var disqus_url = '//localhost:4567/';
66
+ (function() {
67
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
68
+ dsq.src = '//example.org.disqus.com/embed.js';
69
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
70
+ })();
71
+ //]]>
72
+ </script>
73
+ <noscript>
74
+ Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a>
75
+ </noscript>
76
+ <a href="//disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
77
+ STR
78
+ }
79
+ subject{ last_response.body }
80
+ it { should == expected }
81
+ end
82
+
35
83
  end
36
84
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-disqus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
5
- prerelease:
4
+ version: 2.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Iain Barnett
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-28 00:00:00.000000000 Z
11
+ date: 2016-04-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: sinatra
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  description: Drop in disqus to any Sinatra view via a handy helper.
@@ -49,27 +46,26 @@ files:
49
46
  - spec/support/shared/all_routes.rb
50
47
  homepage: https://bitbucket.org/yb66/sinatra-disqus
51
48
  licenses: []
49
+ metadata: {}
52
50
  post_install_message:
53
51
  rdoc_options: []
54
52
  require_paths:
55
53
  - lib
56
54
  required_ruby_version: !ruby/object:Gem::Requirement
57
- none: false
58
55
  requirements:
59
- - - ! '>='
56
+ - - '>='
60
57
  - !ruby/object:Gem::Version
61
58
  version: '0'
62
59
  required_rubygems_version: !ruby/object:Gem::Requirement
63
- none: false
64
60
  requirements:
65
- - - ! '>='
61
+ - - '>='
66
62
  - !ruby/object:Gem::Version
67
63
  version: '0'
68
64
  requirements: []
69
65
  rubyforge_project:
70
- rubygems_version: 1.8.25
66
+ rubygems_version: 2.0.14
71
67
  signing_key:
72
- specification_version: 3
68
+ specification_version: 4
73
69
  summary: Easy disqus for Sinatra.
74
70
  test_files:
75
71
  - spec/disqus_spec.rb