My first Jekyll blog which I hosted on GitHub Pages before they offered SSL http://habdas.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

config.ru 643B

12345678910111213141516171819202122232425
  1. require 'bundler/setup'
  2. require 'sinatra/base'
  3. # The project root directory
  4. $root = ::File.dirname(__FILE__)
  5. class SinatraStaticServer < Sinatra::Base
  6. get(/.+/) do
  7. send_sinatra_file(request.path) {404}
  8. end
  9. not_found do
  10. send_file(File.join(File.dirname(__FILE__), 'public', '404.html'), {:status => 404})
  11. end
  12. def send_sinatra_file(path, &missing_file_block)
  13. file_path = File.join(File.dirname(__FILE__), 'public', path)
  14. file_path = File.join(file_path, 'index.html') unless file_path =~ /\.[a-z]+$/i
  15. File.exist?(file_path) ? send_file(file_path) : missing_file_block.call
  16. end
  17. end
  18. run SinatraStaticServer