diff --git a/HISTORY.md b/HISTORY.md index 261ffee5..3c419bde 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,7 @@ and have bugs that may allow non-whitelisted HTML to sneak through. * Introduce Ruby 1.9 compatibility fixes. + * Handle duplicate page errors in frontend. # 1.0.1 / 2010-08-12 diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index ce5e8580..e4cb0991 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -68,8 +68,13 @@ module Precious format = params[:format].intern - wiki.write_page(name, format, params[:content], commit_message) - redirect "/#{name}" + begin + wiki.write_page(name, format, params[:content], commit_message) + redirect "/#{name}" + rescue Gollum::DuplicatePageError => e + @message = "Duplicate page: #{e.message}" + mustache :error + end end post '/preview' do diff --git a/lib/gollum/frontend/templates/error.mustache b/lib/gollum/frontend/templates/error.mustache new file mode 100644 index 00000000..326cd9f8 --- /dev/null +++ b/lib/gollum/frontend/templates/error.mustache @@ -0,0 +1,11 @@ +