octopress-social 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +41 -32
- data/lib/octopress-social/disqus.rb +44 -30
- data/lib/octopress-social/facebook.rb +29 -9
- data/lib/octopress-social/google-plus.rb +1 -1
- data/lib/octopress-social/twitter.rb +15 -8
- data/lib/octopress-social/version.rb +1 -1
- data/lib/octopress-social.rb +14 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc69b51e6a1d4ccc410094fede2aee2d4d6af2a7
|
4
|
+
data.tar.gz: 909c4cb057c933360f3e35781217685f8e976b66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6715d8246cc3b68020c5b9697625515a112317d71d0ff74826996596884778286b7c4b0d61f8e2c6593ff86caf876584841370333793ae4b09153d6d68886a06
|
7
|
+
data.tar.gz: 59df88675057d14007087997e82dcfeccd22530a94559a26c58f6a65b5a2bab41a070812ade795c91d357ad5d9a16c0df3f3d4f99f266afd69da68c1694d3f8a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 1.2.0 (2015-03-18)
|
4
|
+
- New: Added Disqus comments link tag.
|
5
|
+
- New: Facebook comments link tag.
|
6
|
+
- New: Tags auto-detect context (sharing a post or the current page).
|
7
|
+
- Fixed: Hashtags are added on tweet link.
|
8
|
+
|
3
9
|
### 1.1.0 (2015-03-17)
|
4
10
|
- New: Added support Disqus comments.
|
5
11
|
- New: Disable Facebook comments on any page or post with `comments: false`.
|
data/README.md
CHANGED
@@ -27,19 +27,28 @@ Then add the gem to your Jekyll configuration.
|
|
27
27
|
gems:
|
28
28
|
- octopress-social
|
29
29
|
|
30
|
+
## Basics
|
31
|
+
|
32
|
+
To integrate these social services, you'll need to add some minimal configurations;
|
33
|
+
usually just a username or user id.
|
34
|
+
|
35
|
+
All tags respond to context. For example, in a post loop, `{% tweet_button %}` will
|
36
|
+
automatically point to the current post. Used outside of a post loop, tags will refer to the current page.
|
37
|
+
|
30
38
|
## Twitter
|
31
39
|
|
32
|
-
Configure this plugin in your site's `_config.yml`.
|
40
|
+
Configure this plugin in your site's `_config.yml`. You really only need to configure
|
41
|
+
`username`, but these are the defaults
|
33
42
|
|
34
43
|
```yaml
|
35
44
|
twitter:
|
36
45
|
username: # Add your Twitter handle
|
37
|
-
tweet_count: false #
|
38
|
-
size: normal #
|
46
|
+
tweet_count: false # Show number of shares on Twitter
|
47
|
+
size: normal # Or large
|
39
48
|
tweet_link_text: Twitter # Configure the link text
|
40
|
-
tweet_message: ":title by :username - :url
|
49
|
+
tweet_message: ":title by :username :hashtags - :url" # With Tweet button Twitter add the URL last
|
41
50
|
|
42
|
-
follow_count: false #
|
51
|
+
follow_count: false # Show number of followers
|
43
52
|
profile_link_text: "Follow :username"
|
44
53
|
```
|
45
54
|
|
@@ -80,11 +89,10 @@ To use Twitter's fancy buttons you'll need to add this tag to your site's layout
|
|
80
89
|
Sharing tags:
|
81
90
|
```
|
82
91
|
{% tweet_button %}
|
83
|
-
{%
|
84
|
-
{% tweet_link %} # tweet with a (no js) link
|
92
|
+
{% tweet_link %} # Tweet with a (no js) link
|
85
93
|
```
|
86
94
|
|
87
|
-
The tweet button and tweet link will open a new page with a composed tweet in the format in your Twitter configuration, `:title by :username - :url :hashtags`.
|
95
|
+
The tweet button and tweet link will open a new page with a composed tweet in the format in your Twitter configuration, `:title by :username - :url :hashtags`.
|
88
96
|
|
89
97
|
Follow tags:
|
90
98
|
|
@@ -97,6 +105,13 @@ Follow tags:
|
|
97
105
|
|
98
106
|
Configure this plugin in your site's `_config.yml`.
|
99
107
|
|
108
|
+
You don't need to configure anything to start using this plugin but if you want to
|
109
|
+
use the follow button or profile link, you'll need to add your `profile_id`.
|
110
|
+
|
111
|
+
To get your `profile_id`, take a section from the url to your profile page `https://www.facebook.com/[profile_id]`.
|
112
|
+
|
113
|
+
Here are the defaults:
|
114
|
+
|
100
115
|
```yaml
|
101
116
|
facebook:
|
102
117
|
app_id: # For a nicer (no js) sharing experience
|
@@ -107,16 +122,22 @@ facebook:
|
|
107
122
|
show_faces: false
|
108
123
|
colorscheme: light # Or dark
|
109
124
|
kid_directed_site: false # Is your site directed at kids under 13?
|
125
|
+
|
110
126
|
share_link_text: Facebook # Text for plain-old link
|
111
127
|
profile_link_text: "Find me on Facebook"
|
128
|
+
|
112
129
|
comment_count: 5 # Number of facebook comments to show by default
|
130
|
+
comments_link_text: Comments
|
131
|
+
disabled_comments_text: Comments disabled # Set to '' to output nothing when comments are disabled
|
113
132
|
```
|
114
133
|
|
115
134
|
These configurations are all based on [Facebook's widget configuration spec](https://developers.facebook.com/docs/plugins/), visit that site for more info.
|
116
135
|
|
117
|
-
To get your `profile_id`, take a section from the url to your profile page `https://www.facebook.com/[profile_id]`.
|
118
136
|
|
119
|
-
|
137
|
+
### Facebook APP ID
|
138
|
+
|
139
|
+
If you want to use the fancy share link (lets you set default content for the share),
|
140
|
+
you'll need to get an `app_id`. For that you'll have to [register](https://developers.facebook.com/apps) as a developer and go through the process to create an
|
120
141
|
'app'. This is free and it doesn't mean you're developing software or anything, it's just how Facebook wants to do this. Once you've
|
121
142
|
created an app, go to the "Basic settings page" by clicking settings, and then finding the "Basic" link. There you should be able to find
|
122
143
|
your App ID.
|
@@ -148,6 +169,7 @@ Embed Facebook comments widget:
|
|
148
169
|
|
149
170
|
```
|
150
171
|
{% facebook_comments %}
|
172
|
+
{% facebook_comments_link %} # Add a link that jumps right to your comments section.
|
151
173
|
```
|
152
174
|
|
153
175
|
## Google+
|
@@ -180,7 +202,7 @@ Sharing tags:
|
|
180
202
|
```
|
181
203
|
{% gplus_one_button %}
|
182
204
|
{% gplus_share_button %}
|
183
|
-
{% gplus_share_link %} #
|
205
|
+
{% gplus_share_link %} # Share with a (no js) link
|
184
206
|
```
|
185
207
|
|
186
208
|
Follow tags:
|
@@ -195,7 +217,10 @@ Follow tags:
|
|
195
217
|
Configure this plugin in your site's `_config.yml` and optionally on each page or post.
|
196
218
|
|
197
219
|
```yaml
|
198
|
-
|
220
|
+
disqus:
|
221
|
+
shortname: # Your site's disqus identifier
|
222
|
+
comments_link_text: Comments # Text label for comments link
|
223
|
+
comments_disabled_link_text: Comments disabled # Set to '' to not output a comments link when disabled
|
199
224
|
```
|
200
225
|
|
201
226
|
In any page or post, you can add these configurations to the YAML front-matter.
|
@@ -206,32 +231,16 @@ disqus_title: # Custom title for comments metadata (defaults to page/po
|
|
206
231
|
comments: false # Disable comments for this page or post
|
207
232
|
```
|
208
233
|
|
209
|
-
### Tags
|
234
|
+
### Disqus Tags
|
210
235
|
|
211
236
|
These tags will help you integrate Disqus comments into your site.
|
212
237
|
|
213
238
|
```
|
214
|
-
{% disqus_comments %}
|
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)
|
239
|
+
{% disqus_comments %} # Embed comments on a page
|
240
|
+
{% disqus_comments_link %} # Add a link that jumps right to your comments section.
|
222
241
|
```
|
223
242
|
|
224
|
-
|
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
|
-
|
243
|
+
Disqus has a script that lets you add comment count to the link, but it's so buggy, I'm not including it because I don't want to deal with the support. You can still add it to your site manually.
|
235
244
|
|
236
245
|
## Contributing
|
237
246
|
|
@@ -3,49 +3,64 @@ module Octopress
|
|
3
3
|
module Disqus
|
4
4
|
extend self
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
attr_accessor :url, :config
|
7
|
+
|
8
|
+
DEFAULTS = {
|
9
|
+
'comments_link_text' => 'Comments',
|
10
|
+
'disabled_comments_text' => 'Comments disabled'
|
11
|
+
}
|
12
|
+
|
13
|
+
def set_config(site)
|
14
|
+
@config ||= DEFAULTS.merge(site['disqus'] || {})
|
8
15
|
end
|
9
16
|
|
10
|
-
def
|
11
|
-
Social.full_url(site, item)
|
17
|
+
def set_url(site, item)
|
18
|
+
@url = Social.full_url(site, item)
|
12
19
|
end
|
13
20
|
|
14
21
|
def identifier(site, item)
|
15
|
-
item['disqus_identifier'] || url
|
22
|
+
item['disqus_identifier'] || url
|
16
23
|
end
|
17
24
|
|
18
25
|
def disqus_comments(site, item)
|
19
|
-
|
20
|
-
<
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
var disqus_shortname = '#{config}';
|
34
|
-
#{embed_script('count')}
|
35
|
-
</script>
|
36
|
-
}
|
26
|
+
if item['comments'] != false
|
27
|
+
%Q{<div id="disqus_thread"></div>
|
28
|
+
<script type="text/javascript">
|
29
|
+
var disqus_shortname = '#{config['shortname']}';
|
30
|
+
var disqus_url = '#{url}';
|
31
|
+
var disqus_identifier = '#{identifier(site, item)}';
|
32
|
+
var disqus_title = '#{item['title']}';
|
33
|
+
#{embed_script('embed')}
|
34
|
+
</script>
|
35
|
+
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
|
36
|
+
}
|
37
|
+
else
|
38
|
+
''
|
39
|
+
end
|
37
40
|
end
|
38
41
|
|
39
42
|
def embed_script(script)
|
40
43
|
%Q{(function () {
|
41
44
|
var s = document.createElement('script'); s.async = true;
|
42
45
|
s.type = 'text/javascript';
|
43
|
-
s.src = '//#{config}.disqus.com/#{script}.js';
|
46
|
+
s.src = '//#{config['shortname']}.disqus.com/#{script}.js';
|
44
47
|
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
|
45
48
|
}());
|
46
49
|
}
|
47
50
|
end
|
48
51
|
|
52
|
+
def disqus_comments_link(site, item)
|
53
|
+
if item['comments'] != false
|
54
|
+
link = (item['context'] == 'page' ? '' : url)
|
55
|
+
link << '#disqus_thread'
|
56
|
+
%Q{<a class="disqus-comments-link" href="#{link}">Comments</a>}
|
57
|
+
elsif !config['disabled_comments_text'].empty?
|
58
|
+
%Q{<span class="disqus-comments-disabled">#{config['disabled_comments_text']}</span>}
|
59
|
+
else
|
60
|
+
''
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
49
64
|
class Tag < Liquid::Tag
|
50
65
|
def initialize(tag, input, tokens)
|
51
66
|
@tag = tag.strip
|
@@ -53,13 +68,12 @@ module Octopress
|
|
53
68
|
end
|
54
69
|
|
55
70
|
def render(context)
|
56
|
-
|
57
|
-
|
71
|
+
site = context['site']
|
72
|
+
item = Octopress::Social.item(context, @input)
|
58
73
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
74
|
+
Octopress::Social::Disqus.set_config(site)
|
75
|
+
Octopress::Social::Disqus.set_url(site, item)
|
76
|
+
Octopress::Social::Disqus.send(@tag, site, item).gsub(/(\s{2,}|\n)/, ' ').strip
|
63
77
|
end
|
64
78
|
end
|
65
79
|
end
|
@@ -3,6 +3,8 @@ module Octopress
|
|
3
3
|
module Facebook
|
4
4
|
extend self
|
5
5
|
|
6
|
+
attr_accessor :url, :config
|
7
|
+
|
6
8
|
DEFAULTS = {
|
7
9
|
'profile_id' => nil,
|
8
10
|
'app_id' => nil,
|
@@ -14,15 +16,20 @@ module Octopress
|
|
14
16
|
'kid_directed_site' => false,
|
15
17
|
'comment_count' => 5,
|
16
18
|
'share_link_text' => 'Facebook',
|
17
|
-
'profile_link_text' => 'Friend me on Facebook'
|
19
|
+
'profile_link_text' => 'Friend me on Facebook',
|
20
|
+
'comments_link_text' => 'Comments',
|
21
|
+
'disabled_comments_text' => 'Comments disabled'
|
18
22
|
}
|
19
23
|
|
20
|
-
def
|
24
|
+
def set_config(site)
|
21
25
|
@config ||= DEFAULTS.merge(site['facebook'] || {})
|
22
26
|
end
|
23
27
|
|
28
|
+
def set_url(site, item)
|
29
|
+
@url = Social.full_url(site, item)
|
30
|
+
end
|
31
|
+
|
24
32
|
def facebook_share_link(site, item)
|
25
|
-
url = Social.full_url(site, item)
|
26
33
|
if config['app_id']
|
27
34
|
%Q{<a class="facebook-share-link" href="https://www.facebook.com/dialog/share?
|
28
35
|
app_id=#{config['app_id']}
|
@@ -38,7 +45,7 @@ module Octopress
|
|
38
45
|
|
39
46
|
def facebook_like_button(site, item)
|
40
47
|
%Q{<div class="fb-like"
|
41
|
-
data-href="#{
|
48
|
+
data-href="#{url}"
|
42
49
|
#{width}
|
43
50
|
data-layout="#{config['layout']}"
|
44
51
|
data-action="#{config['action']}"
|
@@ -66,7 +73,7 @@ module Octopress
|
|
66
73
|
|
67
74
|
def facebook_send_button(site, item)
|
68
75
|
%Q{<div class="fb-send"
|
69
|
-
data-href="#{
|
76
|
+
data-href="#{url}"
|
70
77
|
#{width}
|
71
78
|
data-colorscheme="#{config['colorscheme']}"
|
72
79
|
data-kid-directed-site="#{config['kid_directed_site']}"></div>
|
@@ -96,8 +103,8 @@ module Octopress
|
|
96
103
|
|
97
104
|
def facebook_comments(site, item)
|
98
105
|
if item['comments'] != false
|
99
|
-
%Q{<div class="fb-comments"
|
100
|
-
data-href="#{
|
106
|
+
%Q{<div class="fb-comments" id="facebook_comments"
|
107
|
+
data-href="#{url}"
|
101
108
|
data-numposts="#{config['comment_count']}"
|
102
109
|
data-colorscheme="#{config['colorscheme']}"
|
103
110
|
></div>}
|
@@ -106,6 +113,18 @@ module Octopress
|
|
106
113
|
end
|
107
114
|
end
|
108
115
|
|
116
|
+
def facebook_comments_link(site, item)
|
117
|
+
if item['comments'] != false
|
118
|
+
link = (item['context'] == 'page' ? '' : url)
|
119
|
+
link << '#facebook_comments'
|
120
|
+
%Q{<a class="facebook-comments-link" href="#{link}">Comments</a>}
|
121
|
+
elsif !config['disabled_comments_text'].empty?
|
122
|
+
%Q{<span class="facebook-comments-disabled">#{config['disabled_comments_text']}</span>}
|
123
|
+
else
|
124
|
+
''
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
109
128
|
class Tag < Liquid::Tag
|
110
129
|
def initialize(tag, input, tokens)
|
111
130
|
@tag = tag.strip
|
@@ -113,10 +132,11 @@ module Octopress
|
|
113
132
|
end
|
114
133
|
|
115
134
|
def render(context)
|
116
|
-
item = context
|
135
|
+
item = Octopress::Social.item(context, @input)
|
117
136
|
site = context['site']
|
118
137
|
|
119
|
-
Octopress::Social::Facebook.
|
138
|
+
Octopress::Social::Facebook.set_url(site, item)
|
139
|
+
Octopress::Social::Facebook.set_config(site)
|
120
140
|
Octopress::Social::Facebook.send(@tag, site, item).gsub(/(\s{2,}|\n)/, ' ').strip
|
121
141
|
end
|
122
142
|
end
|
@@ -3,8 +3,10 @@ module Octopress
|
|
3
3
|
module Twitter
|
4
4
|
extend self
|
5
5
|
|
6
|
+
attr_accessor :url, :config
|
7
|
+
|
6
8
|
DEFAULTS = {
|
7
|
-
'tweet_message' => ":title by :username - :url
|
9
|
+
'tweet_message' => ":title by :username :hashtags - :url",
|
8
10
|
'size' => 'normal',
|
9
11
|
'tweet_count' => false,
|
10
12
|
'follow_count' => false,
|
@@ -12,12 +14,16 @@ module Octopress
|
|
12
14
|
'profile_link_text' => "Follow :username"
|
13
15
|
}
|
14
16
|
|
15
|
-
def
|
16
|
-
@config
|
17
|
+
def set_config(site)
|
18
|
+
@config = DEFAULTS.merge(site['twitter'] || {})
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_url(site, item)
|
22
|
+
@url = Social.full_url(site, item)
|
17
23
|
end
|
18
24
|
|
19
25
|
def tweet_link(site, item)
|
20
|
-
%Q{<a class="twitter-share-link" href="https://twitter.com/intent/tweet?&text=#{message(site, item).strip}" target="_blank">#{config['tweet_link_text']}</a>}
|
26
|
+
%Q{<a class="twitter-share-link" href="https://twitter.com/intent/tweet?&text=#{message(site, item).strip.gsub('#', '%23')}" target="_blank">#{config['tweet_link_text']}</a>}
|
21
27
|
end
|
22
28
|
|
23
29
|
def tweet_button(site, item)
|
@@ -25,7 +31,7 @@ module Octopress
|
|
25
31
|
<a href="https://twitter.com/share" class="twitter-share-button"
|
26
32
|
#{'data-size="large"' if config['size'] == 'large'}
|
27
33
|
#{'data-count="none"' if !config['tweet_count']}
|
28
|
-
#{button_message(site, item)}
|
34
|
+
#{button_message(site, item).sub(/\s?#{url}/, '')}
|
29
35
|
data-dnt="true">#{config['tweet_link_text']}</a>
|
30
36
|
}
|
31
37
|
end
|
@@ -48,7 +54,7 @@ module Octopress
|
|
48
54
|
(item['tweet_message'] || config['tweet_message'])
|
49
55
|
.sub(':title', item['title'] || '')
|
50
56
|
.sub(':username', username(item))
|
51
|
-
.sub(':url',
|
57
|
+
.sub(':url', url)
|
52
58
|
.sub(':hashtags', hashtags(item))
|
53
59
|
.strip
|
54
60
|
end
|
@@ -83,10 +89,11 @@ module Octopress
|
|
83
89
|
end
|
84
90
|
|
85
91
|
def render(context)
|
86
|
-
item = context
|
92
|
+
item = Octopress::Social.item(context, @input)
|
87
93
|
site = context['site']
|
88
94
|
|
89
|
-
Octopress::Social::Twitter.
|
95
|
+
Octopress::Social::Twitter.set_config(site)
|
96
|
+
Octopress::Social::Twitter.set_url(site, item)
|
90
97
|
Octopress::Social::Twitter.send(@tag, site, item).gsub(/(\s{2,}|\n)/, ' ').strip
|
91
98
|
end
|
92
99
|
end
|
data/lib/octopress-social.rb
CHANGED
@@ -17,6 +17,19 @@ module Octopress
|
|
17
17
|
|
18
18
|
File.join(root, site['baseurl'], item['url'].sub('index.html', ''))
|
19
19
|
end
|
20
|
+
|
21
|
+
def item(context, input)
|
22
|
+
if item = context[input]
|
23
|
+
item['context'] = input
|
24
|
+
elsif item = context['post']
|
25
|
+
item['context'] = 'post'
|
26
|
+
else
|
27
|
+
item = context['page']
|
28
|
+
item['context'] = 'page'
|
29
|
+
end
|
30
|
+
|
31
|
+
item
|
32
|
+
end
|
20
33
|
end
|
21
34
|
end
|
22
35
|
|
@@ -37,9 +50,9 @@ Liquid::Template.register_tag('facebook_send_button', Octopress::Social::Faceboo
|
|
37
50
|
Liquid::Template.register_tag('facebook_follow_button', Octopress::Social::Facebook::Tag)
|
38
51
|
Liquid::Template.register_tag('facebook_profile_link', Octopress::Social::Facebook::Tag)
|
39
52
|
Liquid::Template.register_tag('facebook_comments', Octopress::Social::Facebook::Tag)
|
53
|
+
Liquid::Template.register_tag('facebook_comments_link', Octopress::Social::Facebook::Tag)
|
40
54
|
Liquid::Template.register_tag('facebook_script_tag', Octopress::Social::Facebook::Tag)
|
41
55
|
Liquid::Template.register_tag('disqus_comments', Octopress::Social::Disqus::Tag)
|
42
|
-
Liquid::Template.register_tag('disqus_count_script', Octopress::Social::Disqus::Tag)
|
43
56
|
Liquid::Template.register_tag('disqus_comments_link', Octopress::Social::Disqus::Tag)
|
44
57
|
|
45
58
|
if defined? Octopress::Docs
|