Module: Evil::Helpers
- Includes:
- Models
- Defined in:
- lib/evil/helpers.rb
Instance Method Summary collapse
- #attempt_openid_authentication ⇒ Object
- #not_authorized(message = nil) ⇒ Object
- #partial(template, options = {}) ⇒ Object
- #render_config_field(field) ⇒ Object
- #serve(template) ⇒ Object
- #urlencode(str) ⇒ Object
- #whitelisted_openid? ⇒ Boolean
Instance Method Details
#attempt_openid_authentication ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/evil/helpers.rb', line 36 def attempt_openid_authentication openid_authenticate do |result, identity_url| if result == :successful yield identity_url else end end end |
#not_authorized(message = nil) ⇒ Object
27 28 29 30 |
# File 'lib/evil/helpers.rb', line 27 def (=nil) status 401 halt haml(:login) end |
#partial(template, options = {}) ⇒ Object
19 20 21 |
# File 'lib/evil/helpers.rb', line 19 def partial(template, ={}) haml(partial_name(template), .merge( :layout => false )) end |
#render_config_field(field) ⇒ Object
23 24 25 |
# File 'lib/evil/helpers.rb', line 23 def render_config_field(field) partial("plugins/fields/#{field.type}", :locals => { :field => field }) end |
#serve(template) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/evil/helpers.rb', line 5 def serve(template) initialize_plugins liquid_template = Liquid::Template.parse(template.reload.source) content_type(template.content_type || 'text/html', :charset => template.encoding || 'utf-8') if template.ttl headers 'Cache-Control' => "public, max-age=#{template.ttl}" end liquid_template.render 'params' => params end |
#urlencode(str) ⇒ Object
46 47 48 |
# File 'lib/evil/helpers.rb', line 46 def urlencode(str) URI.escape(str) end |
#whitelisted_openid? ⇒ Boolean
32 33 34 |
# File 'lib/evil/helpers.rb', line 32 def whitelisted_openid? session[:identity_url] && Whitelist.(session[:identity_url]) end |