allow multiple mount point directories as fall back. this makes deploying easier.
authorelijah <elijah@riseup.net>
Wed, 13 Feb 2013 08:28:05 +0000 (00:28 -0800)
committerelijah <elijah@riseup.net>
Wed, 13 Feb 2013 08:28:05 +0000 (00:28 -0800)
lib/site_mount_point.rb
site.rb

index 0b8224a..3cc9cef 100644 (file)
@@ -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
diff --git a/site.rb b/site.rb
index f503604..eaa5e80 100644 (file)
--- a/site.rb
+++ b/site.rb
@@ -4,7 +4,7 @@
 
 pages 'pages', :path => '/'
 
-pages '../leap_doc', :path => '/docs'
+pages ['../leap_doc', '/home/website/leap_doc'], :path => '/docs'
 
 @title = "LEAP"