jekyll-twitter-plugin 1.1.1 → 1.2.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/README.md +30 -4
- data/jekyll-twitter-plugin.gemspec +2 -2
- data/lib/jekyll-twitter-plugin.rb +25 -9
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 102db3b0c516a3de0e93b84790b2d58df8394df7
|
4
|
+
data.tar.gz: 4a6ae787a08375f14a48dc4353b1fe588efd10c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49095924e9b819e0bfec51f453b8f5c32c5c47edb72f348d0dee43afd9f65731db4987e10291a3a5e56172c63b69f6346027ba2224a219ca0ee3a87288ceaad3
|
7
|
+
data.tar.gz: 0be6b6ba0671ec4b33590a7b4fc5d09a3ea46f26de8f3b9db307a62f57d04b0116ba507583245b03bb51759ecf7fae169a34e9aa0c801218847c492ba681c7e0
|
data/README.md
CHANGED
@@ -27,7 +27,6 @@ The plugin supports the following features:
|
|
27
27
|
|
28
28
|
* Twitter oauth credentials - Most Twitter api functions now require authentication. Set up your [application](https://dev.twitter.com/apps/new) and get the credentials.
|
29
29
|
|
30
|
-
|
31
30
|
### Usage
|
32
31
|
|
33
32
|
As mentioned by [Jekyll's documentation](http://jekyllrb.com/docs/plugins/#installing-a-plugin) you have two options; manually import the source file or require the plugin as a `gem`.
|
@@ -58,7 +57,21 @@ $ wget https://raw.githubusercontent.com/rob-murray/jekyll-twitter-plugin/master
|
|
58
57
|
|
59
58
|
#### Credentials
|
60
59
|
|
61
|
-
Your Twitter application authentication credentials are private - do not distribute these!
|
60
|
+
Your Twitter application authentication credentials are private - do not distribute these!
|
61
|
+
|
62
|
+
You can set the authentication variables by adding them to `_config.yml`.
|
63
|
+
|
64
|
+
```yaml
|
65
|
+
# _config.yml
|
66
|
+
twitter:
|
67
|
+
consumer_key: asdf
|
68
|
+
consumer_secret: asdf
|
69
|
+
access_token: asdf
|
70
|
+
access_token_secret: asdf
|
71
|
+
```
|
72
|
+
|
73
|
+
If the authentication variables are not present in `_config.yml` they can be gathered from
|
74
|
+
environment variables.
|
62
75
|
|
63
76
|
* TWITTER_CONSUMER_KEY
|
64
77
|
* TWITTER_CONSUMER_SECRET
|
@@ -100,7 +113,7 @@ The [oembed](https://dev.twitter.com/rest/reference/get/statuses/oembed) API ret
|
|
100
113
|
|
101
114
|
### Output
|
102
115
|
|
103
|
-
As with the original plugin, all content will be rendered inside a div with the classes 'embed' and 'twitter'
|
116
|
+
As with the original plugin, all content will be rendered inside a div with the classes 'embed' and 'twitter'
|
104
117
|
|
105
118
|
```html
|
106
119
|
<div class='embed twitter'>
|
@@ -115,11 +128,24 @@ If something goes wrong then a basic error message will be displayed;
|
|
115
128
|
|
116
129
|
### Caching
|
117
130
|
|
118
|
-
|
131
|
+
Twitter API responses can be cached to speed up Jekyll site builds and avoid going over API limits. The reponses will be cached in a directory within your Jekyll project called `.tweet-cache`, ensure that this is not commit to source control.
|
132
|
+
|
133
|
+
Caching is enabled by default.
|
119
134
|
|
135
|
+
It is possible to disable caching by using the specific `twitternocache` tag.
|
136
|
+
|
137
|
+
```liquid
|
138
|
+
{% twitternocache oembed status_url *options %}
|
139
|
+
|
140
|
+
# Example
|
141
|
+
{% twitternocache oembed https://twitter.com/rubygems/status/518821243320287232 %}
|
142
|
+
|
143
|
+
```
|
120
144
|
|
121
145
|
### Contributions
|
122
146
|
|
147
|
+
I've tried hard to keep all classes and code in the one `lib/jekyll-twitter-plugin.rb` file so that people can just grab this file and include in their Jekyll `_plugins` directory if they do not want to use the Gem. This may have to be dropped if the one file gets too overwhelming.
|
148
|
+
|
123
149
|
Please use the GitHub pull-request mechanism to submit contributions.
|
124
150
|
|
125
151
|
### License
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'jekyll-twitter-plugin'
|
7
|
-
spec.version = '1.
|
7
|
+
spec.version = '1.2.0'
|
8
8
|
spec.authors = ['Rob Murray']
|
9
9
|
spec.email = ['robmurray17@gmail.com']
|
10
10
|
spec.summary = 'A Liquid tag plugin for Jekyll that renders Tweets from Twitter API'
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
|
18
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
18
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
19
19
|
spec.add_development_dependency 'rake'
|
20
20
|
spec.add_development_dependency 'pry-byebug'
|
21
21
|
|
@@ -4,6 +4,7 @@ require 'twitter'
|
|
4
4
|
# A Liquid tag plugin for Jekyll that renders Tweets from Twitter API.
|
5
5
|
# https://github.com/rob-murray/jekyll-twitter-plugin
|
6
6
|
#
|
7
|
+
|
7
8
|
module TwitterJekyll
|
8
9
|
class FileCache
|
9
10
|
def initialize(path)
|
@@ -104,7 +105,7 @@ module TwitterJekyll
|
|
104
105
|
private
|
105
106
|
|
106
107
|
def key
|
107
|
-
@status_url
|
108
|
+
'%s-%s' % [@status_url, @params.to_s]
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
@@ -123,11 +124,11 @@ module TwitterJekyll
|
|
123
124
|
args = params.split(/\s+/).map(&:strip)
|
124
125
|
@api_type = args.shift
|
125
126
|
@params = args
|
126
|
-
|
127
|
-
create_twitter_rest_client
|
128
127
|
end
|
129
128
|
|
130
|
-
def render(
|
129
|
+
def render(context)
|
130
|
+
secrets = extract_twitter_secrets_from_context(context) || extract_twitter_secrets_from_env
|
131
|
+
create_twitter_rest_client(secrets)
|
131
132
|
api_client = create_api_client(@api_type, @params)
|
132
133
|
response = cached_response(api_client) || live_response(api_client)
|
133
134
|
html_output_for(response)
|
@@ -167,14 +168,29 @@ module TwitterJekyll
|
|
167
168
|
end
|
168
169
|
end
|
169
170
|
|
170
|
-
def create_twitter_rest_client
|
171
|
+
def create_twitter_rest_client(secrets)
|
171
172
|
@twitter_client = Twitter::REST::Client.new do |config|
|
172
|
-
config.consumer_key =
|
173
|
-
config.consumer_secret =
|
174
|
-
config.access_token =
|
175
|
-
config.access_token_secret =
|
173
|
+
config.consumer_key = secrets.consumer_key
|
174
|
+
config.consumer_secret = secrets.consumer_secret
|
175
|
+
config.access_token = secrets.access_token
|
176
|
+
config.access_token_secret = secrets.access_token_secret
|
176
177
|
end
|
177
178
|
end
|
179
|
+
|
180
|
+
TwitterSecrets = Struct.new(:consumer_key, :consumer_secret, :access_token, :access_token_secret)
|
181
|
+
|
182
|
+
def extract_twitter_secrets_from_context(context)
|
183
|
+
TwitterSecrets.new(context.registers[:site].config['twitter']['consumer_key'], context.registers[:site].config['twitter']['consumer_secret'], context.registers[:site].config['twitter']['access_token'], context.registers[:site].config['twitter']['access_token_secret']) if context_has_twitter_secrets?(context)
|
184
|
+
end
|
185
|
+
|
186
|
+
def context_has_twitter_secrets?(context)
|
187
|
+
twitter_secrets = context.registers[:site].config['twitter'] || {}
|
188
|
+
['consumer_key', 'consumer_secret', 'access_token', 'access_token_secret'].all? {|s| twitter_secrets.key?(s)}
|
189
|
+
end
|
190
|
+
|
191
|
+
def extract_twitter_secrets_from_env
|
192
|
+
TwitterSecrets.new(ENV.fetch('TWITTER_CONSUMER_KEY'), ENV.fetch('TWITTER_CONSUMER_SECRET'), ENV.fetch('TWITTER_ACCESS_TOKEN'), ENV.fetch('TWITTER_ACCESS_TOKEN_SECRET'))
|
193
|
+
end
|
178
194
|
end
|
179
195
|
|
180
196
|
class TwitterTagNoCache < TwitterTag
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-twitter-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Murray
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.7'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.4.3
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: A Liquid tag plugin for Jekyll that renders Tweets from Twitter API
|