module Jekyll

Public Class Methods

sanitized_path(base_directory, questionable_path) click to toggle source
# File lib/jekyll-multisite.rb, line 31
def sanitized_path(base_directory, questionable_path)
 
 if base_directory.eql?(questionable_path)
   base_directory
 elsif questionable_path.start_with?(base_directory)
   questionable_path
 elsif File.exists?(questionable_path) and !questionable_path.start_with?('/') and (ENV['OS'] == 'Windows_NT')
   File.expand_path(questionable_path)
 elsif File.exists?(questionable_path) and questionable_path != '/' and !(ENV['OS'] == 'Windows_NT')
   File.expand_path(questionable_path)
 else
   File.join(base_directory, questionable_path)
 end

end
sync_dir(cur, base, dest) click to toggle source

Move the _shared directories to the correct location

(very hacky - we move all the files to the correct 
 location with a hook after the site is written/rendered)
# File lib/jekyll-multisite.rb, line 85
def self.sync_dir(cur, base,  dest)
  Dir.glob( File.join(cur, '*'), File::FNM_DOTMATCH).each do |f|
    
    rel = Pathname.new(f).relative_path_from(base)
    dest_dir = File.join(dest, rel)
    
    if File.basename(f) == '.' or File.basename(f) == '..'
      next 
    elsif File.directory?(f)
            if not File.exists?(dest_dir)
              Dir.mkdir(dest_dir)
            end
      sync_dir(f, base, dest)
            Dir.rmdir(f)
    else
            FileUtils.mv(f, dest_dir)
    end
  end
end