Class: NanDoc::DataSource
- Inherits:
-
Nanoc3::DataSources::FilesystemUnified
- Object
- Nanoc3::DataSources::FilesystemUnified
- NanDoc::DataSource
- Includes:
- Cli::CommandMethods, ItemMethods
- Defined in:
- lib/nandoc/support/orphanage.rb,
lib/nandoc/hacks/data-source.rb
Overview
reopen, not really necessary
Defined Under Namespace
Modules: ItemMethods Classes: Orphanage
Instance Method Summary collapse
-
#filename_for(base_filename, ext) ⇒ Object
the content filename for ../README is ../README.
-
#initialize(*a) ⇒ DataSource
constructor
A new instance of DataSource.
-
#items ⇒ Object
Hack the items returned by this datasource object to include also files outside of the <my-site>/content directory, e.g.
Methods included from ItemMethods
#dot_dot_has?, #dot_dot_strip, #dot_dot_strip_assert, #find_parent, #identifier_bare_rootname, #identifier_bare_rootname_assert, #parent_identifier, #site_root, #slash_strip, #slash_strip_assert
Methods included from Cli::CommandMethods
#command_abort, #command_name, #command_path_assert, #invite_to_more_command_help, #invocation_name
Constructor Details
#initialize(*a) ⇒ DataSource
Returns a new instance of DataSource.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nandoc/hacks/data-source.rb', line 19 def initialize *a super(*a) # hack to see as text files without an extension! unless @site.config[:text_extensions].include?(nil) @site.config[:text_extensions].unshift(nil) end @hax_filename_for_last = nil @config = a.last @basenames = @config[:source_file_basenames] or fail("must have source_file_basenames in config.yaml "<< "for nandoc to work." ) @hax_mode = false # this gets turned on when we are doing s/thing weird @hax_root_found = false end |
Instance Method Details
#filename_for(base_filename, ext) ⇒ Object
the content filename for ../README is ../README
39 40 41 42 43 44 45 46 47 |
# File 'lib/nandoc/hacks/data-source.rb', line 39 def filename_for(base_filename, ext) return super unless @hax_mode && ext.nil? if @hax_filename_for_last != base_filename @hax_filename_for_last = base_filename return super else base_filename end end |
#items ⇒ Object
Hack the items returned by this datasource object to include also files outside of the <my-site>/content directory, e.g. README.md or README/*/, NEWS.md, based on settings in the config.
Rescue orphan nodes with no parent page somehow.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/nandoc/hacks/data-source.rb', line 57 def items _ = Nanoc3::Item # autoload it now for easier step debug-ging these = super dot_dot_names = @basenames.map{|x| "../#{x}"} @hax_mode = true additional = dot_dot_names.map do |basename| if File.file?(basename) # was different load_objects(basename, 'item', Nanoc3::Item) else load_objects(basename, 'item', Nanoc3::Item) end end.compact.flatten(1) @hax_mode = false error_for_no_files(dot_dot_names) if additional.empty? res = these + additional orphan_rescue(res) res end |