Sha256: b79e74032f2148abdeb41022c593147c1b35b34d5e72eab163658b430bcb9bbf

Contents?: true

Size: 844 Bytes

Versions: 2

Compression:

Stored size: 844 Bytes

Contents

require "coffee-script"
require "sass"
require "sinatra/base"
require "slim"

module Mado
  class App < Sinatra::Base
    set :root, File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "app"))
    set :sass, cache: false

    configure :development do
      require "sinatra/reloader"
      register Sinatra::Reloader
    end

    helpers do
      def markdown_dir
        @markdown_dir ||= File.dirname(settings.markdown_path)
      end
    end

    get '/' do
      slim :index
    end

    get "/css/application.css" do
      sass :application
    end

    get "/js/application.js" do
      coffee :application
    end

    get "/*" do
      path = File.expand_path(params[:splat][0], markdown_dir)

      if File.exist?(path)
        send_file path, disposition: "inline"
      else
        not_found
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mado-0.1.1 lib/mado/app.rb
mado-0.1.0 lib/mado/app.rb