Webgen::SourceHandler::Metainfo

Summary

This source handler operates on paths that match one of the following path patterns (see the path pattern documentation for more information): **/metainfo, **/*.metainfo

Following is the default meta information set on any node created by this source handler:

blocks: 
  1: 
    name: paths
  2: 
    name: alcn

Description

This source handler provides the ability to set meta information for any path. It uses files in Webgen Page Format which can have two special blocks:

  • paths: This block specifies meta information for paths and therefore this meta information is applied before a node for a path is created. This can be used, for example, to change the output path style. When specifying patterns, remember that the patterns are matched against paths!

  • alcn: This block specifies meta information for nodes and this meta information is applied directly after a node has been created. When specifying patterns, remember that the patterns are matched against absolute localized canonical names! So you always need to take the language part into account, ie. /index.html won’t match but /index.en.html will.

When no name is specified in the meta information file, the first block is assumed to be the paths block and the second block is assumed to be the alcn block. The format of the two blocks is the same: they need to be in YAML format and provide a hash with path patterns as keys and the to-be-assigned meta information as values. The patterns can be normal file system paths or node (a)lcns but you can also use some special characters like * (match any file), ** (match recursively or expansively) and ? (match a single character). You can find the full information in the documentation for File.fnmatch.

All this is best showed in an example:

--- name:paths
/**/index.page:
  output_path_style: [:parent, :basename, :ext, [., :lang]]

mypic.jpg:
  in_menu: true
--- name:alcn
**/index.en.html:
  in_menu: true

All paths named index.page are assigned a new output path style. This has to be done in the paths block because otherwise it would have no effect. And the file mypic.jpg will show up in the menu. Notice, that the first form is specified as an absolute path pattern and the second not. If this meta information file lies in the root directory there is no difference between those two approaches. However, when it lies in a sub directory, the first form is still absolute but the second form is taken relative to the directory in which the meta information file is in.

And last but not least, all nodes with a localized canonical name of index.en.html will show up in the menu (again, notice that the pattern is relative).