Add palceholder post and update db init
This commit is contained in:
parent
a8e3b30668
commit
fc04245162
3 changed files with 56 additions and 4 deletions
32
lib/DB/PlaceholderPost.rakumod
Normal file
32
lib/DB/PlaceholderPost.rakumod
Normal file
|
@ -0,0 +1,32 @@
|
|||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue