Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: f9d82730dc
Fetching contributors…

Cannot retrieve contributors at this time

43 lines (31 sloc) 1.04 kB
require 'sinatra/base'
require 'hide'
module Hide
class Server < Sinatra::Base
enable :logging, :show_exceptions
configure :production, :development do
require File.expand_path('../../../config', __FILE__)
end
configure do
set :website_path, Hide.config(:path)
set :website_directories, Hide.config(:directories)
end
post '/update' do
begin
json = Yajl::Parser.parse(request.body)
before, after = json['before'], json['after']
# p [before, after]
site = Hide::Site.new(settings.website_path, :pages_directories => settings.website_directories)
@indexer = Hide::Indexer.new site, 'elastic-search-website'
@indexer.update! before, after
rescue Yajl::ParseError
puts request.body.read
error 500, "Invalid JSON"
rescue Hide::GitError
puts request.body.read
error 500, "Invalid JSON payload -- shas missing?"
end
end
end
end
Hide::Server.run! if __FILE__ == $0
Jump to Line
Something went wrong with that request. Please try again.