|
|
@ -118,15 +118,22 @@ class App < Sinatra::Application
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
get %r{\A/(.+?)(?=\-|/)} do |doc|
|
|
|
|
|
|
|
|
return 404 unless @doc = settings.docs[doc]
|
|
|
|
|
|
|
|
erb :other
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get '/ping' do
|
|
|
|
get '/ping' do
|
|
|
|
200
|
|
|
|
200
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get %r{\A/(\w+)(\-[\w\-]+)?(/)?(.+)?\z} do |doc, type, slash, rest|
|
|
|
|
|
|
|
|
return 404 unless @doc = settings.docs[doc]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !rest && !slash
|
|
|
|
|
|
|
|
redirect "/#{doc}#{type}/"
|
|
|
|
|
|
|
|
elsif rest && rest.end_with?('/')
|
|
|
|
|
|
|
|
redirect "#{doc}#{type}#{slash}#{rest[0...-1]}"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
erb :other
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
not_found do
|
|
|
|
not_found do
|
|
|
|
send_file File.join(settings.public_folder, '404.html'), status: status
|
|
|
|
send_file File.join(settings.public_folder, '404.html'), status: status
|
|
|
|
end
|
|
|
|
end
|
|
|
|