diff options
author | Saku Ytti <saku@ytti.fi> | 2014-04-16 10:04:12 +0300 |
---|---|---|
committer | Saku Ytti <saku@ytti.fi> | 2014-04-16 10:04:12 +0300 |
commit | d74a152bba73095a0c7090dc078a7023eeb9ad18 (patch) | |
tree | 43f0a47fc93bcdd22f5799d41989582fc57c1cc9 /lib/oxidized/api/web/webapp.rb | |
parent | 2af41e1769225ac42027f2f686763389296bab79 (diff) |
remove web API
It is now separately in oxidized-web package
Diffstat (limited to 'lib/oxidized/api/web/webapp.rb')
-rw-r--r-- | lib/oxidized/api/web/webapp.rb | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/lib/oxidized/api/web/webapp.rb b/lib/oxidized/api/web/webapp.rb deleted file mode 100644 index 751a4c7..0000000 --- a/lib/oxidized/api/web/webapp.rb +++ /dev/null @@ -1,104 +0,0 @@ -require 'sinatra/base' -require 'sinatra/json' -require 'haml' -require 'sass' -require 'pp' -module Oxidized - module API - class WebApp < Sinatra::Base - - get '/' do - redirect '/nodes' - end - - get '/nodes.?:format?' do - @data = nodes.list.map do |node| - node[:status] = 'never' - node[:time] = 'never' - node[:group] = 'default' unless node[:group] - if node[:last] - node[:status] = node[:last][:status] - node[:time] = node[:last][:end] - end - node - end - out :nodes - end - - get '/reload.?:format?' do - nodes.load - @data = 'reloaded list of nodes' - out - end - - - get '/node/fetch/:node' do - node, @json = route_parse :node - @data = nodes.fetch node, nil - out :text - end - - get '/node/fetch/:group/:node' do - node, @json = route_parse :node - @data = nodes.fetch node, params[:group] - out :text - end - - - get '/node/next/:node' do - node, @json = route_parse :node - nodes.next node - redirect '/nodes' unless @json - @data = 'ok' - out - end - - # use this to attach author/email/message to commit - put '/node/next/:node' do - node, @json = route_parse :node - opt = JSON.load request.body.read - nodes.next node, opt - redirect '/nodes' unless @json - @data = 'ok' - out - end - - get '/node/show/:node' do - node, @json = route_parse :node - @data = nodes.show node - out :node - end - - get '/stylesheets/*.css' do - sass params[:splat].first.to_sym - end - - private - - def out template=:default - if @json or params[:format] == 'json' - json @data - elsif template == :text - content_type :text - @data - else - haml template - end - end - - def nodes - settings.nodes - end - - def route_parse param - json = false - e = params[param].split '.' - if e.last == 'json' - e.pop - json = true - end - [e.join('.'), json] - end - end - end -end |