Sha256: fb8c2f87c95f9014c7dffd2385f89d2c0e7287a755f19629b65dbcd803c7476d
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
# Rework this to be nicer.. Extend Sintra::Base require 'sinatra/base' module Gumdrop class Server < Sinatra::Base set :port, Gumdrop.config.port if Gumdrop.config.port # get '/' do # redirect '/index.html' # end get '/*' do Gumdrop.run :dry_run=>true if Gumdrop.config.force_reload file_path= get_content_path params[:splat].join('/') if Gumdrop.site.has_key? file_path content= Gumdrop.site[file_path] if content.useLayout? content_type :css if content.ext == '.css' # Meh? content_type :js if content.ext == '.js' # Meh? content_type :xml if content.ext == '.xml' # Meh? content.render else send_file "source/#{file_path}" end else puts "NOT FOUND: #{file_path}" "#{file_path} Not Found" end end def get_content_path(file_path) keys= [ file_path, "#{file_path}.html", "#{file_path}/index.html" ] if file_path == "" "index.html" else keys.detect {|k| Gumdrop.site.has_key?(k) } end end if Gumdrop.config.auto_run Gumdrop.run :dry_run=>true run! end def self.start(opts={}) # Options opts.reverse_merge! :auto_run => true, :cache_data => false Gumdrop.config.merge! opts Gumdrop.run :dry_run=>true ::Gumdrop::Server end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gumdrop-0.2.7 | lib/gumdrop/server.rb |