Sha256: 172d4ccdc4d54d7140585f637b8aa79b954ee199d02c4f67029747aa6164a353
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 KB
Contents
# encoding: UTF-8 require 'sinatra/base' module Spontaneous module Rack module Front def self.application app = ::Rack::Builder.new do # use ::Rack::CommonLogger, STDERR #unless server.name =~ /CGI/ # use ::Rack::ShowExceptions use Spontaneous::Rack::Static, :root => Spontaneous.revision_dir / "public", :urls => %w[/], :try => ['.html', 'index.html', '/index.html'] Spontaneous.instance.front_controllers.each do |namespace, controller_class| map namespace do run controller_class end end if Spontaneous.instance # Make all the files available under plugin_name/public/** # available under the URL /plugin_name/** # Only used in preview mode Spontaneous.instance.plugins.each do |plugin| map "/#{plugin.name}" do run ::Rack::File.new(plugin.paths.expanded(:public)) end end if Spontaneous.instance map "/rev" do run Spontaneous::Rack::CacheableFile.new(Spontaneous.revision_dir / "rev") end map "/media" do run Spontaneous::Rack::CacheableFile.new(Spontaneous.media_dir) end map "/" do use AroundFront use Reloader if Site.config.reload_classes run Server.new end end end class Server < Sinatra::Base include Spontaneous::Rack::Public def call!(env) @env = env @response = ::Sinatra::Response.new @request = ::Sinatra::Request.new(env) render_path(@request.path_info) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spontaneous-0.2.0.alpha2 | lib/spontaneous/rack/front.rb |
spontaneous-0.2.0.alpha1 | lib/spontaneous/rack/front.rb |