jekyll-twitter-plugin 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da29e624fad543de4ea74ed5a5d44dd868ae9468
4
- data.tar.gz: 6d01a8bdf2f03668f4848835cbda7e5f0edca03a
3
+ metadata.gz: d5cd33cbcbe9db1fff312ba25adb0dafa82b34d4
4
+ data.tar.gz: 6a1be3c2d7cab837a8b9a6a78575189f6ec2b423
5
5
  SHA512:
6
- metadata.gz: 4e5545d32edf1ea675d569baff3907801619f8df5f9348a9f82a7c12097594ab94226cd70954a1eeda6da8c17ff1790cb05b15db8a8f81bad836b3c3968738b8
7
- data.tar.gz: 56e1fede9de06facbe5cd41340448a5a316376979903afc1c75fa65a7aed2e94eb119732eb5c3413b54ecc6672c41ee52f29e1f014eda3725fad3bd5ef21de95
6
+ metadata.gz: ca3b17df94b100230807ae6efcf4c3d0983d63c68d3c629bb2cc2e2edac3452acfa9134ad92695f121ce1b3843fe5767cbbf20699dc589e7c687bba9ace263b6
7
+ data.tar.gz: ee194ec61bc5519e307789e095aa41618e213f4151792b2eff6d98c3d3fba9cc0fb11a275dbc136742dfb06b1f2a01b962b151629fea49d65c9983a08a4dff8b
data/README.md CHANGED
@@ -9,7 +9,7 @@ A Liquid tag plugin for Jekyll that renders Tweets from Twitter API.
9
9
 
