Class: Jekyll::GoogleCse
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::GoogleCse
- Defined in:
- lib/jekyll-google_cse.rb,
lib/jekyll-google_cse/version.rb
Overview
:nodoc:
Constant Summary collapse
- InvalidGoogleCseConfig =
Class.new(Jekyll::Errors::FatalException)
- TEMPLATE =
"<script>\n (function() {\nvar cx = '%s';\nvar gcse = document.createElement('script');\ngcse.type = 'text/javascript';\ngcse.async = true;\ngcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +\n '//cse.google.com/cse.js?cx=' + cx;\nvar s = document.getElementsByTagName('script')[0];\ns.parentNode.insertBefore(gcse, s);\n })();\n</script>\n<gcse:search></gcse:search>\n".freeze
- VERSION =
'1.0.0'.freeze
Instance Method Summary collapse
Instance Method Details
#fetch_google_cse_config(context) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jekyll-google_cse.rb', line 29 def fetch_google_cse_config(context) cse_config = context.registers[:site].config['google_cse_id'] case cse_config when String return cse_config end raise InvalidGoogleCseConfig, 'Invalid jekyll-google_cse configuration. See '\ 'https://github.com/brint/jekyll-google_cse#usage for more '\ 'details on usage and configuration.' end |
#render(context) ⇒ Object
24 25 26 27 |
# File 'lib/jekyll-google_cse.rb', line 24 def render(context) google_cse_config = fetch_google_cse_config(context) format(TEMPLATE, google_cse_config) end |