Sha256: 8800ae027a05e150ba59f83fc6d7d78bb5e7c3badeee210cfb14da3f657f86ef

Contents?: true

Size: 772 Bytes

Versions: 17

Compression:

Stored size: 772 Bytes

Contents

module Locomotive
  module Steam
    module Middlewares

      class WysihtmlCss

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

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

          if content?(env['steam.page'], response)
            url   = ::ActionController::Base.helpers.stylesheet_url('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, response)
          page && !page.redirect && page.response_type == 'text/html' && response.first
        end

      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
locomotivecms-3.1.2 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.2.1 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.2.0 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.2.0.rc2 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.2.0.rc1 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.1.1 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.1.0 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.1.0.rc3 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.1.0.rc2 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.1.0.rc1 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.0.1 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.0.0 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.0.0.rc7 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.0.0.rc6 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.0.0.rc5 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.0.0.rc4 lib/locomotive/steam/middlewares/wysihtml_css.rb
locomotivecms-3.0.0.rc3 lib/locomotive/steam/middlewares/wysihtml_css.rb