Reviewed rules.
h3rald h3rald@h3rald.com
Sat, 24 Feb 2024 13:33:15 +0100
1 files changed,
120 insertions(+),
102 deletions(-)
jump to
M
rules.min
→
rules.min
@@ -66,53 +66,59 @@ )
) :: ;; Create the Projects page -; Group articles by month ( - (dict) expect -> :content - (content 'timestamp dhas?) + symbol process-timestamp + (dict :content ==> dict :result) ( - content /timestamp :ts - ts to-date :date - ts integer "yyyyMM" tformat :code - ts integer "MMMM yyyy" tformat :month - ts integer "MMMM-yyyy" tformat lowercase :id - ; Add to articles - content date %date @content - content ARTICLES append @ARTICLES - (ARCHIVES code dhas?) - ( - ; Add article to existing archive - content ("id" "title" "timestamp" "date") dpick :article - ARCHIVES code dget :archivedata - archivedata /articles :articles - article articles append @articles - archivedata articles %articles :archivedata - ARCHIVES archivedata code dset @ARCHIVES - ) + (content 'timestamp dhas?) ( - ; Create new monthly archive - content ("id" "title" "timestamp" "date") dpick :article - {} - month %month - code %code - article quote %articles - id %id - :archive - ARCHIVES archive code dset @ARCHIVES - ) if - ) when - content -) ^process-timestamp + content /timestamp :ts + ts to-date :date + ts integer "yyyyMM" tformat :code + ts integer "MMMM yyyy" tformat :month + ts integer "MMMM-yyyy" tformat lowercase :id + ; Add to articles + content date %date @content + content ARTICLES append @ARTICLES + (ARCHIVES code dhas?) + ( + ; Add article to existing archive + content ("id" "title" "timestamp" "date") dpick :article + ARCHIVES code dget :archivedata + archivedata /articles :articles + article articles append @articles + archivedata articles %articles :archivedata + ARCHIVES archivedata code dset @ARCHIVES + ) + ( + ; Create new monthly archive + content ("id" "title" "timestamp" "date") dpick :article + {} + month %month + code %code + article quote %articles + id %id + :archive + ARCHIVES archive code dset @ARCHIVES + ) if + ) when + content @result + ) +) :: +;; Group articles by month +( + symbol copy-pdf-article-asset + (dict :asset ==>) + ( + asset /id :id + id "^pdf\/(.+)$" search 1 get :name + asset "output/articles/$1/$1" (name) => % %id @asset + asset output-cp + ) +) :: ; Copy PDF files saved in asset folder ; to the corresponding article output folder. -( - (dict) expect -> :asset - asset /id :id - id "^pdf\/(.+)$" search 1 get :name - asset "output/articles/$1/$1" (name) => % %id @asset - asset output-cp -) ^copy-pdf-article-asset ; Syntax highlighting (@@ -193,73 +199,85 @@ ) replace-apply @result
) ) :: -; Process a content file applying the appropriate template -; and compiling markdown to HTML if necessary. ( - (dict) expect -> :content - content /id :id - content /content-type :ct - "page" :tpl - (ct "article" ==) ("article" @tpl) when - (ct "project" ==) ("project" @tpl) when - (id "index" ==) (content @HOME "home" @tpl) when - "" :page - "" :contents - content input-fread @contents - (content /ext ".md" ==) (contents content markdown @contents) when - content contents %contents @content - tpl content mustache @page - id page process-icons @page - id page process-code @page - content page %contents @content + symbol process-content + (dict :content ==> dict :result) ( - ((id "^(glyph|ruby-compendium)(\/|\\\\)book" match?) ()) ;Do not add index.html due to the way book internal links work. - ((id "index" !=)( - content - "$1/index" (id) =% %id - ".html" %ext - ; ID must be preserved for links on home page. - id %rawid - @content - )) - ) case - content -) ^process-content + content /id :id + content /content-type :ct + "page" :tpl + (ct "article" ==) ("article" @tpl) when + (ct "project" ==) ("project" @tpl) when + (id "index" ==) (content @HOME "home" @tpl) when + "" :page + "" :contents + content input-fread @contents + (content /ext ".md" ==) (contents content markdown @contents) when + content contents %contents @content + tpl content mustache @page + id page process-icons @page + id page process-code @page + content page %contents @content + ( + ((id "^(glyph|ruby-compendium)(\/|\\\\)book" match?) ()) ;Do not add index.html due to the way book internal links work. + ((id "index" !=)( + content + "$1/index" (id) =% %id + ".html" %ext + ; ID must be preserved for links on home page. + id %rawid + @content + )) + ) case + content @result + ) +) :: +;; Process a content file applying the appropriate template +;; and compiling markdown to HTML if necessary. + -; Process and generate home page ( - ; Sort articles by timestamp - ARTICLES (/timestamp swap /timestamp >) sort @ARTICLES - ARTICLES first :latest - ARTICLES 1 5 slice :recents - ; Process summary - latest input-fread "(?ms)(.+)?<hr" search 1 get latest markdown :summary - latest summary %summary @latest - latest dup /timestamp to-date %date @latest - HOME - latest %latest - recents %recents - projects-count %projects-count - articles-count %articles-count - grimoire-count %grimoire-count - ;tags %tags - dup "home" swap mustache :page - "home" page process-icons - %contents - output-fwrite -) ^generate-home + symbol generate-home + (==>) + ( + ; Sort articles by timestamp + ARTICLES (/timestamp swap /timestamp >) sort @ARTICLES + ARTICLES first :latest + ARTICLES 1 5 slice :recents + ; Process summary + latest input-fread "(?ms)(.+)?<hr" search 1 get latest markdown :summary + latest summary %summary @latest + latest dup /timestamp to-date %date @latest + HOME + latest %latest + recents %recents + projects-count %projects-count + articles-count %articles-count + grimoire-count %grimoire-count + ;tags %tags + dup "home" swap mustache :page + "home" page process-icons + %contents + output-fwrite + ) +) :: +;; Process and generate home page + -;; Pre-process CSS assets ( - (dict) expect -> :meta - "" :contents - meta ( - (input-fread @contents meta) - (:temp contents @contents temp) - (contents %contents) - ) tap - output-fwrite -) ^process-css-asset + symbol process-css-asset + (dict :meta ==>) + ( + "" :contents + meta ( + (input-fread @contents meta) + (:temp contents @contents temp) + (contents %contents) + ) tap + output-fwrite + ) +) :: +;; Process CSS assets ;;;;; MAIN ;;;;;