PFT::Content - Filesytem tree mapping content
PFT::Content->new($basedir); PFT::Content->new($basedir, {create => 1});
The structure is the following:
content ├── attachments ├── blog ├── pages ├── pics └── tags
Quick accessors for directories
$tree->dir_root $tree->dir_blog $tree->dir_pages $tree->dir_tags $tree->dir_pics $tree->dir_attachments
Non-existing directories are created by the constructor if the {create => 1} option is passed as last constructor argument.
{create => 1}
Create and return a page. A header is required as argument.
If the page does not exist it gets created according to the header. If the header contains a date, the page is considered to be a blog entry (and positioned as such). If the data is missing the day information, the entry is a month entry.
Similar to new_entry, but does not create a content file if it doesn't exist already.
new_entry
Given a PFT::Header object, returns the path of a page or blog page within the tree.
Note: this function does not work properly if you are seeking for a tag. Tags are a different beast, since they have the same header as a page, but they belong to a different place.
Create and return a tag page. A header is required as argument. If the tag page does not exist it gets created according to the header.
Similar to new_tag, but does not create the content file if it doesn't exist already.
new_tag
List all blog entries (days and months).
List all pages (not tags pages)
List all tag pages (not regular pages)
List all entries (pages + blog + tags)
Get a picture.
Accepts a list of strings which will be joined into the path of a picture file. Returns a PFT::Content::Blob instance, which could correspond to a non-existing file. The caller might create it (e.g. by copying a picture on the corresponding path).
PFT::Content::Blob
List all pictures.
Get an attachment.
Accepts a list of strings which will be joined into the path of an attachment file. Returns a PFT::Content::Blob instance, which could correspond to a non-existing file. The caller might create it (e.g. by copying a file on the corresponding path).
Note that the input path should be made by strings in encoded form, in order to match the filesystem path.
List all attachments.
Go back in blog history of a number of days, return the entries corresponding to that date.
Expects one optional argument as the number of backward days in the blog history. If such argument is not provided, it defaults to 0, returning the entries of the latest edit day.
Please note that only days containing entries really count. If a blog had one entry today, no entry for yesterday and one the day before yesterday, blog_back(0) will return today's entry, and blog_back(1) will return the entry of two days ago.
blog_back(0)
blog_back(1)
Returns a list PFT::Content::Blog object, possibly empty if the blog does not have that many days.
Go back in blog history to a certain date.
Expects as argument a PFT::Date item indicating a date to seek for blog entries.
PFT::Date
Returns a possibly empty list of PFT::Content::Blog objects corresponding to the zero, one or more entries in the specified date.
PFT::Content::Blog
Given a PFT::Content::File object (or any subclass) determines the corresponding date by analyzing the path. Returns a PFT::Date object or undef if the page does not have date.
PFT::Content::File
This function is helpful for checking inconsistency between the date declared in headers and the date used on the file system.
Given a PFT::Content::File object (or any subclass) determines the corresponding slug by analyzing the path. Returns the slug or undef if the content does not have a slug (e.g. months).
This function is helpful for checking inconsistency between the slug declared in headers and the slug used on the file system.
Notify this content abstraction about the renaming of the corresponding content file. First parameter is the original name, second parameter is the new name.
To install PFT, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PFT
CPAN shell
perl -MCPAN -e shell install PFT
For more information on module installation, please visit the detailed CPAN module installation guide.