Sha256: c0866b59473a1d16b69080f5cfce8a954affbfdcae37ebf46e0308db96fa2a4c
Contents?: true
Size: 899 Bytes
Versions: 16
Compression:
Stored size: 899 Bytes
Contents
module Locomotive module Steam module Middlewares class WysihtmlCss GOOGLE_AMP_PATH = '_amp' def initialize(app, opts = {}) @app = app end 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 protected def content?(page, path, response) !path.starts_with?(GOOGLE_AMP_PATH + '/') && !page.redirect && page.response_type == 'text/html' && response.first end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems