working this time
This commit is contained in:
parent
4d1663e588
commit
9aad36f910
4 changed files with 33 additions and 23 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1 @@
|
||||||
result/
|
result
|
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Teapot
|
||||||
|
|
||||||
|
because doll. it uses [markdoll](https://codeberg.org/0x57e11a/markdoll).
|
|
@ -5,7 +5,7 @@ layout: alt.html
|
||||||
|
|
||||||
this is markdoll!
|
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.........
|
yeah.........
|
||||||
|
|
||||||
&look at this
|
&look at this
|
||||||
|
|
|
@ -19,13 +19,16 @@ in pkgs.stdenvNoCC.mkDerivation {
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
mkdir dist
|
mkdir dist
|
||||||
|
|
||||||
layout_inject() {
|
echoerr() { cat <<< "$@" 1>&2; }
|
||||||
layoutFile=$1
|
|
||||||
placeholder=$2
|
|
||||||
content=$3
|
|
||||||
|
|
||||||
layout=$(cat $layoutFile)
|
layout_inject() {
|
||||||
echo ''${layout/"$placeholder"/"$content"}
|
local layoutFile=$1
|
||||||
|
local placeholder=$2
|
||||||
|
local contentFile=$3
|
||||||
|
|
||||||
|
local layout=$(cat $layoutFile)
|
||||||
|
local content=$(cat $contentFile)
|
||||||
|
echo "''${layout/"$placeholder"/"$content"}"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_frontmatter() {
|
get_frontmatter() {
|
||||||
|
@ -37,33 +40,35 @@ in pkgs.stdenvNoCC.mkDerivation {
|
||||||
}
|
}
|
||||||
|
|
||||||
render_final() {
|
render_final() {
|
||||||
file=$1
|
local file=$1
|
||||||
content=$2
|
local outFile=$2
|
||||||
outFile=$3
|
local content=$3
|
||||||
|
|
||||||
### Frontmatter: Get Layout
|
### Frontmatter: Get Layout
|
||||||
layout="${defaultLayout}"
|
local layout="${defaultLayout}"
|
||||||
layoutFm=$(get_frontmatter layout $file)
|
local layoutFm=$(get_frontmatter layout $file)
|
||||||
if [ ! -z $layoutFm ]; then
|
if [ ! -z $layoutFm ]; then
|
||||||
layout="$layoutFm"
|
layout="$layoutFm"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
layoutPath="${layoutSrc}/$layout"
|
local layoutPath="$layout"
|
||||||
if [ ! -f $layoutPath ]; then
|
if [ ! -f $layoutPath ]; then
|
||||||
echo "Layout file $layout not found"
|
layoutPath="${layoutSrc}/$layout"
|
||||||
exit 1
|
if [ ! -f $layoutPath ]; then
|
||||||
|
echo "Layout file $layout not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### Frontmatter: Title
|
### Frontmatter: Title
|
||||||
title=$(get_frontmatter title $file)
|
local title=$(get_frontmatter title $file)
|
||||||
if [ -z $title ]; then
|
if [ -z $title ]; then
|
||||||
title=$(basename $file | sed -e 's/.doll$//')
|
title=$(basename $file | sed -e 's/.doll$//')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### Layout: Title + Content
|
### Layout: Title + Content
|
||||||
mkdir -p $(dirname $outFile)
|
layout_inject $layoutPath %%TITLE%% <<<"$title" > $outFile.tmp.1
|
||||||
layout_inject $layoutPath %%TITLE%% "$title" > $outFile.tmp.1
|
layout_inject $outFile.tmp.1 %%CONTENT%% $content > $outFile.tmp.final
|
||||||
layout_inject $outFile.tmp.1 %%CONTENT%% "$content" > $outFile.tmp.final
|
|
||||||
|
|
||||||
### Layout: Cleanup Tmpfiles
|
### Layout: Cleanup Tmpfiles
|
||||||
cp $outFile.tmp.final $outFile
|
cp $outFile.tmp.final $outFile
|
||||||
|
@ -76,12 +81,14 @@ in pkgs.stdenvNoCC.mkDerivation {
|
||||||
|
|
||||||
for file in $dollFiles; do
|
for file in $dollFiles; do
|
||||||
outFile=$(realpath -m "dist/$(echo $file | sed -e 's/.doll$/.html/')")
|
outFile=$(realpath -m "dist/$(echo $file | sed -e 's/.doll$/.html/')")
|
||||||
|
mkdir -p $(dirname $outFile)
|
||||||
|
|
||||||
echo "reading $file; plopping $outFile"
|
echo "reading $file; plopping $outFile"
|
||||||
|
|
||||||
### Markdoll: Convert
|
### 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
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue