Permalink
Browse files

allow builder to take a custom template directory

  • Loading branch information...
1 parent 3136902 commit 91fdab9cada48921e34e222997ee59cfee7b90fb @technoweenie technoweenie committed Apr 26, 2011
Showing with 9 additions and 5 deletions.
  1. +9 −5 lib/gollum/page_builder.rb
View
14 lib/gollum/page_builder.rb
@@ -15,15 +15,17 @@ def build_page_link(link_name)
attr_reader :assets,
:layout_template,
- :page_template
+ :page_template,
+ :dir
def initialize(wiki, options = {})
@wiki = wiki
@assets = %w(gollum.css template.css)
- @layout_template = "#{DEFAULT_TEMPLATES_PATH}/layout.mustache"
- @page_template = "#{DEFAULT_TEMPLATES_PATH}/page.mustache"
-
process_options(options)
+
+ @dir ||= DEFAULT_TEMPLATES_PATH
+ @layout_template ||= "#{@dir}/layout.mustache"
+ @page_template ||= "#{@dir}/page.mustache"
end
# Public: Publishes the wiki to the given filesystem path.
@@ -93,7 +95,7 @@ def copy_assets_to(destination)
asset_path = "#{destination}/#{ext}"
FileUtils.mkdir(asset_path)
files.each do |file|
- file = "#{DEFAULT_TEMPLATES_PATH}/#{file}" unless file['/']
+ file = "#{@dir}/#{file}" unless file['/']
FileUtils.cp file, "#{asset_path}/#{::File.basename(file)}"
end
end
@@ -123,6 +125,8 @@ def process_options(options)
if page = options[:page_template]
@page_template = ::File.expand_path(page)
end
+
+ @dir = options[:dir]
end
DEFAULT_TEMPLATES_PATH = ::File.expand_path('../page_builder', __FILE__)

0 comments on commit 91fdab9

Please sign in to comment.