|
@ -1,4 +1,4 @@ |
|
|
%w[sinatra dm-core dm-migrations haml sass].each{ |lib| require lib } |
|
|
|
|
|
|
|
|
%w[sinatra dm-core dm-migrations haml sass coffee_script].each{ |lib| require lib } |
|
|
DataMapper.setup(:default, File.join("sqlite3://",settings.root,"development.db")) |
|
|
DataMapper.setup(:default, File.join("sqlite3://",settings.root,"development.db")) |
|
|
|
|
|
|
|
|
class Robot |
|
|
class Robot |
|
@ -13,6 +13,8 @@ DataMapper.finalize |
|
|
|
|
|
|
|
|
get ('/styles.css'){ scss :styles } |
|
|
get ('/styles.css'){ scss :styles } |
|
|
|
|
|
|
|
|
|
|
|
get('/application.js'){ coffee :application } |
|
|
|
|
|
|
|
|
get '/' do |
|
|
get '/' do |
|
|
@robots = Robot.all |
|
|
@robots = Robot.all |
|
|
haml :index |
|
|
haml :index |
|
@ -20,10 +22,14 @@ end |
|
|
|
|
|
|
|
|
post '/build/robot' do |
|
|
post '/build/robot' do |
|
|
robot = Robot.create |
|
|
robot = Robot.create |
|
|
|
|
|
if request.xhr? |
|
|
|
|
|
haml :robot, { layout: false, locals: { robot: robot } } |
|
|
|
|
|
else |
|
|
redirect to('/') |
|
|
redirect to('/') |
|
|
end |
|
|
end |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
delete '/delete/robot/:id' do |
|
|
delete '/delete/robot/:id' do |
|
|
Robot.get(params[:id]).destroy |
|
|
Robot.get(params[:id]).destroy |
|
|
redirect to('/') |
|
|
|
|
|
|
|
|
redirect to('/') unless request.xhr? |
|
|
end |
|
|
end |