all repos — h3rald @ 24011ccd253bd167d03d60815a66ff2a398b6ca0

The sources of https://h3rald.com

Updated to latest hastysite
h3rald h3rald@h3rald.com
Mon, 15 Mar 2021 19:41:50 +0100
commit

24011ccd253bd167d03d60815a66ff2a398b6ca0

parent

58466a8cc01308bf1dee92312c71f467d2a435f7

6 files changed, 85 insertions(+), 85 deletions(-)

jump to
M rules.minrules.min

@@ -1,18 +1,18 @@

'hastysite import -{} =TAGS -{} =TAG-COLUMNS -{} =ARCHIVES -() =ARCHIVE-COLUMNS -() =ARTICLES -{} =HOME -() =PROJECTS +{} :TAGS +{} :TAG-COLUMNS +{} :ARCHIVES +() :ARCHIVE-COLUMNS +() :ARTICLES +{} :HOME +() :PROJECTS ; Utility operator to format a timestamp into a date ( - int "dddd, d MMMM yyyy" tformat -) :to-date + integer "dddd, d MMMM yyyy" tformat +) ^to-date ; Create the Archives page.

@@ -28,7 +28,7 @@ ;ARCHIVE-COLUMNS %archive-columns

dup "_archives" swap mustache %contents dup "page" swap mustache %contents output-fwrite -) :create-archives-page +) ^create-archives-page ; Create the Projects page (

@@ -42,31 +42,31 @@ PROJECTS ('active dhas?) filter (/id swap /id <) sort %active-projects

PROJECTS ('active dhas? not) filter (/id swap /id <) sort %inactive-projects dup "projects" swap mustache %contents output-fwrite -) :create-projects-page +) ^create-projects-page 0 :count ;.... ; Group articles by month ( - (dict) expect -> =content + (dict) expect -> :content (content 'timestamp dhas?) ( content /timestamp :ts ts to-date :date - ts int "yyyyMM" tformat :code - ts int "MMMM yyyy" tformat :month - ts int "MMMM-yyyy" tformat lowercase :id + 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 + 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 + article articles append @articles archivedata articles %articles :archivedata ARCHIVES archivedata code dset @ARCHIVES )

@@ -74,92 +74,92 @@ (

; Create new monthly archive content ("id" "title" "timestamp" "date") dpick :article {} - month %month - code %code - article ' %articles - id %id + month %month + code %code + article quote %articles + id %id :archive ARCHIVES archive code dset @ARCHIVES ) if ) when content -) :process-timestamp +) ^process-timestamp ; Group articles by tags ( - (dict) expect -> =content - ((content 'tags dhas?) (content /tags "" !=) dequote-and) + (dict) expect -> :content + (((content 'tags dhas?) (content /tags "" !=)) &&) ( - content /tags "|" split =tags + content /tags "\|" split :tags tags ( :tag (TAGS tag dhas?) ( ; Add article to existing tag - content ("id" "title" "timestamp") dpick =article - TAGS tag dget =tagdata - article tagdata append #tagdata - TAGS tagdata tag dset #TAGS + content ("id" "title" "timestamp") dpick :article + TAGS tag dget :tagdata + article tagdata append @tagdata + TAGS tagdata tag dset @TAGS ) ( ; Create new tag - content ("id" "title" "timestamp") dpick ' =article - TAGS article ' tag dset #TAGS + content ("id" "title" "timestamp") dpick :article + TAGS article quote tag dset @TAGS ) if ) foreach ) when content -) :process-tags +) ^process-tags ; Copy PDF files saved in asset folder ; to the corresponding article output folder. ( - (dict) expect -> =asset + (dict) expect -> :asset asset /id :id id "^pdf\/(.+)$" search 1 get :name - asset "output/articles/$1/$1" (name) => % %id #asset + asset "output/articles/$1/$1" (name) => % %id @asset asset output-cp -) :copy-pdf-article-asset +) ^copy-pdf-article-asset ; Process a content file applying the appropriate template ; and compiling markdown to HTML if necessary. ( - (dict) expect -> =content + (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 + (id "index" ==) (content @HOME "home" @tpl) when "" :page "" :contents content ( (input-fread @contents content) - ((/ext ".md" ==) (=temp contents temp markdown @contents temp) when) + ((/ext ".md" ==) (:temp contents temp markdown @contents temp) when) (contents %contents) - (=temp tpl temp mustache @page temp) + (:temp tpl temp mustache @page temp) (page %contents) (( - ((id "^(glyph|ruby-compendium)\/book" match) ()) ;Do not add index.html + ((id "^(glyph|ruby-compendium)\/book" match?) ()) ;Do not add index.html ((id "index" !=)("$1/index" (id) => % %id ".html" %ext)) ) case) ) tap -) :process-content +) ^process-content ; Process and generate home page ( ; Sort articles by timestamp - ARTICLES (/timestamp swap /timestamp >) sort #ARTICLES - ARTICLES first =latest - ARTICLES 1 5 slice =recents + ARTICLES (/timestamp swap /timestamp >) sort @ARTICLES + ARTICLES first :latest + ARTICLES 1 5 slice :recents ; Process summary - latest input-fread "/(.+)?<hr/ms" regex 1 get latest markdown :summary - latest summary %summary #latest - latest dup /timestamp to-date %date #latest + latest input-fread "(?ms)(.+)?<hr" search 1 get latest markdown :summary + latest summary %summary @latest + latest dup /timestamp to-date %date @latest ; Process top tags TAGS dkeys ( :tag

@@ -169,44 +169,44 @@ ) map

(last swap last >) sort 0 9 slice ( - =data + :data {} data first %tag data last %total ) map - =tags + :tags HOME ( (latest %latest) (recents %recents) (tags %tags) - (=temp temp "home" temp mustache %contents) + (:temp temp "home" temp mustache %contents) (output-fwrite) ) tap! -) :generate-home +) ^generate-home ;; Pre-process CSS assets ( - (dict) expect -> =meta + (dict) expect -> :meta "" :contents meta ( (input-fread @contents meta) - (=temp contents preprocess-css @contents temp) + (:temp contents preprocess-css @contents temp) (contents %contents) ) tap output-fwrite -) :process-css-asset +) ^process-css-asset ;;;;; MAIN ;;;;; ; Process all contents contents ( - =content - ((content 'draft dhas? not) (content 'content-type dhas?) dequote-and) + :content + (((content 'draft dhas? not) (content 'content-type dhas?)) &&) ( content /id :id content - (/content-type "project" ==) (content PROJECTS append #PROJECTS content) when + (/content-type "project" ==) (content PROJECTS append @PROJECTS content) when process-tags process-timestamp process-content

@@ -227,8 +227,8 @@ ; Process all assets.

assets ( dup ( - ((/id "^pdf\/" match) (copy-pdf-article-asset)) - ((/ext ".css" match) (process-css-asset)) + ((/id "^pdf\/" match?) (copy-pdf-article-asset)) + ((/ext ".css" match?) (process-css-asset)) ((true) (output-cp)) ) case ) foreach
M scripts/article.minscripts/article.min

@@ -6,12 +6,12 @@ timestamp :ts

false :valid-id ( - (string) expect first :ident - ident "^[a-z0-9-]+$" match :valid-regexp - (. "contents" "articles") => "/" join ls =filelist + (str) expect first :ident + ident "^[a-z0-9-]+$" match? :valid-regexp + (. "contents" "articles") => "/" join ls :filelist filelist (filename "(.+)\..+$" search 1 get) map ident in? not :valid-file valid-regexp valid-file and -) :validate +) ^validate (valid-id not) (

@@ -34,7 +34,7 @@

<hr /> " (ident title subtitle ts) => % :metadata -metadata puts +metadata puts! ("Create article?" confirm) ( (ident ".md") => "" join :fn
M scripts/build.minscripts/build.min

@@ -1,10 +1,10 @@

;Builds a site by processing contents and assets. 'hastysite import -"Preprocessing..." notice +"Preprocessing..." notice! preprocess -"Processing rules.." notice +"Processing rules.." notice! process-rules -"Postprocessing..." notice +"Postprocessing..." notice! postprocess -"All done." notice +"All done." notice!
M scripts/clean.minscripts/clean.min

@@ -1,8 +1,8 @@

;Deletes all temporary and output files. 'hastysite import -"Cleaning temporary folder..." notice +"Cleaning temporary folder..." notice! clean-temp -"Cleaning output folder..." notice +"Cleaning output folder..." notice! clean-output -"All done." notice +"All done." notice!
M scripts/index.minscripts/index.min

@@ -1,7 +1,7 @@

;Re-index articles 'hastysite import -"Indexing articles..." notice +"Indexing articles..." notice! . :pwd (. "data.db") => "/" join :store

@@ -10,13 +10,13 @@ (. "output") => "/" join cd

(store file?) ( - "Deleting search index..." notice + "Deleting search index..." notice! store rm ) when -"Importing data..." notice -"litestore -s:$1 -d:articles import" (store) => % ! +"Importing data..." notice! +"litestore -s:$1 -d:articles import" (store) =% ! pwd cd -"All done." notice +"All done." notice!
M scripts/project.minscripts/project.min

@@ -8,18 +8,18 @@ "" :release

false :valid-id ( - (string) expect first :ident - ident "^[a-z0-9-]+$" match :valid-regexp - (. "contents") => "/" join ls =filelist + (str) expect first :ident + ident "^[a-z0-9-]+$" match? :valid-regexp + (. "contents") => "/" join ls :filelist filelist (filename "(.+)\..+$" search 1 get) map ident in? not :valid-file valid-regexp valid-file and -) :validate +) ^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 + (valid-id not) ("ID must not be already used and it must contain only lowercase letters, numbers, or -" warn!) when ) while "Title" ask @title

@@ -39,9 +39,9 @@ active: true

version: $5 download: \"https://github.com/h3rald/$1/releases/download/\" ----- -" (ident title subtitle summary release) => % :metadata +" (ident title subtitle summary release) =% :metadata -metadata puts +metadata puts! ("Create project?" confirm) ( (ident ".md") => "" join :fn