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."
end
wikip = wiki_page(params[:splat].first)
@name, ext = wikip.name.to_url
@name = wikip.name.to_url
@ext = wikip.ext
@path = wikip.path
@allow_uploads = wikip.wiki.allow_uploads
@upload_dest = find_upload_dest(@path)
@@ -320,6 +321,10 @@ module Precious
page_dir = settings.wiki_options[:page_file_dir].to_s
redirect to("/#{clean_url(::File.join(page_dir, page.escaped_url_path))}")
else
unless Gollum::Page.format_for("#{@name}#{@ext}")
@name = "#{@name}#{@ext}"
@ext = nil
end
mustache :create
end
end
+9 -19
View File
@@ -26,23 +26,7 @@ module Precious
end
def format
@format = (@page.format || false) if @format.nil? && @page
@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
@format ||= find_format.to_s.downcase
end
def page_name
@@ -50,7 +34,7 @@ module Precious
end
def formats
super(:markdown)
super(find_format)
end
def default_markup
@@ -60,7 +44,13 @@ module Precious
#QND - sets default template page if specified
def content
@template_page
end
end
private
def find_format
@found_format ||= (Gollum::Page.format_for("#{@name}#{@ext}") || default_markup)
end
end
end
end