website/lib/DB/PlaceholderPost.rakumod

33 lines
748 B
Raku
Raw Normal View History

use v6.e.PREVIEW
use Pandoc;
use JSON::Class:auth<zef:vrurg>;
use DB::Post;
#| An empty placeholder post
unit class PlaceholderPost does Post is json;
#| Marker for disambiguation between post types in json representation, the
#| cheaty way
has Bool:D $.placeholder = True;
method title(--> Str:D) {
"Placeholder Article"
}
#| Shortcut for creating an empty placeholder post
method empty(--> PlaceholderPost:D) {
PlaceholderPost.new(
source => "/dev/null".IO,
posted-at => DateTime.now,
hidden => True,
)
}
# Override the all-slugs method to return an empty array, we don't want the
# placeholder article to be refered to as anything but its id
method all-slugs(--> Array[Str:D]) {
Array[Str:D].new
}