diff --git a/users/sterni/blërg/README.md b/users/sterni/blërg/README.md index 70c286efc..552543c71 100644 --- a/users/sterni/blërg/README.md +++ b/users/sterni/blërg/README.md @@ -5,13 +5,21 @@ - [CBQN][] (other [BQN][] implementations may work, but are untested) - Marshall Lochbaum's [bqn-libs][] which blërg expects to find at the location the `BQN_LIBS` environment variable points to. -- //users/sterni/mn2html -- [mblaze(7)][mblaze] - [execline][] - POSIX `printf(1)` (e.g. from GNU coreutils) +- `mail-notes` backend + - //users/sterni/mn2html + - [mblaze(7)][mblaze] +- `git` backend + - [git][] + - [lowdown][] for Markdown support + - [pandoc][] for Org Mode support [mblaze]: https://github.com/leahneukirchen/mblaze/ [execline]: https://skarnet.org/software/execline/ [BQN]: https://mlochbaum.github.io/BQN/ [CBQN]: https://github.com/dzaima/cbqn [bqn-libs]: https://github.com/mlochbaum/bqn-libs/ +[lowdown]: https://kristaps.bsd.lv/lowdown/ +[pandoc]: https://pandoc.org/ +[git]: https://git-scm.com/ diff --git a/users/sterni/blërg/blërg.bqn b/users/sterni/blërg/blërg.bqn index 593b3e29c..6b251cb75 100755 --- a/users/sterni/blërg/blërg.bqn +++ b/users/sterni/blërg/blërg.bqn @@ -42,6 +42,7 @@ LR ← Lines∘R GetEnv ← {R "importas"‿"env"‿𝕩‿"printf"‿"%s"‿"$env"} RelPath ← •wdpath⊸•file.At +Ext ← '.'⊸(⊑∘1⊸↑∘/∘(=∧∊∘⊢)↑⊢)⌾⌽ •file.Name # 3p dependencies @@ -79,27 +80,42 @@ MailNotesBackend ← {𝕊 config: # Git Backend +converters ← ⍉>⟨ +# TODO(sterni): avoid cat +⟨"html", ⋈"cat"⟩, +⟨"md", "lowdown"‿"-T"‿"html"‿"--html-no-skiphtml"‿"--html-no-escapehtml"‿"--html-callout-mdn"⟩, +# TODO(sterni): use emacs +⟨"org", "pandoc"‿"-f"‿"org"‿"-t"‿"html5"⟩, +⟩ + +# TODO(sterni): don't assemble blocks in this ad hoc fashion +# TODO(sterni): pipefail +PipelineCmd ← {"pipeline"⋈⊸∾(' '⊸∾¨𝕨)∾""⋈⊸∾𝕩} + GitBackend ← {𝕊 config: repo ← RelPath •file.At config j.ObjGet "repository" path ← ∾⟜'/' '/' StripRight config "." j._ObjGetDef "path" # We use zero separated fields when dealing with paths, so quoting is unnecessary - Git ← {R "git"‿"-c"‿"core.quotePath=false"‿"-C"‿repo∾𝕩} - rev ← Git "rev-parse"‿"HEAD" + GitCmd ← {"git"‿"-c"‿"core.quotePath=false"‿"-C"‿repo∾𝕩} + rev ← R GitCmd "rev-parse"‿"HEAD" # Use the author date of the latest commit on the file to establish the date # of the file. The author date is easier to arbitrarily change and survives # history rewrites. It could be interesting to ignore commits that touch # multiple files (especially treewide ones). - PathDate ← {ReadPosDec Git "log"‿"--date=unix"‿"--pretty=tformat:%ad"‿"-1"‿rev‿"--"‿𝕩} + PathDate ← {ReadPosDec R GitCmd "log"‿"--date=unix"‿"--pretty=tformat:%ad"‿"-1"‿rev‿"--"‿𝕩} Entries ⇐ {𝕤⋄ - blobs ← ∘‿2⥊@ SplitChar Git "ls-tree"‿"-zr"‿"--format=%(path)%x00%(objectname)"‿rev‿path + blobs ← ∘‿2⥊@ SplitChar R GitCmd "ls-tree"‿"-zr"‿"--format=%(path)%x00%(objectname)"‿rev‿path {𝕊 p‿b: id ⇐ Slugify path DropPrefix p # TODO(sterni): extract from file if possible title ⇐ •file.Name p time ⇐ PathDate p - Render ⇐ {𝕤 ⋄ {"
"∾𝕩∾""} Git "cat-file"‿"blob"‿b} + Render ⇐ {𝕤 + conv ← converters j.ObjGet Ext p + R (GitCmd "cat-file"‿"blob"‿b) PipelineCmd conv + } }˘blobs } } diff --git a/users/sterni/blërg/default.nix b/users/sterni/blërg/default.nix index 688253a0f..0dacf5e15 100644 --- a/users/sterni/blërg/default.nix +++ b/users/sterni/blërg/default.nix @@ -5,8 +5,10 @@ let runtimeDependencies = [ depot.users.sterni.mn2html pkgs.mblaze - pkgs.execline # execline-cd, importas + pkgs.execline # execline-cd, importas, pipeline # coreutils # for printf (assumed to be installed) + pkgs.pandoc + pkgs.lowdown ]; # … and this