25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/rop/project_reader.rb', line 25
def read_project_subdir(dir, collection, nested: false)
return unless File.directory?(dir) && !@entry_filter.symlink?(dir)
entries = Dir.chdir(dir) do
Dir['*.{adoc,md,markdown,html,svg,png}'] + Dir['*'].select { |fn| File.directory?(fn) }
end
entries.each do |entry|
path = File.join(dir, entry)
Jekyll.logger.debug('OPF:', "Reading entry #{path}")
if File.directory?(path)
read_project_subdir(path, collection, nested: true)
elsif nested || (File.basename(entry, '.*') != 'index')
ext = File.extname(path)
if ['.adoc', '.md', '.markdown'].include? ext
doc = NonLiquidDocument.new(path, site: @site, collection: collection)
doc.read
doc_url_parts = doc.url.split('/')
Jekyll.logger.debug('OPF:',
"Reading document in collection #{collection.label} with URL #{doc.url} (#{doc_url_parts.size} parts)")
if (collection.label != 'projects') || (doc_url_parts.size == 5)
Jekyll.logger.debug('OPF:', "Adding document with URL: #{doc.url}")
collection.docs << doc
else
Jekyll.logger.debug('OPF:',
"Did NOT add document with URL (possibly nesting level doesn’t match): #{doc.url}")
end
else
Jekyll.logger.debug('OPF:', "Adding static file: #{path}")
collection.files << ::Jekyll::StaticFile.new(
@site,
@site.source,
Pathname.new(File.dirname(path)).relative_path_from(Pathname.new(@site.source)).to_s,
File.basename(path),
collection
)
end
end
end
end
|