diff options
author | elijah <elijah@riseup.net> | 2013-02-13 00:28:05 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2013-02-13 00:28:05 -0800 |
commit | 594e8a6284b20ebd73cb9253dd6b016d90b35965 (patch) | |
tree | e6cee6c0686df976e8b4bbcfb9247f337b5e64f0 | |
parent | 1ffbf21a961b93a33ea94b578a4260932f13414d (diff) |
allow multiple mount point directories as fall back. this makes deploying easier.
-rw-r--r-- | lib/site_mount_point.rb | 26 | ||||
-rw-r--r-- | site.rb | 2 |
2 files changed, 21 insertions, 7 deletions
diff --git a/lib/site_mount_point.rb b/lib/site_mount_point.rb index 0b8224a..3cc9cef 100644 --- a/lib/site_mount_point.rb +++ b/lib/site_mount_point.rb @@ -14,12 +14,7 @@ class SiteMountPoint attr_accessor :timestamp def initialize(site_config, directory_source, options={}) - if directory_source.starts_with?('/') - @directory = directory_source - else - @directory = File.expand_path(directory_source, File.dirname(site_config.file_path)) - end - + @directory = find_directory(site_config, directory_source) @path = options[:path] @relative_directory = relative_dir_path(@directory) @menu_file = file_path('menu.txt') @@ -56,4 +51,23 @@ class SiteMountPoint end end + def find_directory(site_config, directory_source) + directory = nil + [directory_source].flatten.each do |dir_source| + if dir_source.starts_with?('/') + directory = dir_source + else + directory = File.expand_path(dir_source, File.dirname(site_config.file_path)) + end + if Dir.exists?(directory) + break + end + end + if Dir.exists?(directory) + return directory + else + raise 'FATAL ERROR: could find any of %s' % directory_source.join(', ') + end + end + end
\ No newline at end of file @@ -4,7 +4,7 @@ pages 'pages', :path => '/' -pages '../leap_doc', :path => '/docs' +pages ['../leap_doc', '/home/website/leap_doc'], :path => '/docs' @title = "LEAP" |