octopress-social 1.2.0 → 1.3.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 +5 -0
- data/README.md +18 -0
- data/lib/octopress-social/twitter.rb +32 -4
- data/lib/octopress-social/version.rb +1 -1
- data/lib/octopress-social.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 897b85017a8b777f4c2e525da305201fed073713
|
4
|
+
data.tar.gz: 125b92d5eee580aaf1aa6c901ae68c5c814a4bfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23ef92ea65bdfd4c49e1663ffc36c0c5c4326dc6917a9d225f249163a1981b6b29efc424efb9d83f0b0c2c0580d712d9473033ec11f896b4fc5a8c9e63b7440a
|
7
|
+
data.tar.gz: c36bd80d6775eb098d9f155d09d501217b3f034f3d0395beb47f70495ad17a57f1ab2474d5d6bb4d7e8bb4dbccca39ec3fd1dd1f8ec21943c66c78c4eb891999
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 1.3.0 (2015-03-21)
|
4
|
+
- New: Embeddable tweets with {% tweet %} tag.
|
5
|
+
- Fixed: Default tweet message (without configured username) removes 'by' credit.
|
6
|
+
- Fixed: Tweets in post loops shared current page instead of post.
|
7
|
+
|
3
8
|
### 1.2.0 (2015-03-18)
|
4
9
|
- New: Added Disqus comments link tag.
|
5
10
|
- New: Facebook comments link tag.
|
data/README.md
CHANGED
@@ -47,6 +47,7 @@ twitter:
|
|
47
47
|
size: normal # Or large
|
48
48
|
tweet_link_text: Twitter # Configure the link text
|
49
49
|
tweet_message: ":title by :username :hashtags - :url" # With Tweet button Twitter add the URL last
|
50
|
+
embedded_link_color: # Set link color for embedded tweets
|
50
51
|
|
51
52
|
follow_count: false # Show number of followers
|
52
53
|
profile_link_text: "Follow :username"
|
@@ -101,6 +102,23 @@ Follow tags:
|
|
101
102
|
{% twitter_profile_link %}
|
102
103
|
```
|
103
104
|
|
105
|
+
Embed a tweet:
|
106
|
+
|
107
|
+
```
|
108
|
+
{% tweet status_url %}Tweet Text{% endtweet %}
|
109
|
+
```
|
110
|
+
|
111
|
+
This will generate a blockquote, much like this one:
|
112
|
+
|
113
|
+
```
|
114
|
+
<blockquote class="twitter-tweet" data-link-color="" lang="">
|
115
|
+
<p>[Tweet Text]</p>
|
116
|
+
<a href="[tweet_url]"> — @[user]</a>
|
117
|
+
</blockquote>
|
118
|
+
```
|
119
|
+
|
120
|
+
If you include the twitter widget.js in your site, this will automatically be replaced with one of Twitter's fancy embedded tweets.
|
121
|
+
|
104
122
|
## Facebook
|
105
123
|
|
106
124
|
Configure this plugin in your site's `_config.yml`.
|
@@ -31,7 +31,8 @@ module Octopress
|
|
31
31
|
<a href="https://twitter.com/share" class="twitter-share-button"
|
32
32
|
#{'data-size="large"' if config['size'] == 'large'}
|
33
33
|
#{'data-count="none"' if !config['tweet_count']}
|
34
|
-
#{
|
34
|
+
data-url="#{url}"
|
35
|
+
#{button_message(site, item)}
|
35
36
|
data-dnt="true">#{config['tweet_link_text']}</a>
|
36
37
|
}
|
37
38
|
end
|
@@ -51,16 +52,17 @@ module Octopress
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def message(site, item)
|
55
|
+
username_var = (username(item).empty? ? 'by :username' : ':username')
|
54
56
|
(item['tweet_message'] || config['tweet_message'])
|
55
57
|
.sub(':title', item['title'] || '')
|
56
|
-
.sub(
|
58
|
+
.sub(username_var, username(item))
|
57
59
|
.sub(':url', url)
|
58
60
|
.sub(':hashtags', hashtags(item))
|
59
61
|
.strip
|
60
62
|
end
|
61
63
|
|
62
64
|
def button_message(site, item)
|
63
|
-
%Q{data-text="#{message(site, item)}"}
|
65
|
+
%Q{data-text="#{message(site, item).sub(/\s?#{url}/, '')}"}
|
64
66
|
end
|
65
67
|
|
66
68
|
def profile_link_text
|
@@ -82,6 +84,32 @@ module Octopress
|
|
82
84
|
"<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>"
|
83
85
|
end
|
84
86
|
|
87
|
+
def tweet(site, item, url, content)
|
88
|
+
user = "@#{url.match(/.com\/(.+)?\/status/)[1]}"
|
89
|
+
%Q{<blockquote class="twitter-tweet"
|
90
|
+
data-link-color="#{config['embedded_link_color']}"
|
91
|
+
lang="#{item['lang'] || site['lang']}">
|
92
|
+
<p>#{content}</p>
|
93
|
+
<a href="#{url}"> — #{user}</a>
|
94
|
+
</blockquote>
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
98
|
+
class Tweet < Liquid::Block
|
99
|
+
def initialize(tag, input, tokens)
|
100
|
+
super
|
101
|
+
@tag = tag.strip
|
102
|
+
@input = input.strip
|
103
|
+
end
|
104
|
+
|
105
|
+
def render(context)
|
106
|
+
content = super(context)
|
107
|
+
site = context['site']
|
108
|
+
item = context['page']
|
109
|
+
Octopress::Social::Twitter.tweet(site, item, @input, content).gsub(/(\s{2,}|\n)/, ' ').strip
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
85
113
|
class Tag < Liquid::Tag
|
86
114
|
def initialize(tag, input, tokens)
|
87
115
|
@tag = tag.strip
|
@@ -89,8 +117,8 @@ module Octopress
|
|
89
117
|
end
|
90
118
|
|
91
119
|
def render(context)
|
92
|
-
item = Octopress::Social.item(context, @input)
|
93
120
|
site = context['site']
|
121
|
+
item = Octopress::Social.item(context, @input)
|
94
122
|
|
95
123
|
Octopress::Social::Twitter.set_config(site)
|
96
124
|
Octopress::Social::Twitter.set_url(site, item)
|
data/lib/octopress-social.rb
CHANGED
@@ -33,6 +33,7 @@ module Octopress
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
Liquid::Template.register_tag('tweet', Octopress::Social::Twitter::Tweet)
|
36
37
|
Liquid::Template.register_tag('tweet_button', Octopress::Social::Twitter::Tag)
|
37
38
|
Liquid::Template.register_tag('tweet_link', Octopress::Social::Twitter::Tag)
|
38
39
|
Liquid::Template.register_tag('twitter_script_tag', Octopress::Social::Twitter::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.3.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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|