Sha256: 17d18699f3ff00d69e8c3b03a65798d464c52239267b1a1a1a972a0dcc2953ed

Contents?: true

Size: 736 Bytes

Versions: 5

Compression:

Stored size: 736 Bytes

Contents

require 'padrino'
require 'redcarpet'

Tilt.prefer Tilt::RedcarpetTemplate

module PactBroker
  module Doc
    module Controllers
      class App < Padrino::Application

        set :root, File.join(File.dirname(__FILE__), '..')
        set :show_exceptions, true

        helpers do
          def resource_exists? rel_name
            File.exist? File.join(self.class.root, 'views', "#{rel_name}.markdown")
          end
        end

        get ":rel_name" do
          rel_name = params[:rel_name]
          if resource_exists? rel_name
            markdown rel_name.to_sym, {:layout_engine => :haml, layout: :'layouts/main'}, {}
          else
            response.status = 404
          end
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pact_broker-1.3.2.rc1 lib/pact_broker/doc/controllers/app.rb
pact_broker-1.3.1 lib/pact_broker/doc/controllers/app.rb
pact_broker-1.3.0 lib/pact_broker/doc/controllers/app.rb
pact_broker-1.2.0 lib/pact_broker/doc/controllers/app.rb
pact_broker-1.1.0 lib/pact_broker/doc/controllers/app.rb