sinatra-disqus 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,18 +1,33 @@
1
1
  ## CH-CH-CH-CH-CHANGES! ##
2
2
 
3
+ ### Friday the 28th of June 2013, v2.0.0 ###
4
+
5
+ * Disqus has dropped support for developer mode. Updated to reflect this.
6
+ * Updated scripts.
7
+ * 100% coverage for documentation.
8
+
9
+ ----
10
+
11
+
3
12
  ### Saturday the 20th of April 2013, v1.1.0 ###
4
13
 
5
14
  * More updating of docs.
6
15
  * Removed reliance on Haml.
7
16
 
17
+ ----
18
+
19
+
8
20
  ### Saturday the 20th of April 2013, v1.0.0 ###
9
21
 
10
22
  * Updated the docs a bit.
11
23
  * Bumped to v1.0.0 for semver.
12
24
 
25
+ ----
26
+
27
+
13
28
  ### Thursday the 9th of August 2012, v0.0.1 ###
14
29
 
15
30
  * First release.
16
31
  * It has a spec!
17
32
 
18
- ----
33
+ ----
data/README.md CHANGED
@@ -13,17 +13,21 @@ or via Bundler:
13
13
 
14
14
  ### Example ###
15
15
 
16
+ Note: It used to be that you were able to put Disqus into "development mode", [this is no longer valid](http://iainbarnett.me.uk/articles/disqus-developer-mode). Instead, add another site shortname and modify the settings slightly, similar to the examples below.
17
+
16
18
  #### Classic style
17
19
 
18
20
  require 'sinatra'
19
21
  require 'haml'
20
22
  require 'sinatra/disqus'
21
23
 
22
- configure do
24
+ configure :production do
23
25
  # Disqus settings
24
26
  set :disqus_shortname, "example.org"
25
- # Put disqus into developer mode unless in production.
26
- set :disqus_developer, !production?
27
+ end
28
+
29
+ configure :development, :test do
30
+ set :disqus_shortname, "dev-example.org"
27
31
  end
28
32
 
29
33
  get "/" do
@@ -58,11 +62,16 @@ or via Bundler:
58
62
 
59
63
  configure do
60
64
  enable :inline_templates # just for this example
65
+ end
61
66
 
67
+ configure :production do
62
68
  # Disqus settings
63
69
  set :disqus_shortname, "example.org"
64
- # Put disqus into developer mode unless in production.
65
- set :disqus_developer, !production?
70
+ end
71
+
72
+ configure :development do
73
+ # Disqus settings
74
+ set :disqus_shortname, "dev-example.org"
66
75
  end
67
76
 
68
77
  get "/" do
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Sinatra
4
4
  module Disqus
5
- VERSION = "1.1.0"
5
+ # This library's version.
6
+ VERSION = "2.0.0"
6
7
  end
7
8
  end
@@ -2,32 +2,36 @@
2
2
 
3
3
  require 'sinatra/base'
4
4
 
5
+ # @see http://www.sinatrarb.com/
5
6
  module Sinatra
7
+
8
+ # Drop in disqus to any Sinatra view via a handy helper.
6
9
  module Disqus
7
10
 
11
+ # Top part of the javascripts.
8
12
  Disqus_output_top = <<TOP
9
- <div id='disqus_thread'>
10
- <script type='text/javascript'>
11
- //<![CDATA[
13
+ <div id='disqus_thread'></div>
14
+ <script type='text/javascript'>
15
+ //<![CDATA[
12
16
  TOP
17
+
18
+ # The bottom bit of the sandwich we're making.
13
19
  Disqus_output_bottom = <<BOTTOM
14
- (function() {
15
- var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
16
- dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
17
- (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
18
- })();
19
- //]]>
20
- </script>
21
- <noscript>
22
- Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a>
23
- </noscript>
24
- <p>
25
- <a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
26
- </p>
27
- </div>
20
+ (function() {
21
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
22
+ dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
23
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
24
+ })();
25
+ //]]>
26
+ </script>
27
+ <noscript>
28
+ Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a>
29
+ </noscript>
30
+ <a href="//disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
28
31
  BOTTOM
29
32
 
30
33
  # @private
34
+ # Private yet helpful methods.
31
35
  module Private
32
36
  require 'digest/md5'
33
37
 
@@ -40,53 +44,39 @@ BOTTOM
40
44
 
41
45
  # @param [Hash] opts
42
46
  # @option opts [String] :title The page title, usually held in @title
43
- # @option opts [0,1] :disqus_developer The development mode.
44
47
  # @option opts [String] :disqus_shortname The short name of the site (e.g. example.org )
45
48
  # @option opts [String] :disqus_identifier The unique identifier the page the comments sit on.
46
49
  # @option opts [String] :request_url The page's url.
47
50
  # @return [String] The portion of the disqus javascript with the vars.
51
+ # @note The option :disqus_developer is no longer supported by Disqus
48
52
  def self.build_vars( opts )
49
53
  <<STR
50
- var disqus_title = "#{opts[:title].gsub(/'/, "\\\\'")}";
51
- var disqus_developer = #{opts[:disqus_developer]}; // developer mode
52
- var disqus_shortname = '#{opts[:disqus_shortname]}';
53
- var disqus_identifier = '#{opts[:disqus_identifier]}'; // is on if 1
54
- var disqus_url = '#{opts[:request_url]}';
54
+ var disqus_title = "#{opts[:title].gsub(/'/, "\\\\'")}";
55
+ var disqus_shortname = '#{opts[:disqus_shortname]}';
56
+ var disqus_identifier = '#{opts[:disqus_identifier]}';
57
+ var disqus_url = '#{opts[:request_url]}';
55
58
  STR
56
59
  end
57
60
  end
58
61
 
59
62
 
63
+ # Handy helpers.
60
64
  module Helpers
61
65
 
62
66
  # @return [String] Returns the bit of HTML/javascript to stick in the page.
63
67
  def inject_disqus
64
- "#{Disqus_output_top}#{Private.build_vars(request_url: uri(request.path_info), disqus_shortname: settings.disqus_shortname, disqus_developer: settings.disqus_developer, title: @title, disqus_identifier: Private.disqus_identifier(request.path))}#{Disqus_output_bottom}"
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}"
65
69
  end
66
70
 
67
71
  end
68
72
 
69
73
 
74
+ # Sinatra hook for extensions.
70
75
  def self.registered(app)
71
76
  app.helpers Disqus::Helpers
72
-
73
-
77
+
74
78
  # @param [String] s The short name of the site (e.g. example.org )
75
79
  app.set :disqus_shortname, nil
76
-
77
-
78
- # @param [true,false,nil] bool Whether developer mode is on (true), off (false) or set to use the default (nil), which is the current environment (if production then off).
79
- def disqus_developer=(bool)
80
- @disqus_developer = bool
81
- end
82
-
83
- # @return [0,1] 0 is off, 1 is on.
84
- def disqus_developer
85
- if @disqus_developer.nil?
86
- @disqus_developer = ENV['RACK_ENV'] == "production" ? false : true
87
- end
88
- @disqus_developer ? 1 : 0
89
- end
90
80
 
91
81
  end # registered
92
82
  end
data/spec/disqus_spec.rb CHANGED
@@ -10,28 +10,24 @@ describe "Disqus" do
10
10
  it_should_behave_like "Any route"
11
11
  context "Output" do
12
12
  let(:expected) { <<STR
13
- <div id='disqus_thread'>
14
- <script type='text/javascript'>
15
- //<![CDATA[
16
- var disqus_title = "Home";
17
- var disqus_developer = 1; // developer mode
18
- var disqus_shortname = 'example.org';
19
- var disqus_identifier = '6666cd76f96956469e7be39d750cc7d9'; // is on if 1
20
- var disqus_url = 'http://example.org/';
21
- (function() {
22
- var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
23
- dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
24
- (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
25
- })();
26
- //]]>
27
- </script>
28
- <noscript>
29
- Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a>
30
- </noscript>
31
- <p>
32
- <a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
33
- </p>
34
- </div>
13
+ <div id='disqus_thread'></div>
14
+ <script type='text/javascript'>
15
+ //<![CDATA[
16
+ var disqus_title = "Home";
17
+ var disqus_shortname = 'example.org';
18
+ var disqus_identifier = '6666cd76f96956469e7be39d750cc7d9';
19
+ var disqus_url = 'http://example.org/';
20
+ (function() {
21
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
22
+ dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
23
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
24
+ })();
25
+ //]]>
26
+ </script>
27
+ <noscript>
28
+ Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a>
29
+ </noscript>
30
+ <a href="//disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
35
31
  STR
36
32
  }
37
33
  subject{ last_response.body }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-disqus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-20 00:00:00.000000000 Z
12
+ date: 2013-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra