bin/ghp in ghp-0.0.5 vs bin/ghp in ghp-0.0.7
- old
+ new
@@ -33,21 +33,41 @@
end
end
module Nanoc::DataSources
module Filesystem
+ def get_ghp_config
+ Dir.chdir(File.expand_path('../..', __FILE__).strip) {
+ Nanoc::Site.new('.').config
+ }
+ end
+
+ def pathfind_file(in_dir = ".")
+ (["./lib"] + $:).collect {|x| File.join(File.expand_path("..", x), in_dir) }.select {|x| File.directory? x }.each do |found_dir|
+ yield found_dir
+ end
+ end
+
def items
- ghp_config = Nanoc::Site.new('.').config
+ ghp_config = get_ghp_config
alt_content = ghp_config[:alt_content] || "content"
- alt_dir = (["./lib"] + $:).collect {|x| File.join(File.expand_path("..", x), alt_content) }.select {|x| File.directory? x }[0]
- load_objects(alt_dir, 'item', Nanoc::Item)
+
+ acc = [ ]
+ pathfind_file(alt_content) do |alt_dir|
+ acc += load_objects(alt_dir, 'item', Nanoc::Item)
+ end
+ acc
end
def layouts
- ghp_config = Nanoc::Site.new('.').config
+ ghp_config = get_ghp_config
alt_layouts = ghp_config[:alt_layouts] || "layouts"
- alt_dir = (["./lib"] + $:).collect {|x| File.join(File.expand_path("..", x), alt_layouts) }.select {|x| File.directory? x }[0]
- load_objects(alt_dir, 'layout', Nanoc::Layout)
+
+ acc = []
+ pathfind_file(alt_layouts) do |alt_dir|
+ acc += load_objects(alt_dir, 'layout', Nanoc::Layout)
+ end
+ acc
end
end
end
# Run base