Solve minor issue involving Preview title (#1417)

This commit is contained in:
Dawa Ometto
2019-09-11 15:47:41 +02:00
committed by GitHub
parent 0fda253457
commit d55a3432a2
3 changed files with 9 additions and 3 deletions
+2 -2
View File
@@ -382,7 +382,7 @@ module Precious
post '/preview' do
wiki = wiki_new
@name = params[:page] || "Preview"
@name = params[:page] ? strip_page_name(CGI.unescape(params[:page])) : 'Preview'
@page = wiki.preview_page(@name, params[:content], params[:format])
['sidebar', 'header', 'footer'].each do |subpage|
@page.send("set_#{subpage}".to_sym, params[subpage]) if params[subpage]
@@ -393,7 +393,7 @@ module Precious
@h1_title = wiki.h1_title
@editable = false
@bar_side = wiki.bar_side
@allow_uploads = wiki.allow_uploads
@allow_uploads = false
@navbar = false
@preview = true
mustache :page
+5
View File
@@ -10,6 +10,11 @@ module Precious
[nil, ''].include?(param) ? nil : CGI.unescape(param)
end
def strip_page_name(name)
# Check if name already has a format extension, and if so, strip it.
Gollum::Page.valid_extension?(name) ? Gollum::Page.strip_filename(name) : name
end
# Remove all slashes from the start of string.
# Remove all double slashes
def clean_url url
+2 -1
View File
@@ -434,8 +434,9 @@ context "Frontend" do
end
test "previews content" do
post "/gollum/preview", :content => 'abc', :format => 'markdown'
post "/gollum/preview", :content => 'abc', :format => 'markdown', :page => 'Samewise%20Gamgee.mediawiki'
assert last_response.ok?
assert last_response.body.include?('Samewise Gamgee</h1>')
end
test "previews content on the first page of an empty wiki" do