Grimoire.
h3rald h3rald@h3rald.com
Sat, 24 Feb 2024 13:51:56 +0100
5 files changed,
129 insertions(+),
8 deletions(-)
D
contents/grimoire.md
@@ -1,7 +0,0 @@
------ -id: grimoire -title: Grimoire -content-type: page ------ - -_Coming soon!_
M
rules.min
→
rules.min
@@ -4,10 +4,11 @@ {} :ARCHIVES
() :ARTICLES {} :HOME () :PROJECTS +() :SPELLS "contents/articles" ls size :articles-count 17 :projects-count -0 :grimoire-count +"contents/grimoire" ls size :grimoire-count ( symbol to-date@@ -65,6 +66,28 @@ output-fwrite
) ) :: ;; Create the Projects page + +( + symbol create-grimoire-page + (==>) + ( + {} + "grimoire/index" %id + "grimoire.html" %path + ".html" %ext + "GRIMOIRE" %title + "page" %content-type + SPELLS (/id swap /id <) sort %spells + projects-count %projects-count + articles-count %articles-count + grimoire-count %grimoire-count + dup "grimoire" swap mustache :page + "grimoire" page process-icons + %contents + output-fwrite + ) +) :: +;; Create the Grimoire page ( symbol process-timestamp@@ -296,6 +319,7 @@ (((content 'draft dhas? not) (content 'content-type dhas?)) &&)
( content /id :id (content /content-type "project" ==) (content PROJECTS append @PROJECTS) when + (content /content-type "spell" ==) (content SPELLS append @SPELLS) when content projects-count %projects-count articles-count %articles-count@@ -309,6 +333,7 @@ ) foreach
; Create aggregator pages create-projects-page + create-grimoire-page create-articles-page ; Generate home page
A
scripts/spell.min
@@ -0,0 +1,41 @@
+;Generates a new spell page. +"" :ident +"" :title +"" :subtitle +false :valid-id + +( + (str) expect first :ident + ident "^[a-z0-9-]+$" match? :valid-regexp + (. "contents" "grimoire") => "/" join ls :filelist + filelist (filename "(.+)\..+$" search 1 get) map ident in? not :valid-file + valid-regexp valid-file and +) ^validate + +(valid-id not) ( + "ID" ask @ident + ident validate @valid-id + (valid-id not) + ("ID must not be already used and it must contain only lowercase letters, numbers, or -" warn) + when +) while + +"Title" ask @title +"Subtitle" ask @subtitle + +"----- +id: $1 +title: \"$2\" +subtitle: \"$3\" +content-type: spell +----- + +" (ident title subtitle) =% :metadata + +("Cast spell?" confirm) + ( + (ident ".md") => "" join :fn + (. "contents" "grimoire" fn) => "/" join :path + metadata path fwrite + ) +when
A
templates/grimoire.mustache
@@ -0,0 +1,34 @@
+<!DOCTYPE html> +<html lang="en"> + {{> _head}} + <body> + {{> _theme_switcher}} + <div class="main container-fluid themed-content"> + <div class="row"> + <div class="col-xs-12 sidebar"> + {{> _header}} + </div> + </div> + <div class="row main-content"> + <div class="col-xs-12"> + <article class="{{content-type}} box content"> + {{> _page_header}} + <p>This is the old grimoire of Herald. It contains <strong>{{grimoire-count}}</strong> powerful spells and enchantments to unlock the secret magic of Unix or the dark curses of Windows.</p> + <div id="body-text" class="hyphenate"> + <ul> + {{#spells}} + <li><a href="{{id}}">{{title}}</a></li> + {{/spells}} + </ul> + </div> + </article> + </div> + </div> + <div class="row"> + <div class="col-xs-12"> + {{> _footer}} + </div> + </div> + </div> + </body> +</html>