octopress-social 1.0.0 → 1.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +54 -4
- data/lib/octopress-social.rb +7 -3
- data/lib/octopress-social/disqus.rb +67 -0
- data/lib/octopress-social/facebook.rb +9 -5
- data/lib/octopress-social/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ad8a7ece7e30fbc6fce89ea3753d9eaf13355c8
|
4
|
+
data.tar.gz: b4f122dce2d3e6ea8648372350925946a809dcd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 984ee78928c0d0c68bda2eb965364fdc0e27c4b6ba38413ee6cfd3e047cd5dfb27755dac7d0145ddf57b0fc3327d242b4303dd084287c88b9304c0495f5a50ea
|
7
|
+
data.tar.gz: 9f7234ac4585cfbecffc5a8ce6ceb0b8b7125e6b08393a6c28e9a0215c9b3bba222cac7e8a4c2fabd9f83aa7d072a8c995c92849c894b630fbabdd7333214762
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Octopress Social
|
2
2
|
|
3
|
-
Easy social
|
3
|
+
Easy social integrations with Twitter, Facebook, and Google+ with fancy buttons or plain-old links.
|
4
|
+
|
5
|
+
[](https://travis-ci.org/octopress/social)
|
6
|
+
[](https://rubygems.org/gems/octopress-social)
|
7
|
+
[](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
|
-
|
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
|
-
|
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 )
|
data/lib/octopress-social.rb
CHANGED
@@ -5,9 +5,10 @@ module Octopress
|
|
5
5
|
module Social
|
6
6
|
extend self
|
7
7
|
|
8
|
-
autoload :Twitter,
|
9
|
-
autoload :Facebook,
|
10
|
-
autoload :GooglePlus,
|
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
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
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
|
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.
|
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-
|
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
|