Refactor create view. Fixes create with file extension. Fixes automatic selection of format in editor.

This commit is contained in:
Bart Kamphorst
2018-02-05 15:15:54 +01:00
parent f75037db42
commit ddea445a28
2 changed files with 15 additions and 20 deletions
+6 -1
View File
@@ -301,7 +301,8 @@ module Precious
@template_page = (temppage.page != nil) ? temppage.page.raw_data : "Template page option is set, but no /_Template page is present or committed." @template_page = (temppage.page != nil) ? temppage.page.raw_data : "Template page option is set, but no /_Template page is present or committed."
end end
wikip = wiki_page(params[:splat].first) wikip = wiki_page(params[:splat].first)
@name, ext = wikip.name.to_url @name = wikip.name.to_url
@ext = wikip.ext
@path = wikip.path @path = wikip.path
@allow_uploads = wikip.wiki.allow_uploads @allow_uploads = wikip.wiki.allow_uploads
@upload_dest = find_upload_dest(@path) @upload_dest = find_upload_dest(@path)
@@ -320,6 +321,10 @@ module Precious
page_dir = settings.wiki_options[:page_file_dir].to_s page_dir = settings.wiki_options[:page_file_dir].to_s
redirect to("/#{clean_url(::File.join(page_dir, page.escaped_url_path))}") redirect to("/#{clean_url(::File.join(page_dir, page.escaped_url_path))}")
else else
unless Gollum::Page.format_for("#{@name}#{@ext}")
@name = "#{@name}#{@ext}"
@ext = nil
end
mustache :create mustache :create
end end
end end
+8 -18
View File
@@ -26,23 +26,7 @@ module Precious
end end
def format def format
@format = (@page.format || false) if @format.nil? && @page @format ||= find_format.to_s.downcase
@format.to_s.downcase
end
def has_footer
@footer = (@page.footer || false) if @footer.nil? && @page
!!@footer
end
def has_header
@header = (@page.header || false) if @header.nil? && @page
!!@header
end
def has_sidebar
@sidebar = (@page.sidebar || false) if @sidebar.nil? && @page
!!@sidebar
end end
def page_name def page_name
@@ -50,7 +34,7 @@ module Precious
end end
def formats def formats
super(:markdown) super(find_format)
end end
def default_markup def default_markup
@@ -61,6 +45,12 @@ module Precious
def content def content
@template_page @template_page
end end
private
def find_format
@found_format ||= (Gollum::Page.format_for("#{@name}#{@ext}") || default_markup)
end
end end
end end
end end