Further tweaking of markup error handling code
This commit is contained in:
parent
2786446dbb
commit
04a8f80273
11 changed files with 77 additions and 68 deletions
|
@ -6,19 +6,17 @@ class AdminController < ApplicationController
|
|||
|
||||
def create_system
|
||||
if @wiki.setup?
|
||||
flash[:error] = <<-EOL
|
||||
Wiki has already been created in '#{@wiki.storage_path}'. Shut down Instiki and delete
|
||||
this directory if you want to recreate it from scratch.<br/><br/>
|
||||
(WARNING: this will destroy content of your current wiki).
|
||||
EOL
|
||||
flash[:error] =
|
||||
"Wiki has already been created in '#{@wiki.storage_path}'. " +
|
||||
"Shut down Instiki and delete this directory if you want to recreate it from scratch." +
|
||||
"\n\n" +
|
||||
"(WARNING: this will destroy content of your current wiki)."
|
||||
redirect_home(@wiki.webs.keys.first)
|
||||
elsif @params['web_name']
|
||||
# form submitted -> create a wiki
|
||||
@wiki.setup(@params['password'], @params['web_name'], @params['web_address'])
|
||||
flash[:info] = <<-EOL
|
||||
Your new wiki '#{@params['web_name']}' is created!<br/>
|
||||
Please edit its home page and press Submit when finished.
|
||||
EOL
|
||||
flash[:info] = "Your new wiki '#{@params['web_name']}' is created!\n" +
|
||||
"Please edit its home page and press Submit when finished."
|
||||
redirect_to :web => @params['web_address'], :controller => 'wiki', :action => 'new',
|
||||
:id => 'HomePage'
|
||||
else
|
||||
|
|
|
@ -122,7 +122,7 @@ class WikiController < ApplicationController
|
|||
|
||||
def edit
|
||||
if @page.nil?
|
||||
redirect_to :action => 'index'
|
||||
redirect_home
|
||||
elsif @page.locked?(Time.now) and not @params['break_lock']
|
||||
redirect_to :web => @web_name, :action => 'locked', :id => @page_name
|
||||
else
|
||||
|
@ -172,28 +172,28 @@ class WikiController < ApplicationController
|
|||
end
|
||||
|
||||
def save
|
||||
redirect_to :action => 'index' if @page_name.nil?
|
||||
redirect_home if @page_name.nil?
|
||||
cookies['author'] = @params['author']
|
||||
|
||||
begin
|
||||
page = @web.pages[@page_name]
|
||||
if @web.pages[@page_name]
|
||||
wiki.revise_page(
|
||||
@web_name, @page_name, @params['content'], Time.now,
|
||||
Author.new(@params['author'], remote_ip)
|
||||
)
|
||||
page.unlock
|
||||
if @page
|
||||
wiki.revise_page(@web_name, @page_name, @params['content'], Time.now,
|
||||
Author.new(@params['author'], remote_ip))
|
||||
@page.unlock
|
||||
else
|
||||
wiki.write_page(
|
||||
@web_name, @page_name, @params['content'], Time.now,
|
||||
Author.new(@params['author'], remote_ip)
|
||||
)
|
||||
wiki.write_page(@web_name, @page_name, @params['content'], Time.now,
|
||||
Author.new(@params['author'], remote_ip))
|
||||
end
|
||||
redirect_to_page @page_name
|
||||
rescue => e
|
||||
page.unlock if defined? page
|
||||
flash[:error] = e
|
||||
redirect_to :action => 'edit', :web => @web_name, :id => @page_name
|
||||
flash[:content] = @params['content']
|
||||
if @page
|
||||
@page.unlock
|
||||
redirect_to :action => 'edit', :web => @web_name, :id => @page_name
|
||||
else
|
||||
redirect_to :action => 'new', :web => @web_name, :id => @page_name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue