Class: Locomotive::Steam::Middlewares::WysihtmlCss

Inherits:
Object
  • Object
show all
Defined in:
lib/locomotive/steam/middlewares/wysihtml_css.rb

Constant Summary collapse

GOOGLE_AMP_PATH =
'_amp'

Instance Method Summary collapse

Constructor Details

#initialize(app, opts = {}) ⇒ WysihtmlCss

Returns a new instance of WysihtmlCss.


9
10
11
# File 'lib/locomotive/steam/middlewares/wysihtml_css.rb', line 9

def initialize(app, opts = {})
  @app = app
end

Instance Method Details

#call(env) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/locomotive/steam/middlewares/wysihtml_css.rb', line 13

def call(env)
  status, headers, response = @app.call(env)

  if content?(env['steam.page'], env['steam.path'], response)
    url   = ::ActionController::Base.helpers.stylesheet_path('locomotive/wysihtml5_editor')
    html  = %(<link rel="stylesheet" type="text/css" href="#{url}">)
    response.first.gsub!('</head>', %(#{html}</head>))
  end

  [status, headers, response]
end