Skip to content

Instantly share code, notes, and snippets.

@sumdog
Created October 15, 2015 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumdog/ba0b72d12995dd185303 to your computer and use it in GitHub Desktop.
Save sumdog/ba0b72d12995dd185303 to your computer and use it in GitHub Desktop.
module Jekyll
class << self
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)
File.expand_path(questionable_path)
else
File.join(base_directory, questionable_path)
end
end
end
class Site
class Cleaner
def parent_dirs(file)
parent_dir = File.dirname(file)
if parent_dir == '/'
[]
elsif parent_dir == site.dest
[]
else
[parent_dir] + parent_dirs(parent_dir)
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment