From 1d5bfbb162184ebdb92cccde2ccf120e0d242aab Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Sun, 19 Jun 2011 21:25:16 +0200 Subject: [PATCH] Add URL for page creation to allow preemption by extensions --- lib/gollum/frontend/app.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 5b9a77c5..6f510853 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -101,7 +101,7 @@ module Precious mustache :edit end else - mustache :create + redirect "/create/#{CGI.escape(@name)}" end end @@ -124,7 +124,17 @@ module Precious redirect "/#{page.escaped_url_path}" end - + + get '/create/*' do + wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options) + @name = params[:splat].first + if wiki.page(@name) + redirect "/#{CGI.escape(@name)}" + else + mustache :create + end + end + post '/create' do name = params[:page] path = sanitize_empty_params(params[:path]) @@ -298,9 +308,7 @@ module Precious content_type file.mime_type file.raw_data else - @name = name - @path = path - mustache :create + redirect "/create/#{CGI.escape(name)}" end end