The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Plerd::Post - A Plerd blog post

DESCRIPTION

An object of the class Plerd::Post represents a single post to a Plerd-based blog, with Markdown source and HTML output.

CLASS METHODS

new( \%config )

Object constructor. The single config hashref must include the following keys:

plerd

The parent Plerd object.

source_file

A Path::Class::File object representing this post's Markdown source file.

OBJECT ATTRIBUTES

Read-only attributes

newer_post

A Plerd::Post object representing the next-newer post to the blog.

Is the current object represents the newest post in the blog, then this method returns undef.

older_post

A Plerd::Post object representing the next-older post to the blog.

Is the current object represents the oldest post in the blog, then this method returns undef.

published_filename

The local filename (without parent directory path) of the HTML file that this post will generate upon publication.

published_timestamp

This post's date, in W3C format, set to midnight in the local timezone.

reading_time

An estimated reading-time for this post, measured in whole minutes, and based on an assumed (and fairly conservative) reading pace of 200 words per minute.

updated_timestamp

The modification time of this this post's source file, in W3C format, set to the local timezone.

uri

The URI of the of the HTML file that this post will generate upon publication.

utc_date

Returns the value of date (see below), with the time zone set to UTC.

Read-write attributes

attributes

A hashref of all the attributes defined in the source document's metadata section, whether or not Plerd takes any special meaning from them.

For example, if a source document defines both title and favorite_color key-value pairs in its metadata, both keys and values will appear in this hashref, even though Plerd pays no mind to the latter key.

body

String representing the post's body text.

date

DateTime object representing this post's presented publication date.

Plerd usually sets this for you, based on the post's metadata, and sets the time zone to local. If you'd like the object in UTC time instead, use the utc_date attribute.

description

String representing a short, descriptive summary of this post. This value affects the metadata attached to this post, for use by social media and such.

If you don't set this value yourself by the time Plerd needs it, then it will set it to the first paragraph of the post's body text (with all markup removed).

image

(Optional) URI object referencing an illustrative image for this post.

Setting this value affects the metadata attached to this post, for use by social media and such.

image_alt

(Optional) A text description of the image referenced by the image atribute.

Setting this value affects the metadata attached to this post, for use by social media and such.

title

String representing this post's title.

tags

An array reference to the list of tags (as plain-text strings) associated with this post as set in the source file using the 'tags:' header.

tag_objects

An array reference to the list of tags (as Plerd::Tag objects) associated with this post as set in the source file using the 'tags:' header.

OBJECT METHODS

publish

 $post->publish

Publishes the post.

send_webmentions

 $report = $post->send_webmentions

Attempts to send a webmention for every hyperlink contained in the post.

The return value is a hashref with the following keys:

attempts

The number of webmentions this post attempted to send.

sent

The number of webmentions actually sent (due to webmention-endpoint URLs advertised by the links' targets).

delivered

The number of webmentions whose delivery was acknowledged by the receiving endpoint.

AUTHOR

Jason McIntosh <jmac@jmac.org>