Class: TwitterJekyll::TwitterTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll-twitter-plugin.rb

Direct Known Subclasses

TwitterTagNoCache

Constant Summary collapse

ERROR_BODY_TEXT =
"<p>Tweet could not be processed</p>"
DEFAULT_API_TYPE =
"oembed"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_name, params, _tokens) ⇒ TwitterTag

Returns a new instance of TwitterTag.



157
158
159
160
# File 'lib/jekyll-twitter-plugin.rb', line 157

def initialize(_name, params, _tokens)
  super
  @api_type, @params = parse_params(params)
end

Instance Attribute Details

#cache=(value) ⇒ Object

for testing



155
156
157
# File 'lib/jekyll-twitter-plugin.rb', line 155

def cache=(value)
  @cache = value
end

Class Method Details

.cache_klassObject



162
163
164
# File 'lib/jekyll-twitter-plugin.rb', line 162

def self.cache_klass
  FileCache
end

Instance Method Details

#render(context) ⇒ Object



166
167
168
169
170
171
172
# File 'lib/jekyll-twitter-plugin.rb', line 166

def render(context)
  secrets = find_secrets!(context)
  create_twitter_rest_client(secrets)
  api_client = create_api_client(@api_type, @params)
  response = cached_response(api_client) || live_response(api_client)
  html_output_for(response)
end