octopress-social 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3213c10c4cdb75d78032f8147d4c77f7004d874
4
- data.tar.gz: cee00964846941a3c8ee6bd97c5e82dbb7f441f2
3
+ metadata.gz: 7ad8a7ece7e30fbc6fce89ea3753d9eaf13355c8
4
+ data.tar.gz: b4f122dce2d3e6ea8648372350925946a809dcd2
5
5
  SHA512:
6
- metadata.gz: 4f38f54ce707ce47542466af7721a39103b77f7acb64bff33eae1de977db49450446bdcd393acb58c04d2dc5a317912452657fefe1e53706d4e593bc838b26eb
7
- data.tar.gz: 7b6d4b137b4da101fb8740c179dd51bf29dec2211eb6a633e4969ecb20c8fd0de60dc459a71d09fc75ced9877ea105416593538e03a3ed85712ee4425a47fbd6
6
+ metadata.gz: 984ee78928c0d0c68bda2eb965364fdc0e27c4b6ba38413ee6cfd3e047cd5dfb27755dac7d0145ddf57b0fc3327d242b4303dd084287c88b9304c0495f5a50ea
7
+ data.tar.gz: 9f7234ac4585cfbecffc5a8ce6ceb0b8b7125e6b08393a6c28e9a0215c9b3bba222cac7e8a4c2fabd9f83aa7d072a8c995c92849c894b630fbabdd7333214762
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ### 1.1.0 (2015-03-17)
4
+ - New: Added support Disqus comments.
5
+ - New: Disable Facebook comments on any page or post with `comments: false`.
6
+
7
+ ### 1.0.0 (2015-03-17)
8
+ - Initial release
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Octopress Social
2
2
 
3
- Easy social features from Twitter, Facebook, and Google+ with fancy buttons or plain-old links.
3
+ Easy social integrations with Twitter, Facebook, and Google+ with fancy buttons or plain-old links.
4
+
5
+ [![Build Status](http://img.shields.io/travis/octopress/social.svg)](https://travis-ci.org/octopress/social)
6
+ [![Gem Version](http://img.shields.io/gem/v/octopress-social.svg)](https://rubygems.org/gems/octopress-social)
7
+ [![License](http://img.shields.io/:license-mit-blue.svg)](http://octopress.mit-license.org)
4
8
 
5
9
  ## Installation
6
10
 
@@ -91,7 +95,7 @@ Follow tags:
91
95
 
92
96
  ## Facebook
93
97
 
94
- These configurations are all based on [Facebook's widget configuration spec](https://developers.facebook.com/docs/plugins/), visit that site for more info.
98
+ Configure this plugin in your site's `_config.yml`.
95
99
 
96
100
  ```yaml
97
101
  facebook:
@@ -108,6 +112,8 @@ facebook:
108
112
  comment_count: 5 # Number of facebook comments to show by default
109
113
  ```
110
114
 
115
+ These configurations are all based on [Facebook's widget configuration spec](https://developers.facebook.com/docs/plugins/), visit that site for more info.
116
+
111
117
  To get your `profile_id`, take a section from the url to your profile page `https://www.facebook.com/[profile_id]`.
112
118
 
113
119
  To get an `app_id` you'll need to [register](https://developers.facebook.com/apps) as a developer and go through the process to create an
@@ -144,10 +150,9 @@ Embed Facebook comments widget:
144
150
  {% facebook_comments %}
145
151
  ```
146
152
 
147
-
148
153
  ## Google+
149
154
 
150
- These configurations are based on Google's [web sharing widgets](https://developers.google.com/+/web/+1button/).
155
+ Configure this plugin in your site's `_config.yml`.
151
156
 
152
157
  ```yaml
153
158
  gplus:
@@ -160,6 +165,8 @@ gplus:
160
165
  profile_link_text: "Follow on Google+"
161
166
  ```
162
167
 
168
+ These configurations are based on Google's [web sharing widgets](https://developers.google.com/+/web/+1button/).
169
+
163
170
  ### Google+ Tags
164
171
 
165
172
  To use Google's fancy buttons, you'll need to add this tag to your site's layout before the closing body tag.
@@ -183,6 +190,49 @@ Follow tags:
183
190
  {% gplus_profile_link %}
184
191
  ```
185
192
 
193
+ ## Disqus Comments
194
+
195
+ Configure this plugin in your site's `_config.yml` and optionally on each page or post.
196
+
197
+ ```yaml
198
+ disqus_shortname: # Your site's disqus identifier
199
+ ```
200
+
201
+ In any page or post, you can add these configurations to the YAML front-matter.
202
+
203
+ ```
204
+ disqus_identifier: # Unique identifier for this page's comments (defaults to full url)
205
+ disqus_title: # Custom title for comments metadata (defaults to page/post title)
206
+ comments: false # Disable comments for this page or post
207
+ ```
208
+
209
+ ### Tags
210
+
211
+ These tags will help you integrate Disqus comments into your site.
212
+
213
+ ```
214
+ {% disqus_comments %} # Embed comments on a page
215
+ ```
216
+
217
+ If you want to link directly to the comments section of a post or page, create a link like this:
218
+
219
+ ```
220
+ {% disqus_comments_link %} # link to the comments section on the current page
221
+ {% disqus_comments_link post %} # link to the comments section on a post (in the posts loop)
222
+ ```
223
+
224
+ This will generate a link to the page or post with the on page anchor `#disqus_thread` added, linking you directly to the comments
225
+ section.
226
+
227
+ If you want to show the number of comments in the link, add the following tag to your page layout, somewhere before `</body>`.
228
+
229
+ ```
230
+ {% disqus_count_script %} # Add script for adding counts to comment links
231
+ ```
232
+
233
+ This tag will find all comments links on the current page and add the comment count. You can configure this link text from your the admin panel on Disqus's site.
234
+
235
+
186
236
  ## Contributing
187
237
 
188
238
  1. Fork it ( https://github.com/[my-github-username]/octopress-social/fork )
@@ -5,9 +5,10 @@ module Octopress
5
5
  module Social
6
6
  extend self
7
7
 
8
- autoload :Twitter, 'octopress-social/twitter'
9
- autoload :Facebook, 'octopress-social/facebook'
10
- autoload :GooglePlus, 'octopress-social/google-plus'
8
+ autoload :Twitter, 'octopress-social/twitter'
9
+ autoload :Facebook, 'octopress-social/facebook'
10
+ autoload :GooglePlus, 'octopress-social/google-plus'
11
+ autoload :Disqus, 'octopress-social/disqus'
11
12
 
12
13
  def full_url(site, item)
13
14
  unless root = site['url']
@@ -37,6 +38,9 @@ Liquid::Template.register_tag('facebook_follow_button', Octopress::Social::Faceb
37
38
  Liquid::Template.register_tag('facebook_profile_link', Octopress::Social::Facebook::Tag)
38
39
  Liquid::Template.register_tag('facebook_comments', Octopress::Social::Facebook::Tag)
39
40
  Liquid::Template.register_tag('facebook_script_tag', Octopress::Social::Facebook::Tag)
41
+ Liquid::Template.register_tag('disqus_comments', Octopress::Social::Disqus::Tag)
42
+ Liquid::Template.register_tag('disqus_count_script', Octopress::Social::Disqus::Tag)
43
+ Liquid::Template.register_tag('disqus_comments_link', Octopress::Social::Disqus::Tag)
40
44
 
41
45
  if defined? Octopress::Docs
42
46
  Octopress::Docs.add({
@@ -0,0 +1,67 @@
1
+ module Octopress
2
+ module Social
3
+ module Disqus
4
+ extend self
5
+
6
+ def config(site=nil)
7
+ @config ||= site['disqus_shortname']
8
+ end
9
+
10
+ def url(site, item)
11
+ Social.full_url(site, item)
12
+ end
13
+
14
+ def identifier(site, item)
15
+ item['disqus_identifier'] || url(site, item)
16
+ end
17
+
18
+ def disqus_comments(site, item)
19
+ %Q{<div id="disqus_thread"></div>
20
+ <script type="text/javascript">
21
+ var disqus_shortname = '#{config}';
22
+ var disqus_url = '#{url(site, item)}';
23
+ var disqus_identifier = '#{identifier(site, item)}';
24
+ var disqus_title = '#{item['title']}';
25
+ #{embed_script('embed')}
26
+ </script>
27
+ <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
28
+ }
29
+ end
30
+
31
+ def disqus_count_script(site, item)
32
+ %Q{<script type="text/javascript">
33
+ var disqus_shortname = '#{config}';
34
+ #{embed_script('count')}
35
+ </script>
36
+ }
37
+ end
38
+
39
+ def embed_script(script)
40
+ %Q{(function () {
41
+ var s = document.createElement('script'); s.async = true;
42
+ s.type = 'text/javascript';
43
+ s.src = '//#{config}.disqus.com/#{script}.js';
44
+ (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
45
+ }());
46
+ }
47
+ end
48
+
49
+ class Tag < Liquid::Tag
50
+ def initialize(tag, input, tokens)
51
+ @tag = tag.strip
52
+ @input = input.strip
53
+ end
54
+
55
+ def render(context)
56
+ item = context[@input] || context['page']
57
+ site = context['site']
58
+
59
+ config = Octopress::Social::Disqus.config(site)
60
+ if config && item['comments'] != false
61
+ Octopress::Social::Disqus.send(@tag, site, item).gsub(/(\s{2,}|\n)/, ' ').strip
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -95,11 +95,15 @@ module Octopress
95
95
  end
96
96
 
97
97
  def facebook_comments(site, item)
98
- %Q{<div class="fb-comments"
99
- data-href="#{Social.full_url(site, item)}"
100
- data-numposts="#{config['comment_count']}"
101
- data-colorscheme="#{config['colorscheme']}"
102
- ></div>}
98
+ if item['comments'] != false
99
+ %Q{<div class="fb-comments"
100
+ data-href="#{Social.full_url(site, item)}"
101
+ data-numposts="#{config['comment_count']}"
102
+ data-colorscheme="#{config['colorscheme']}"
103
+ ></div>}
104
+ else
105
+ ''
106
+ end
103
107
  end
104
108
 
105
109
  class Tag < Liquid::Tag
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Social
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-social
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-17 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -87,8 +87,10 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - CHANGELOG.md
90
91
  - README.md
91
92
  - lib/octopress-social.rb
93
+ - lib/octopress-social/disqus.rb
92
94
  - lib/octopress-social/facebook.rb
93
95
  - lib/octopress-social/google-plus.rb
94
96
  - lib/octopress-social/twitter.rb