Basic database operations
This commit is contained in:
parent
08e450bd51
commit
40ec00a4ad
3 changed files with 71 additions and 6 deletions
|
@ -1,10 +1,13 @@
|
|||
use v6.e.PREVIEW;
|
||||
|
||||
#| Post database
|
||||
unit module DB;
|
||||
|
||||
use Pandoc;
|
||||
use JSON::Class:auth<zef:vrurg>;
|
||||
|
||||
#| Shared post meta-data
|
||||
role Post {
|
||||
role Post is json {
|
||||
#| 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
|
||||
|
@ -18,9 +21,26 @@ role Post {
|
|||
}
|
||||
|
||||
#| A plain markdown post
|
||||
class MarkdownPost does Post {
|
||||
class MarkdownPost does Post is json {
|
||||
#| Marker for disambiguation between post types in json representation, the
|
||||
#| cheaty way
|
||||
has Bool:D $.markdown = True;
|
||||
|
||||
method title(--> Str:D) {
|
||||
markdown-title($!source)
|
||||
}
|
||||
}
|
||||
|
||||
# #| 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 = [];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue