Sha256: aaf5175e2f35b0a3b0ab35c55f547d90d9ac62214aabbf1d304e5de48b90e064

Contents?: true

Size: 643 Bytes

Versions: 3

Compression:

Stored size: 643 Bytes

Contents

require 'bundler/setup'
require 'sinatra/base'

# The project root directory
$root = ::File.dirname(__FILE__)

class SinatraStaticServer < Sinatra::Base

  get(/.+/) do
    send_sinatra_file(request.path) {404}
  end

  not_found do
    send_file(File.join(File.dirname(__FILE__), 'public', '404.html'), {:status => 404})
  end

  def send_sinatra_file(path, &missing_file_block)
    file_path = File.join(File.dirname(__FILE__), 'public',  path)
    file_path = File.join(file_path, 'index.html') unless file_path =~ /\.[a-z]+$/i
    File.exist?(file_path) ? send_file(file_path) : missing_file_block.call
  end

end

run SinatraStaticServer

Version data entries

3 entries across 2 versions & 1 rubygems

Version Path
octopress-3.0.0.alpha2 lib/octopress/scaffold/site/config.ru
octopress-3.0.0.alpha2 lib/octopress/scaffold/site/config/rack.rb
octopress-3.0.0.alpha1 lib/octopress/scaffold/site/config/rack.rb