Sha256: ef9b0ac6300ed83219cda48b72b250e5821c56088973564a5603b2a8ce278bab

Contents?: true

Size: 533 Bytes

Versions: 28

Compression:

Stored size: 533 Bytes

Contents

module Locomotive
  module Middlewares
    class Permalink

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

      def call(env)
        if env['PATH_INFO'] =~ /^#{Locomotive.mounted_on}\/_permalink.json/
          request     = Rack::Request.new(env)
          underscore  = request.params['underscore'] == '1'
          value       = request.params['string'].try(:permalink, underscore)

          [200, {}, [{ value: value }.to_json]]
        else
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
locomotive_cms-2.5.7 lib/locomotive/middlewares/permalink.rb
locomotivecms-3.0.0.pre.alpha.2 lib/locomotive/middlewares/permalink.rb
locomotivecms-3.0.0.pre.alpha lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.5.6 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.5.6.rc2 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.5.6.rc1 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.5.5 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.5.4 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.5.3 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.5.2 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.5.1 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.5.0 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.5.0.rc3 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.5.0.rc2 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.5.0.rc1 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.4.1 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.4.0 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.3.1 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.3.0 lib/locomotive/middlewares/permalink.rb
locomotive_cms-2.2.3 lib/locomotive/middlewares/permalink.rb