NAME

PFT::Content - Filesytem tree mapping content

SYNOPSIS

PFT::Content->new($basedir);
PFT::Content->new($basedir, {create => 1});

DESCRIPTION

The structure is the following:

content
├── attachments
├── blog
├── pages
├── pics
└── tags

Properties

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.

Methods

new_entry

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.

entry

Similar to new_entry, but does not create a content file if it doesn't exist already.

hdr_to_path

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.

new_tag

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.

tag

Similar to new_tag, but does not create the content file if it doesn't exist already.

blog_ls

List all blog entries (days and months).

pages_ls

List all pages (not tags pages)

tags_ls

List all tag pages (not regular pages)

entry_ls

List all entries (pages + blog + tags)

pic

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).

pics_ls

List all pictures.

attachment

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.

attachments_ls

List all attachments.

blog_back

Go back in blog history, return the corresponding entry.

Expects one optional argument as the number of steps backward in history. If such argument is not provided, it defaults to 0, returning the most recent entry.

Returns a PFT::Content::Blog object, or undef if the blog does not have that many entries.

path_to_date

Given a path (of a page) determine the corresponding date. Returns a PFT::Date object or undef if the page does not have date.

path_to_slug

Given a path (of a page) determine the corresponding slug string.

was_renamed

Notify a renaming of a inner file. First parameter is the original name, second parameter is the new name.