Merge pull request #1198 from QuaeNocentDocent/template_page
Template page
This commit is contained in:
@@ -157,6 +157,7 @@ Gollum comes with the following command line options:
|
||||
| --template-dir | [PATH] | Specify custom mustache template directory. |
|
||||
| --help | none | Display the list of options on the command line. |
|
||||
| --version | none | Display the current version of Gollum. |
|
||||
| --template-page | none | Tell Gollum to use /_Template as the default content for new pages. _Template must be git committed. |
|
||||
|
||||
**Notes:**
|
||||
|
||||
|
||||
+4
-2
@@ -148,7 +148,9 @@ MSG
|
||||
opts.on("--template-dir [PATH]", "Specify custom mustache template directory.") do |path|
|
||||
wiki_options[:template_dir] = path
|
||||
end
|
||||
|
||||
opts.on("--template-page", "Use _Template in root as a template for new pages.") do
|
||||
wiki_options[:template_page] = true
|
||||
end
|
||||
opts.separator ""
|
||||
opts.separator " Common:"
|
||||
|
||||
@@ -162,7 +164,6 @@ MSG
|
||||
end
|
||||
|
||||
opts.separator ""
|
||||
|
||||
end
|
||||
|
||||
# Read command line options into `options` hash
|
||||
@@ -208,6 +209,7 @@ if options[:irb]
|
||||
if !wiki.exist? then
|
||||
raise Gollum::InvalidGitRepositoryError
|
||||
end
|
||||
|
||||
puts
|
||||
puts "Loaded Gollum wiki at:"
|
||||
puts "#{File.expand_path(gollum_path).inspect}"
|
||||
|
||||
@@ -314,6 +314,10 @@ module Precious
|
||||
|
||||
get '/create/*' do
|
||||
forbid unless @allow_editing
|
||||
if settings.wiki_options[:template_page] then
|
||||
temppage = wiki_page("/_Template")
|
||||
@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.gsub('+', '-'))
|
||||
@name = wikip.name.to_url
|
||||
@path = wikip.path
|
||||
|
||||
@@ -56,6 +56,11 @@ module Precious
|
||||
def default_markup
|
||||
Precious::App.settings.default_markup
|
||||
end
|
||||
|
||||
#QND - sets default template page if specified
|
||||
def content
|
||||
@template_page
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -310,6 +310,28 @@ context "Frontend" do
|
||||
assert_no_match(/[^\/]#{dir}/, last_response.body)
|
||||
end
|
||||
|
||||
test "create with template succeed if template exists" do
|
||||
Precious::App.set(:wiki_options, { :template_page => true })
|
||||
page='_Template'
|
||||
post '/create', :content => 'fake template', :page => page,
|
||||
:path => '/', :format => 'markdown', :message => ''
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
#puts last_response
|
||||
@wiki.clear_cache
|
||||
get "/create/TT"
|
||||
assert last_response.ok?
|
||||
get '/delete/_Template'
|
||||
Precious::App.set(:wiki_options, { :template_page => false })
|
||||
end
|
||||
|
||||
test "create with template succeed if template doesn't exist" do
|
||||
Precious::App.set(:wiki_options, { :template_page => true })
|
||||
get "/create/TT"
|
||||
assert last_response.ok?
|
||||
Precious::App.set(:wiki_options, { :template_page => false })
|
||||
end
|
||||
|
||||
test "create sets the correct path for a relative path subdirectory with the page file directory set" do
|
||||
Precious::App.set(:wiki_options, { :page_file_dir => "foo" })
|
||||
dir = "bardir"
|
||||
|
||||
Reference in New Issue
Block a user