diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index e013853f..34c5231a 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -103,5 +103,22 @@ class AdminController < ApplicationController redirect_to :controller => 'admin', :web => @web_name, :action => 'edit_web' end end + + def delete_web + unless (request.post? || ENV["RAILS_ENV"] == "test") + headers['Allow'] = 'POST' + render(:status => 405, :text => 'You must use an HTTP POST', :layout => 'error') + return + end + if wiki.authenticate(params['system_password_delete_web']) + @web.remove_pages(@web.select_all) + wiki.delete_web(@web_name) + flash[:info] = "Web \"#{@web_name}\" has been deleted." + redirect_to :controller => 'wiki', :action => 'web_list' + else + flash[:error] = password_error(params['system_password_delete_web']) + redirect_to :controller => 'admin', :web => @web_name, :action => 'edit_web' + end + end end diff --git a/app/views/admin/edit_web.rhtml b/app/views/admin/edit_web.rhtml index 64d0f90f..393f1d1b 100644 --- a/app/views/admin/edit_web.rhtml +++ b/app/views/admin/edit_web.rhtml @@ -125,4 +125,17 @@

<% end %> +<% form_tag({:controller => 'admin', :web => @web.address, :action => 'delete_web'}, + { :id => 'delete_web', + :onsubmit => "return checkSystemPassword(document.getElementById('system_password_delete_web').value)", + 'accept-charset' => 'utf-8' }) do +%> +

+ Delete this Web, and all its pages. + + and + +

+<% end %> + <%= javascript_include_tag 'edit_web' %>