-
-
Save bezhermoso/ffe79962000c3d50ad88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sinkdown | |
class Server | |
def initialize | |
Faye::WebSocket.load_adapter 'thin' | |
@thin = Rack::Handler.get 'thin' | |
end | |
def serve(site) | |
app = Rack::Builder.new do | |
use Sinkdown::Middleware::Reload, | |
:site => site | |
use Rack::Cors do | |
allow do | |
origins '*' | |
resource '/', | |
:methods => [:get, :post, :delete, :put, :options, :head] | |
end | |
end | |
use Faye::RackAdapter, | |
:mount => '/faye', | |
:timeout => 25 | |
# Serve Markdown -> HTML files | |
use Rack::Static, | |
:urls => ['/html'], | |
:root => site.config[:sinkdown_dir], | |
:index => 'index.html' | |
use Rack::Static, | |
:urls => ['/css', '/js'], | |
:root => File.dirname(__FILE__) + '/assets' | |
use Sinkdown::Middleware::Api, | |
:site => site | |
run Sinkdown::Middleware::RedirectHome | |
end | |
@thin.run app, :Port => site.config[:port] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment