octopress-social 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +192 -0
- data/lib/octopress-social.rb +50 -0
- data/lib/octopress-social/facebook.rb +121 -0
- data/lib/octopress-social/google-plus.rb +101 -0
- data/lib/octopress-social/twitter.rb +95 -0
- data/lib/octopress-social/version.rb +5 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f3213c10c4cdb75d78032f8147d4c77f7004d874
|
4
|
+
data.tar.gz: cee00964846941a3c8ee6bd97c5e82dbb7f441f2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4f38f54ce707ce47542466af7721a39103b77f7acb64bff33eae1de977db49450446bdcd393acb58c04d2dc5a317912452657fefe1e53706d4e593bc838b26eb
|
7
|
+
data.tar.gz: 7b6d4b137b4da101fb8740c179dd51bf29dec2211eb6a633e4969ecb20c8fd0de60dc459a71d09fc75ced9877ea105416593538e03a3ed85712ee4425a47fbd6
|
data/README.md
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
# Octopress Social
|
2
|
+
|
3
|
+
Easy social features from Twitter, Facebook, and Google+ with fancy buttons or plain-old links.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
If you're using bundler add this gem to your site's Gemfile in the `:jekyll_plugins` group:
|
8
|
+
|
9
|
+
group :jekyll_plugins do
|
10
|
+
gem 'octopress-social'
|
11
|
+
end
|
12
|
+
|
13
|
+
Then install the gem with Bundler
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
To install manually without bundler:
|
18
|
+
|
19
|
+
$ gem install octopress-social
|
20
|
+
|
21
|
+
Then add the gem to your Jekyll configuration.
|
22
|
+
|
23
|
+
gems:
|
24
|
+
- octopress-social
|
25
|
+
|
26
|
+
## Twitter
|
27
|
+
|
28
|
+
Configure this plugin in your site's `_config.yml`.
|
29
|
+
|
30
|
+
```yaml
|
31
|
+
twitter:
|
32
|
+
username: # Add your Twitter handle
|
33
|
+
tweet_count: false # show number of shares on Twitter
|
34
|
+
size: normal # or large
|
35
|
+
tweet_link_text: Twitter # Configure the link text
|
36
|
+
tweet_message: ":title by :username - :url :hashtags"
|
37
|
+
|
38
|
+
follow_count: false # show number of followers
|
39
|
+
profile_link_text: "Follow :username"
|
40
|
+
```
|
41
|
+
|
42
|
+
To include hashtags, in your tweet message add them in the YAML front matter of your post or page, like this:
|
43
|
+
|
44
|
+
```yaml
|
45
|
+
twitter_hashtag: tech # A single hashtag
|
46
|
+
twitter_hashtags: # Multiple hashtags
|
47
|
+
- tech
|
48
|
+
- kittens
|
49
|
+
```
|
50
|
+
|
51
|
+
If your site has multiple authors, you can configure the author's twitter handle in a
|
52
|
+
post's YAML front-matter and the tweet button (or link) will mention them in the default message.
|
53
|
+
|
54
|
+
```yaml
|
55
|
+
twitter_username: some_author
|
56
|
+
```
|
57
|
+
|
58
|
+
You can also configure a different default message in your post or page's YAML
|
59
|
+
front-matter:
|
60
|
+
|
61
|
+
```
|
62
|
+
tweet_message: "Yay Jekyll :title by :username - :url :hashtags"
|
63
|
+
```
|
64
|
+
|
65
|
+
Note: This plugin sets the twitter button's "do not track" setting to 'true'. I have
|
66
|
+
no intention of making this configurable.
|
67
|
+
|
68
|
+
### Twitter Tags
|
69
|
+
|
70
|
+
To use Twitter's fancy buttons you'll need to add this tag to your site's layout before the closing body tag.
|
71
|
+
|
72
|
+
```
|
73
|
+
{% twitter_script_tag %} # Injects Twitter's widget.js.
|
74
|
+
```
|
75
|
+
|
76
|
+
Sharing tags:
|
77
|
+
```
|
78
|
+
{% tweet_button %}
|
79
|
+
{% tweet_button post %}
|
80
|
+
{% tweet_link %} # tweet with a (no js) link
|
81
|
+
```
|
82
|
+
|
83
|
+
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`. If you want tweet buttons to show up on post index or archive pages, add the `post` argument to the tweet button tag.
|
84
|
+
|
85
|
+
Follow tags:
|
86
|
+
|
87
|
+
```
|
88
|
+
{% twitter_follow_button %}
|
89
|
+
{% twitter_profile_link %}
|
90
|
+
```
|
91
|
+
|
92
|
+
## Facebook
|
93
|
+
|
94
|
+
These configurations are all based on [Facebook's widget configuration spec](https://developers.facebook.com/docs/plugins/), visit that site for more info.
|
95
|
+
|
96
|
+
```yaml
|
97
|
+
facebook:
|
98
|
+
app_id: # For a nicer (no js) sharing experience
|
99
|
+
profile_id: # For follow button or profile link
|
100
|
+
action: like # Or recommend
|
101
|
+
share: false # Also add a share button
|
102
|
+
layout: button # Choices: standard, box_count, button_count, button
|
103
|
+
show_faces: false
|
104
|
+
colorscheme: light # Or dark
|
105
|
+
kid_directed_site: false # Is your site directed at kids under 13?
|
106
|
+
share_link_text: Facebook # Text for plain-old link
|
107
|
+
profile_link_text: "Find me on Facebook"
|
108
|
+
comment_count: 5 # Number of facebook comments to show by default
|
109
|
+
```
|
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
|
+
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
|
114
|
+
'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
|
115
|
+
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
|
116
|
+
your App ID.
|
117
|
+
|
118
|
+
### Facebook Tags
|
119
|
+
|
120
|
+
To use Facebook's scripted features you'll need to add this tag to your site's layout before the closing body tag.
|
121
|
+
|
122
|
+
```
|
123
|
+
{% facebook_script_tag %} # Injects Facebook's widget.js.
|
124
|
+
```
|
125
|
+
|
126
|
+
Sharing tags:
|
127
|
+
|
128
|
+
```
|
129
|
+
{% facebook_like_button %}
|
130
|
+
{% facebook_send_button %} # For private sharing
|
131
|
+
{% facebook_share_link %} # share with a (no js) link
|
132
|
+
```
|
133
|
+
|
134
|
+
Friend and Follow tags:
|
135
|
+
|
136
|
+
```
|
137
|
+
{% facebook_follow_button %} # Requires a public profile
|
138
|
+
{% facebook_profile_link %}
|
139
|
+
```
|
140
|
+
|
141
|
+
Embed Facebook comments widget:
|
142
|
+
|
143
|
+
```
|
144
|
+
{% facebook_comments %}
|
145
|
+
```
|
146
|
+
|
147
|
+
|
148
|
+
## Google+
|
149
|
+
|
150
|
+
These configurations are based on Google's [web sharing widgets](https://developers.google.com/+/web/+1button/).
|
151
|
+
|
152
|
+
```yaml
|
153
|
+
gplus:
|
154
|
+
id: # Your Google+ userid (for follow button or profile link)
|
155
|
+
size: medium # choices: small, medium, standard, large
|
156
|
+
width: # Specify width of button
|
157
|
+
share_count: false # Show number of shares or +1s
|
158
|
+
follow_count: false # Show numer of followers
|
159
|
+
share_link_text: Google+ # Text for plain-old link
|
160
|
+
profile_link_text: "Follow on Google+"
|
161
|
+
```
|
162
|
+
|
163
|
+
### Google+ Tags
|
164
|
+
|
165
|
+
To use Google's fancy buttons, you'll need to add this tag to your site's layout before the closing body tag.
|
166
|
+
|
167
|
+
```
|
168
|
+
{% gplus_script_tag %} # Injects Google's widget.js.
|
169
|
+
```
|
170
|
+
|
171
|
+
Sharing tags:
|
172
|
+
|
173
|
+
```
|
174
|
+
{% gplus_one_button %}
|
175
|
+
{% gplus_share_button %}
|
176
|
+
{% gplus_share_link %} # share with a (no js) link
|
177
|
+
```
|
178
|
+
|
179
|
+
Follow tags:
|
180
|
+
|
181
|
+
```
|
182
|
+
{% gplus_follow_button %}
|
183
|
+
{% gplus_profile_link %}
|
184
|
+
```
|
185
|
+
|
186
|
+
## Contributing
|
187
|
+
|
188
|
+
1. Fork it ( https://github.com/[my-github-username]/octopress-social/fork )
|
189
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
190
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
191
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
192
|
+
5. Create a new Pull Request
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "octopress-social/version"
|
2
|
+
require "liquid"
|
3
|
+
|
4
|
+
module Octopress
|
5
|
+
module Social
|
6
|
+
extend self
|
7
|
+
|
8
|
+
autoload :Twitter, 'octopress-social/twitter'
|
9
|
+
autoload :Facebook, 'octopress-social/facebook'
|
10
|
+
autoload :GooglePlus, 'octopress-social/google-plus'
|
11
|
+
|
12
|
+
def full_url(site, item)
|
13
|
+
unless root = site['url']
|
14
|
+
abort "Site url not configured. Please set url: http://your-site.com in Jekyll configuration file."
|
15
|
+
end
|
16
|
+
|
17
|
+
File.join(root, site['baseurl'], item['url'].sub('index.html', ''))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Liquid::Template.register_tag('tweet_button', Octopress::Social::Twitter::Tag)
|
23
|
+
Liquid::Template.register_tag('tweet_link', Octopress::Social::Twitter::Tag)
|
24
|
+
Liquid::Template.register_tag('twitter_script_tag', Octopress::Social::Twitter::Tag)
|
25
|
+
Liquid::Template.register_tag('twitter_follow_button', Octopress::Social::Twitter::Tag)
|
26
|
+
Liquid::Template.register_tag('twitter_profile_link', Octopress::Social::Twitter::Tag)
|
27
|
+
Liquid::Template.register_tag('gplus_share_button', Octopress::Social::GooglePlus::Tag)
|
28
|
+
Liquid::Template.register_tag('gplus_share_link', Octopress::Social::GooglePlus::Tag)
|
29
|
+
Liquid::Template.register_tag('gplus_one_button', Octopress::Social::GooglePlus::Tag)
|
30
|
+
Liquid::Template.register_tag('gplus_follow_button', Octopress::Social::GooglePlus::Tag)
|
31
|
+
Liquid::Template.register_tag('gplus_profile_link', Octopress::Social::GooglePlus::Tag)
|
32
|
+
Liquid::Template.register_tag('gplus_script_tag', Octopress::Social::GooglePlus::Tag)
|
33
|
+
Liquid::Template.register_tag('facebook_like_button', Octopress::Social::Facebook::Tag)
|
34
|
+
Liquid::Template.register_tag('facebook_share_link', Octopress::Social::Facebook::Tag)
|
35
|
+
Liquid::Template.register_tag('facebook_send_button', Octopress::Social::Facebook::Tag)
|
36
|
+
Liquid::Template.register_tag('facebook_follow_button', Octopress::Social::Facebook::Tag)
|
37
|
+
Liquid::Template.register_tag('facebook_profile_link', Octopress::Social::Facebook::Tag)
|
38
|
+
Liquid::Template.register_tag('facebook_comments', Octopress::Social::Facebook::Tag)
|
39
|
+
Liquid::Template.register_tag('facebook_script_tag', Octopress::Social::Facebook::Tag)
|
40
|
+
|
41
|
+
if defined? Octopress::Docs
|
42
|
+
Octopress::Docs.add({
|
43
|
+
name: "Octopress Social",
|
44
|
+
gem: "octopress-social",
|
45
|
+
version: Octopress::Social::VERSION,
|
46
|
+
description: "Easy social network integration for Jekyll sites.",
|
47
|
+
path: File.expand_path(File.join(File.dirname(__FILE__), "../")),
|
48
|
+
source_url: "https://github.com/octopress/social"
|
49
|
+
})
|
50
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Social
|
3
|
+
module Facebook
|
4
|
+
extend self
|
5
|
+
|
6
|
+
DEFAULTS = {
|
7
|
+
'profile_id' => nil,
|
8
|
+
'app_id' => nil,
|
9
|
+
'layout' => 'button',
|
10
|
+
'action' => 'like',
|
11
|
+
'show_faces' => false,
|
12
|
+
'share' => false,
|
13
|
+
'colorscheme' => 'light',
|
14
|
+
'kid_directed_site' => false,
|
15
|
+
'comment_count' => 5,
|
16
|
+
'share_link_text' => 'Facebook',
|
17
|
+
'profile_link_text' => 'Friend me on Facebook'
|
18
|
+
}
|
19
|
+
|
20
|
+
def config(site=nil)
|
21
|
+
@config ||= DEFAULTS.merge(site['facebook'] || {})
|
22
|
+
end
|
23
|
+
|
24
|
+
def facebook_share_link(site, item)
|
25
|
+
url = Social.full_url(site, item)
|
26
|
+
if config['app_id']
|
27
|
+
%Q{<a class="facebook-share-link" href="https://www.facebook.com/dialog/share?
|
28
|
+
app_id=#{config['app_id']}
|
29
|
+
&href=#{url}&redirect_uri=#{url}"
|
30
|
+
target="_blank">#{config['share_link_text']}</a>
|
31
|
+
}
|
32
|
+
else
|
33
|
+
%Q{<a class="facebook-share-link"
|
34
|
+
href="https://www.facebook.com/sharer/sharer.php?u=#{url}"
|
35
|
+
target="_blank">#{config['share_link_text']}</a>}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def facebook_like_button(site, item)
|
40
|
+
%Q{<div class="fb-like"
|
41
|
+
data-href="#{Social.full_url(site, item)}"
|
42
|
+
#{width}
|
43
|
+
data-layout="#{config['layout']}"
|
44
|
+
data-action="#{config['action']}"
|
45
|
+
data-show-faces="#{config['show_faces']}"
|
46
|
+
data-colorscheme="#{config['colorscheme']}"
|
47
|
+
data-kid-directed-site="#{config['kid_directed_site']}"
|
48
|
+
data-share="#{config['share']}"></div>
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def facebook_profile_link(*args)
|
53
|
+
%Q{<a class="facebook-profile-link" href="https://www.facebook.com/#{config['profile_id']}">#{config['profile_link_text']}</a>}
|
54
|
+
end
|
55
|
+
|
56
|
+
def facebook_follow_button(*args)
|
57
|
+
%Q{<div class="fb-follow"
|
58
|
+
data-href="https://www.facebook.com/#{config['profile_id']}"
|
59
|
+
#{width}
|
60
|
+
data-layout="#{config['layout']}"
|
61
|
+
data-layout="#{config['layout']}"
|
62
|
+
data-action="#{config['action']}"
|
63
|
+
data-colorscheme="#{config['colorscheme']}">
|
64
|
+
</div>}
|
65
|
+
end
|
66
|
+
|
67
|
+
def facebook_send_button(site, item)
|
68
|
+
%Q{<div class="fb-send"
|
69
|
+
data-href="#{Social.full_url(site, item)}"
|
70
|
+
#{width}
|
71
|
+
data-colorscheme="#{config['colorscheme']}"
|
72
|
+
data-kid-directed-site="#{config['kid_directed_site']}"></div>
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
def width
|
77
|
+
if w = config['width']
|
78
|
+
%Q{data-width="#{w}"}
|
79
|
+
else
|
80
|
+
''
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def facebook_script_tag(*args)
|
85
|
+
%Q{
|
86
|
+
<div id="fb-root"></div>
|
87
|
+
<script>(function(d, s, id) {
|
88
|
+
var js, fjs = d.getElementsByTagName(s)[0];
|
89
|
+
if (d.getElementById(id)) return;
|
90
|
+
js = d.createElement(s); js.id = id;
|
91
|
+
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0";
|
92
|
+
fjs.parentNode.insertBefore(js, fjs);
|
93
|
+
}(document, 'script', 'facebook-jssdk'));</script>
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
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>}
|
103
|
+
end
|
104
|
+
|
105
|
+
class Tag < Liquid::Tag
|
106
|
+
def initialize(tag, input, tokens)
|
107
|
+
@tag = tag.strip
|
108
|
+
@input = input.strip
|
109
|
+
end
|
110
|
+
|
111
|
+
def render(context)
|
112
|
+
item = context[@input] || context['page']
|
113
|
+
site = context['site']
|
114
|
+
|
115
|
+
Octopress::Social::Facebook.config(site)
|
116
|
+
Octopress::Social::Facebook.send(@tag, site, item).gsub(/(\s{2,}|\n)/, ' ').strip
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Social
|
3
|
+
module GooglePlus
|
4
|
+
extend self
|
5
|
+
|
6
|
+
DEFAULTS = {
|
7
|
+
'size' => 'medium',
|
8
|
+
'count_bubble' => false,
|
9
|
+
'share_link_text' => 'Google+',
|
10
|
+
'profile_link_text' => 'Follow on Google+',
|
11
|
+
'width' => ''
|
12
|
+
}
|
13
|
+
|
14
|
+
HEIGHT = {
|
15
|
+
'small' => 15,
|
16
|
+
'medium' => 20,
|
17
|
+
'large' => 24
|
18
|
+
}
|
19
|
+
|
20
|
+
def config(site=nil)
|
21
|
+
@config ||= DEFAULTS.merge(site['gplus'] || {})
|
22
|
+
end
|
23
|
+
|
24
|
+
def gplus_share_link(site, item)
|
25
|
+
%Q{<a class="g-plus-share-link" href="https://plus.google.com/share?url=#{Social.full_url(site, item)}" target="_blank">#{config['share_link_text']}</a>}
|
26
|
+
end
|
27
|
+
|
28
|
+
def gplus_one_button(site, item)
|
29
|
+
%Q{<div class="g-plusone" data-href="#{Social.full_url(site, item)}" #{count('share')} #{width} #{size}></div>}
|
30
|
+
end
|
31
|
+
|
32
|
+
def gplus_share_button(site, item)
|
33
|
+
%Q{<div class="g-plus" data-action="share" data-href="#{Social.full_url(site, item)}" #{count('share')} #{width} #{size}></div>}
|
34
|
+
end
|
35
|
+
|
36
|
+
def gplus_follow_button(*args)
|
37
|
+
%Q{<div class="g-follow" #{count('follow')} #{height} data-href="//plus.google.com/u/0/#{config['userid']}" data-rel="author"></div>}
|
38
|
+
end
|
39
|
+
|
40
|
+
def gplus_profile_link(*args)
|
41
|
+
%Q{<a class="g-plus-profile-link" href="//plus.google.com/u/0/#{config['userid']}">#{config['profile_link_text']}</a>}
|
42
|
+
end
|
43
|
+
|
44
|
+
def count(type)
|
45
|
+
if config["#{type}_count"]
|
46
|
+
%Q{data-annotation="bubble"}
|
47
|
+
else
|
48
|
+
%Q{data-annotation="none"}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def width
|
53
|
+
%Q{data-width="#{config['width']}"}
|
54
|
+
end
|
55
|
+
|
56
|
+
def size
|
57
|
+
%Q{data-size="#{config['size']}"}
|
58
|
+
end
|
59
|
+
|
60
|
+
def height
|
61
|
+
%Q{data-height="#{HEIGHT[config['size']]}"}
|
62
|
+
end
|
63
|
+
|
64
|
+
def lang(item)
|
65
|
+
if item['lang']
|
66
|
+
"window.___gcfg = {lang: '#{item['lang']}'};"
|
67
|
+
else
|
68
|
+
''
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def gplus_script_tag(site, item)
|
73
|
+
%Q{
|
74
|
+
<script type="text/javascript">
|
75
|
+
#{Octopress::Social::GooglePlus.lang(item)}
|
76
|
+
(function() {
|
77
|
+
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
|
78
|
+
po.src = 'https://apis.google.com/js/platform.js';
|
79
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
|
80
|
+
})();
|
81
|
+
</script>
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
class Tag < Liquid::Tag
|
86
|
+
def initialize(tag, input, tokens)
|
87
|
+
@tag = tag.strip
|
88
|
+
@input = input.strip
|
89
|
+
end
|
90
|
+
|
91
|
+
def render(context)
|
92
|
+
item = context[@input] || context['page']
|
93
|
+
site = context['site']
|
94
|
+
|
95
|
+
Octopress::Social::GooglePlus.config(site)
|
96
|
+
Octopress::Social::GooglePlus.send(@tag, site, item).gsub(/(\s{2,}|\n)/, ' ').strip
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Social
|
3
|
+
module Twitter
|
4
|
+
extend self
|
5
|
+
|
6
|
+
DEFAULTS = {
|
7
|
+
'tweet_message' => ":title by :username - :url :hashtags",
|
8
|
+
'size' => 'normal',
|
9
|
+
'tweet_count' => false,
|
10
|
+
'follow_count' => false,
|
11
|
+
'tweet_link_text' => "Twitter",
|
12
|
+
'profile_link_text' => "Follow :username"
|
13
|
+
}
|
14
|
+
|
15
|
+
def config(site=nil)
|
16
|
+
@config ||= DEFAULTS.merge(site['twitter'] || {})
|
17
|
+
end
|
18
|
+
|
19
|
+
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>}
|
21
|
+
end
|
22
|
+
|
23
|
+
def tweet_button(site, item)
|
24
|
+
%Q{
|
25
|
+
<a href="https://twitter.com/share" class="twitter-share-button"
|
26
|
+
#{'data-size="large"' if config['size'] == 'large'}
|
27
|
+
#{'data-count="none"' if !config['tweet_count']}
|
28
|
+
#{button_message(site, item)}
|
29
|
+
data-dnt="true">#{config['tweet_link_text']}</a>
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def username(item={})
|
34
|
+
if username = item['twitter_username'] || config['username']
|
35
|
+
"@#{username.sub('@', '')}" # ensure @ mark, but not two.
|
36
|
+
else
|
37
|
+
''
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def hashtags(item)
|
42
|
+
hashtags = Array(item['twitter_hashtag'] || item['twitter_hashtags'])
|
43
|
+
.map{|h| "##{h.sub('#', '')}" } # ensure hash mark, but not two.
|
44
|
+
.join(' ')
|
45
|
+
end
|
46
|
+
|
47
|
+
def message(site, item)
|
48
|
+
(item['tweet_message'] || config['tweet_message'])
|
49
|
+
.sub(':title', item['title'] || '')
|
50
|
+
.sub(':username', username(item))
|
51
|
+
.sub(':url', Social.full_url(site, item))
|
52
|
+
.sub(':hashtags', hashtags(item))
|
53
|
+
.strip
|
54
|
+
end
|
55
|
+
|
56
|
+
def button_message(site, item)
|
57
|
+
%Q{data-text="#{message(site, item)}"}
|
58
|
+
end
|
59
|
+
|
60
|
+
def profile_link_text
|
61
|
+
config['profile_link_text'].sub(':username', username)
|
62
|
+
end
|
63
|
+
|
64
|
+
def twitter_profile_link(*args)
|
65
|
+
%Q{<a href="https://twitter.com/#{username.sub('@', '')}" class="twitter-follow-link">#{profile_link_text}</a>}
|
66
|
+
end
|
67
|
+
|
68
|
+
def twitter_follow_button(*args)
|
69
|
+
%Q{
|
70
|
+
<a href="https://twitter.com/#{username.sub('@', '')}" class="twitter-follow-button"
|
71
|
+
#{'data-show-count="false"' if !config['follow_count']} data-dnt="true">#{profile_link_text}</a>
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
def twitter_script_tag(*args)
|
76
|
+
"<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>"
|
77
|
+
end
|
78
|
+
|
79
|
+
class Tag < Liquid::Tag
|
80
|
+
def initialize(tag, input, tokens)
|
81
|
+
@tag = tag.strip
|
82
|
+
@input = input.strip
|
83
|
+
end
|
84
|
+
|
85
|
+
def render(context)
|
86
|
+
item = context[@input] || context['page']
|
87
|
+
site = context['site']
|
88
|
+
|
89
|
+
Octopress::Social::Twitter.config(site)
|
90
|
+
Octopress::Social::Twitter.send(@tag, site, item).gsub(/(\s{2,}|\n)/, ' ').strip
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: octopress-social
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brandon Mathis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: clash
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: octopress-debugger
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Easy social network integration for Jekyll sites
|
84
|
+
email:
|
85
|
+
- brandon@imathis.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- README.md
|
91
|
+
- lib/octopress-social.rb
|
92
|
+
- lib/octopress-social/facebook.rb
|
93
|
+
- lib/octopress-social/google-plus.rb
|
94
|
+
- lib/octopress-social/twitter.rb
|
95
|
+
- lib/octopress-social/version.rb
|
96
|
+
homepage: http://github.com/octopress/social
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.2.2
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Easy social network integration for Jekyll sites
|
120
|
+
test_files: []
|