2025-01-21 03:24:01 -05:00
|
|
|
use v6.e.PREVIEW;
|
|
|
|
|
2025-01-21 01:31:33 -05:00
|
|
|
#| Post database
|
|
|
|
unit module DB;
|
|
|
|
|
|
|
|
use Pandoc;
|
2025-01-21 03:24:01 -05:00
|
|
|
use JSON::Class:auth<zef:vrurg>;
|
2025-01-21 01:31:33 -05:00
|
|
|
|
|
|
|
#| Shared post meta-data
|
2025-01-21 03:24:01 -05:00
|
|
|
role Post is json {
|
2025-01-21 01:31:33 -05:00
|
|
|
#| The location of the source file for the post
|
|
|
|
has IO::Path:D $.source is required;
|
|
|
|
#| The time to display for the creation of the post
|
|
|
|
has DateTime:D $.posted-at is required;
|
|
|
|
#| An optional list of edit times for the post
|
|
|
|
has DateTime:D @.edited-at is rw = [];
|
|
|
|
|
|
|
|
#| Get the title for this post, intended to be extracted from whatever
|
|
|
|
#| document produced it
|
|
|
|
method title(--> Str:D) {...}
|
|
|
|
}
|
|
|
|
|
|
|
|
#| A plain markdown post
|
2025-01-21 03:24:01 -05:00
|
|
|
class MarkdownPost does Post is json {
|
|
|
|
#| Marker for disambiguation between post types in json representation, the
|
|
|
|
#| cheaty way
|
|
|
|
has Bool:D $.markdown = True;
|
2025-01-21 01:31:33 -05:00
|
|
|
|
|
|
|
method title(--> Str:D) {
|
|
|
|
markdown-title($!source)
|
|
|
|
}
|
|
|
|
}
|
2025-01-21 03:24:01 -05:00
|
|
|
|
|
|
|
# #| A literate idris post in markdown format
|
|
|
|
# class IdrisPost does Post {
|
|
|
|
|
|
|
|
# method title(--> Str:D) {
|
|
|
|
# markdown-title($!source)
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
|
|
|
|
#| The top level posts database
|
|
|
|
class PostDB is json(:pretty) {
|
|
|
|
#| The inner list of posts
|
|
|
|
has Post:D @.posts = [];
|
|
|
|
}
|