| Class | FileHandlers::DirectoryHandler |
| In: |
lib/webgen/plugins/filehandlers/directory.rb
|
| Parent: | DefaultHandler |
Handles directories.
Returns a new DirNode.
# File lib/webgen/plugins/filehandlers/directory.rb, line 81
81: def create_node( path, parent, meta_info )
82: filename = File.basename( path ) + '/'
83: if parent.nil? || (node = parent.find {|child| child =~ filename }).nil?
84: node = DirNode.new( parent, filename, meta_info )
85: node.node_info[:processor] = self
86: node.node_info[:src] = path
87: end
88: node
89: end
See DefaultFileHandler#link_from and PageHandler#link_from.
# File lib/webgen/plugins/filehandlers/directory.rb, line 105
105: def link_from( node, ref_node, attr = {} )
106: lang_node = (attr[:resolve_lang_node] == false ? node : node.node_for_lang( ref_node['lang'] ) )
107: attr[:link_text] ||= lang_node['directoryName'] || node['title']
108: super( lang_node, ref_node, attr )
109: end
Return the page node for the directory node using the specified language lang. If an index file is specified, then the its correct language node is returned, else node is returned.
# File lib/webgen/plugins/filehandlers/directory.rb, line 99
99: def node_for_lang( node, lang )
100: langnode = node['indexFile'].node_for_lang( lang ) if node['indexFile']
101: langnode || node
102: end
Recursively creates a given directory path starting from the path of parent and returns the bottom most directory node.
# File lib/webgen/plugins/filehandlers/directory.rb, line 113
113: def recursive_create_path( path, parent )
114: path.split( File::SEPARATOR ).each do |pathname|
115: case pathname
116: when '.' then #do nothing
117: when '..' then parent = parent.parent
118: else parent = @plugin_manager['Core/FileHandler'].create_node( pathname, parent, self )
119: end
120: end
121: parent
122: end