From 4ee5913bd0b3347d3a129f3bf853747c6724724c Mon Sep 17 00:00:00 2001 From: noe Date: Tue, 22 Apr 2025 11:18:59 -0700 Subject: [PATCH] plugin support --- examples/plugins/plural.sh | 14 ++++++++++++++ examples/quickstart/default.nix | 9 ++++++++- examples/quickstart/pluginTests.doll | 7 +++++++ examples/quickstart/plugins/inline-example.sh | 13 +++++++++++++ flake.lock | 8 ++++---- pkgs/brewTea.nix | 5 ++++- pkgs/mkMarkdollPlugin.nix | 14 ++++++++------ 7 files changed, 58 insertions(+), 12 deletions(-) create mode 100755 examples/plugins/plural.sh create mode 100644 examples/quickstart/pluginTests.doll create mode 100755 examples/quickstart/plugins/inline-example.sh diff --git a/examples/plugins/plural.sh b/examples/plugins/plural.sh new file mode 100755 index 0000000..4b33135 --- /dev/null +++ b/examples/plugins/plural.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +alterName=$1 + +cat << EOF +
+ + ${alterName}@41666$>  + + + $(<"/dev/stdin") + +
+EOF \ No newline at end of file diff --git a/examples/quickstart/default.nix b/examples/quickstart/default.nix index 61bb390..ba559ec 100644 --- a/examples/quickstart/default.nix +++ b/examples/quickstart/default.nix @@ -1,4 +1,4 @@ -{ pkgs, brewTea, ... }: brewTea { +{ pkgs, brewTea, mkMarkdollPlugin }: brewTea { name = "examples_quickstart"; version = "0.0.0"; @@ -7,4 +7,11 @@ # maybe don't do this but its possible to reference _any file_. defaultLayout = ./layouts/default.html; + + # these are mostly for alias purposes... + # can do an [invoke(plural)(...):yay!] type thing + # one can invoke stuff inline too without doing this. + markdollPlugins = [ + (mkMarkdollPlugin "plural" ../plugins/plural.sh) + ]; } \ No newline at end of file diff --git a/examples/quickstart/pluginTests.doll b/examples/quickstart/pluginTests.doll new file mode 100644 index 0000000..e270d45 --- /dev/null +++ b/examples/quickstart/pluginTests.doll @@ -0,0 +1,7 @@ +--- +title: plugin tests +--- + +&plural plugin + [invoke(plural)(aki):hi this one is aki] + [invoke(plural)(noe):hi this one is noe] \ No newline at end of file diff --git a/examples/quickstart/plugins/inline-example.sh b/examples/quickstart/plugins/inline-example.sh new file mode 100755 index 0000000..896824c --- /dev/null +++ b/examples/quickstart/plugins/inline-example.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +flip() { + LC_ALL=C LC_ALL=en_US.UTF-8 rev <"/dev/stdin" +} + +main() { + case $1 in + flip) flip;; + esac +} + +main $1 \ No newline at end of file diff --git a/flake.lock b/flake.lock index 19229e1..5938811 100644 --- a/flake.lock +++ b/flake.lock @@ -59,11 +59,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1745093370, - "narHash": "sha256-M4Nal2SQ9hW08VVjgV80V5KqC3W/8flsc9hUluIYdYM=", + "lastModified": 1745344651, + "narHash": "sha256-5hCu3usWVtVPh5WrN7uCu1Kr3rU26/jxD68l9ZhmEfs=", "ref": "refs/heads/main", - "rev": "fb42921ee9a4592b5f055a4e8c4fe244275e4fef", - "revCount": 79, + "rev": "bd5f16268020b438e9022ddfe555431d3efe891b", + "revCount": 81, "type": "git", "url": "https://codeberg.org/0x57e11a/markdoll.git" }, diff --git a/pkgs/brewTea.nix b/pkgs/brewTea.nix index 654abf1..37a3e6c 100644 --- a/pkgs/brewTea.nix +++ b/pkgs/brewTea.nix @@ -4,7 +4,9 @@ version, # TODO: do not require flakes - markdollParser ? inputs.markdoll.packages.${pkgs.system}.markdoll, + markdollParser ? inputs.markdoll.packages.${pkgs.system}.markdoll.override({ + danger = true; + }), markdollPlugins ? [], src, @@ -17,6 +19,7 @@ in pkgs.stdenvNoCC.mkDerivation { inherit name version src; buildPhase = '' + export PATH="$PATH:${pkgs.lib.makeBinPath markdollPlugins}" mkdir dist echoerr() { cat <<< "$@" 1>&2; } diff --git a/pkgs/mkMarkdollPlugin.nix b/pkgs/mkMarkdollPlugin.nix index b2da8d1..32a3483 100644 --- a/pkgs/mkMarkdollPlugin.nix +++ b/pkgs/mkMarkdollPlugin.nix @@ -1,7 +1,9 @@ -{ pkgs }: binPath: pkgs.stdenvNoCC.mkDerivation { - src = binPath; - buildPhase = '' - mkdir -p $out - cp $src $out/plugin - ''; +{ pkgs }: name: src: pkgs.stdenvNoCC.mkDerivation { + inherit name src; + version = "0.0.0"; + dontUnpack = true; + installPhase = " + mkdir -p $out/bin + cp $src $out/bin/${name} + "; } \ No newline at end of file