diff --git a/.gitignore b/.gitignore index af1da56..e2f5dd2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -result/ \ No newline at end of file +result \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..1ff03f0 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Teapot + +because doll. it uses [markdoll](https://codeberg.org/0x57e11a/markdoll). diff --git a/examples/quickstart/index.doll b/examples/quickstart/index.doll index b5bfde9..85d4a5a 100644 --- a/examples/quickstart/index.doll +++ b/examples/quickstart/index.doll @@ -5,7 +5,7 @@ layout: alt.html this is markdoll! -&so it is really gay to use other doll's software right? +&so it is really gay to use other doll's software right?? yeah......... &look at this diff --git a/pkgs/brewTea.nix b/pkgs/brewTea.nix index 40b06da..21f6268 100644 --- a/pkgs/brewTea.nix +++ b/pkgs/brewTea.nix @@ -19,13 +19,16 @@ in pkgs.stdenvNoCC.mkDerivation { buildPhase = '' mkdir dist - layout_inject() { - layoutFile=$1 - placeholder=$2 - content=$3 + echoerr() { cat <<< "$@" 1>&2; } - layout=$(cat $layoutFile) - echo ''${layout/"$placeholder"/"$content"} + layout_inject() { + local layoutFile=$1 + local placeholder=$2 + local contentFile=$3 + + local layout=$(cat $layoutFile) + local content=$(cat $contentFile) + echo "''${layout/"$placeholder"/"$content"}" } get_frontmatter() { @@ -37,33 +40,35 @@ in pkgs.stdenvNoCC.mkDerivation { } render_final() { - file=$1 - content=$2 - outFile=$3 + local file=$1 + local outFile=$2 + local content=$3 ### Frontmatter: Get Layout - layout="${defaultLayout}" - layoutFm=$(get_frontmatter layout $file) + local layout="${defaultLayout}" + local layoutFm=$(get_frontmatter layout $file) if [ ! -z $layoutFm ]; then layout="$layoutFm" fi - - layoutPath="${layoutSrc}/$layout" + + local layoutPath="$layout" if [ ! -f $layoutPath ]; then - echo "Layout file $layout not found" - exit 1 + layoutPath="${layoutSrc}/$layout" + if [ ! -f $layoutPath ]; then + echo "Layout file $layout not found" + exit 1 + fi fi ### Frontmatter: Title - title=$(get_frontmatter title $file) + local title=$(get_frontmatter title $file) if [ -z $title ]; then title=$(basename $file | sed -e 's/.doll$//') fi ### Layout: Title + Content - mkdir -p $(dirname $outFile) - layout_inject $layoutPath %%TITLE%% "$title" > $outFile.tmp.1 - layout_inject $outFile.tmp.1 %%CONTENT%% "$content" > $outFile.tmp.final + layout_inject $layoutPath %%TITLE%% <<<"$title" > $outFile.tmp.1 + layout_inject $outFile.tmp.1 %%CONTENT%% $content > $outFile.tmp.final ### Layout: Cleanup Tmpfiles cp $outFile.tmp.final $outFile @@ -76,12 +81,14 @@ in pkgs.stdenvNoCC.mkDerivation { for file in $dollFiles; do outFile=$(realpath -m "dist/$(echo $file | sed -e 's/.doll$/.html/')") + mkdir -p $(dirname $outFile) + echo "reading $file; plopping $outFile" ### Markdoll: Convert - content=$(cat $file | ${markdoll} convert) + local content=$(cat $file | ${markdoll} convert | tee $outFile.tmp.render) - render_final $file $content $outFile + render_final $file $outFile $outFile.tmp.render done '';