lib/gitdocs/server.rb in gitdocs-0.4.8 vs lib/gitdocs/server.rb in gitdocs-0.4.9

- old
+ new

@@ -16,10 +16,11 @@ gds = @gitdocs manager = @manager Thin::Logging.debug = @manager.debug Thin::Server.start('127.0.0.1', port) do use Rack::Static, :urls => ['/css', '/js', '/img', '/doc'], :root => File.expand_path("../public", __FILE__) + use Rack::MethodOverride run Renee { if request.path_info == '/' render! "home", :layout => 'app', :locals => {:conf => manager.config, :nav_state => "home" } else path 'settings' do @@ -29,22 +30,37 @@ manager.config.global.update_attributes(request.POST['config']) request.POST['share'].each do |idx, share| if remote_branch = share.delete('remote_branch') share['remote_name'], share['branch_name'] = remote_branch.split('/', 2) end - shares[Integer(idx)].update_attributes(share) + # Update paths + if share['path'] && !share['path'].empty? + shares[Integer(idx)].update_attributes(share) + end end EM.add_timer(0.1) { manager.restart } redirect! '/settings' end end path('search').get do render! "search", :layout => 'app', :locals => {:conf => manager.config, :results => manager.search(request.GET['q']), :nav_state => nil} end - path('shares').post do - Configuration::Share.create + path('shares') do + post do + Configuration::Share.create + redirect! '/settings' + end + + var(:int) do |id| + delete do + share = manager.config.shares.find { |s| s.id == id } + halt 404 if share.nil? + share.destroy + redirect! '/settings' + end + end end var :int do |idx| gd = gds[idx] halt 404 if gd.nil? \ No newline at end of file