WWW::Kontent::Path - Classes for navigating Kontent stores
my $path = WWW::Kontent::Path.new; $path.parse('foo/bar[42]/baz.pdf{view}'); $path.resolve(:in($root), :request($r)); say $path.components[0].name; # foo say $path.components[1].revno; # 42 say ref $path.components[3].revision; # WWW::Kontent::Store::NarrowDBI::SavedRev say $path.format; # pdf
WWW::Kontent::Path is a class representing a path to a Kontent page. Besides the Path object itself, it also defines WWW::Kontent::Component, a single part of a path.
A path is the portion of the URL which Kontent examines to determine which page it should operate on, which mode that page should be processed in, and which format it should be rendered in. Expressed as a Perl 6 grammar, it might look something like this:
grammar Grammar::Kontent::Path { rule name { \w+ } rule revno { \[ \d+ \] } rule format { \. <name> } rule mode { \{ <name> \} } rule component { <name> <revno>? } rule path { /? [ <revno> | <component> ] [ / <component> ]* <format>? <mode>? } }
In somewhat simpler terms, all of these are valid:
<name>/<name>/<name> <name>[<revno>]/<name>{mode} [<revno>]/<name>/<name>[<revno>].<format>
As well as most similar combinations.
Component objects contain two accessors, name and revno, representing the name and revision number of that particular part of the path. name is undefined in the first component, representing the root node; if revno is undefined it means that the current revision should be used.
name
revno
After resolve has been called on the WWW::Kontent::Path object it belongs to, two additional fields become available. page and revision contain the page and revision, respectively, associated with the component.
resolve
page
revision
A component can be stringified, yielding a string something like bar[42], but intelligent enough to omit missing parts of the component.
bar[42]
Component objects should never be allocated by user code; only WWW::Kontent::Path should create them.
Represents a full path (set of components). Once a Path object has been allocated, a string path must be given to the parse method; later, a call to resolve (with the root node and request passed in) will find the pages and revisions associated with those path components.
parse
The components accessor, filled in by parse, contains an array of Component objects. The mode accessor contains the mode, while the format accessor contains the format. The page and revision accessors retrieve the page and revision, respectively, of the last component, and are only useful after resolve has been called.
components
mode
format
WWW::Kontent
To install WWW::Kontent::Path, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Kontent::Path
CPAN shell
perl -MCPAN -e shell install WWW::Kontent::Path
For more information on module installation, please visit the detailed CPAN module installation guide.