10
10
  A Liquid tag plugin for [Jekyll](http://jekyllrb.com/) that enables Twitter content to be used in any content served by Jekyll, content is fetched from the [Twitter API](https://dev.twitter.com/home).
11
11
 
12
- It is based on the original Jekyll Tweet Tag from [scottwb](https://github.com/scottwb/jekyll-tweet-tag) which has not been updated since Twitter updated their API to require Oauth. This version uses the excellent [Twitter gem](https://github.com/sferik/twitter) to make requests and handle authentication.
12
+ It is based on the original Jekyll Tweet Tag from [scottwb](https://github.com/scottwb/jekyll-tweet-tag) which has not been updated since Twitter updated their API to require certain preconditions. This version uses the excellent [Twitter gem](https://github.com/sferik/twitter) to make requests and handle authentication.
13
13
 
14
14
  This plugin replaces the broken plugin mentioned above and uses a different tag name and API - this is by design so that the two plugins can be used, if the original gets fixed.
15
15
 
@@ -60,10 +60,10 @@ $ wget https://raw.githubusercontent.com/rob-murray/jekyll-twitter-plugin/master
60
60
 
61
61
  Your Twitter application authentication credentials are private - do not distribute these! As such this plugin requires your credentials as Environment variables, it requires the following keys to be set;
62
62
 
63
- * **TWITTER_CONSUMER_KEY**
64
- * **TWITTER_CONSUMER_SECRET**
65
- * **TWITTER_ACCESS_TOKEN**
66
- * **TWITTER_ACCESS_TOKEN_SECRET**
63
+ * TWITTER_CONSUMER_KEY
64
+ * TWITTER_CONSUMER_SECRET
65
+ * TWITTER_ACCESS_TOKEN
66
+ * TWITTER_ACCESS_TOKEN_SECRET
67
67
 
68
68
  ```bash
69
69
  $ export TWITTER_CONSUMER_KEY=foo etc.
@@ -73,13 +73,13 @@ $ export TWITTER_CONSUMER_KEY=foo etc.
73
73
 
74
74
  To use the plugin, in your source content use the tag `twitter` and then pass additional parameters to the plugin.
75
75
 
76
- ```ruby
77
- {% plugin_type api_type params %}
76
+ ```liquid
77
+ {% plugin_type api_type *params %}
78
78
  ```
79
79
 
80
80
  * `plugin_type` - Either `twitter` or `twitternocache`.
81
81
  * `api_type` - The Twitter API to use, check below for supported APIs.
82
- * `params` - Parameters for the API separated by spaces.
82
+ * `*params` - Parameters for the API separated by spaces. Refer below and to respective Twitter API documentation for available parameters.
83
83
 
84
84
  ### Supported Twitter APIs
85
85
 
@@ -89,10 +89,13 @@ The following Twitter APIs are supported.
89
89
 
90
90
  The [oembed](https://dev.twitter.com/rest/reference/get/statuses/oembed) API returns html snippet to embed in your app, this will be rendered in the familiar Twitter style.
91
91
 
92
- ```ruby
93
- {% twitter oembed status_url %}
92
+ ```liquid
93
+ {% twitter oembed status_url *options %}
94
+
94
95
  # Example
95
96
  {% twitter oembed https://twitter.com/rubygems/status/518821243320287232 %}
97
+ # With options
98
+ {% twitter oembed https://twitter.com/rubygems/status/518821243320287232 align='right' width='350' %}
96
99
  ```
97
100
 
98
101
  ### Output
@@ -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.0.1'
7
+ spec.version = '1.1.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'
@@ -37,8 +37,6 @@ module TwitterJekyll
37
37
  end
38
38
 
39
39
  class NullCache
40
- def initialize; end
41
-
42
40
  def read(_key); end
43
41
 
44
42
  def write(_key, _data); end
@@ -52,7 +50,15 @@ module TwitterJekyll
52
50
  def key; end
53
51
  end
54
52
 
55
- module TwitterApiMixin
53
+ class TwitterApi
54
+ def initialize(client, params)
55
+ @client = client
56
+ @status_url = params.shift
57
+ parse_args(params)
58
+ end
59
+
60
+ private
61
+
56
62
  def id_from_status_url(url)
57
63
  if url.to_s =~ /([^\/]+$)/
58
64
  Regexp.last_match[1]
@@ -66,25 +72,37 @@ module TwitterJekyll
66
72
  rescue Twitter::Error::NotFound
67
73
  nil
68
74
  end
75
+
76
+ def parse_args(args)
77
+ @params ||= begin
78
+ params = {}
79
+ args.each do |arg|
80
+ k, v = arg.split('=').map(&:strip)
81
+ if k && v
82
+ if v =~ /^'(.*)'$/
83
+ v = Regexp.last_match[1]
84
+ end
85
+ params[k] = v
86
+ end
87
+ end
88
+ params
89
+ end
90
+ end
69
91
  end
70
92
 
71
- class Oembed
72
- include TwitterJekyll::TwitterApiMixin
93
+ class Oembed < TwitterApi
73
94
  include TwitterJekyll::Cacheable
74
95
 
75
- def initialize(client, params)
76
- @client = client
77
- @status_url = params
78
- end
79
-
80
96
  def fetch
81
97
  tweet_id = id_from_status_url(@status_url)
82
98
 
83
99
  if tweet = find_tweet(tweet_id)
84
- @client.oembed tweet
100
+ @client.oembed tweet, @params
85
101
  end
86
102
  end
87
103
 
104
+ private
105
+
88
106
  def key
89
107
  @status_url
90
108
  end
@@ -108,19 +126,19 @@ module TwitterJekyll
108
126
  end
109
127
 
110
128
  def render(_context)
111
- api_type = @params.first
112
- tweet_params = @params.last
129
+ api_type = @params.dup.shift
113
130
 
114
- api_client = create_api_client(api_type, tweet_params)
115
- html_output_for(api_client)
131
+ api_client = create_api_client(api_type, @params)
132
+ response = cached_response(api_client) || live_response(api_client)
133
+ html_output_for(response)
116
134
  end
117
135
 
118
136
  private
119
137
 
120
- def html_output_for(api_client)
138
+ def html_output_for(response)
121
139
  body = ERROR_BODY_TEXT
122
140
 
123
- if response = cached_response(api_client) || live_response(api_client)
141
+ if response
124
142
  body = response.html || body
125
143
  end
126
144
 
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.0.1
4
+ version: 1.1.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-10-05 00:00:00.000000000 Z
11
+ date: 2014-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler