error handling!!
This commit is contained in:
parent
a17d82f996
commit
a4faf2f38c
6 changed files with 53 additions and 13 deletions
|
@ -8,11 +8,25 @@
|
||||||
# maybe don't do this but its possible to reference _any file_.
|
# maybe don't do this but its possible to reference _any file_.
|
||||||
defaultLayout = ./layouts/default.html;
|
defaultLayout = ./layouts/default.html;
|
||||||
|
|
||||||
# these are mostly for alias purposes...
|
markdollPlugins = let
|
||||||
# can do an [invoke(plural)(...):yay!] type thing
|
sPoNgEbOb = pkgs.buildGoModule {
|
||||||
# one can invoke stuff inline too without doing this.
|
name = "sPoNgEbOb";
|
||||||
markdollPlugins = [
|
vendorHash = null;
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
repo = "sPoNgEbOb";
|
||||||
|
owner = "yzguy";
|
||||||
|
rev = "9e4bf8e86d5fd7870000832ff571acf13b6941eb";
|
||||||
|
hash = "sha256-MWVtW9gzYmx3sOSvPh9NI4h6MotuO1ZQyzC09jpsHJI=";
|
||||||
|
};
|
||||||
|
|
||||||
|
preBuild = ''
|
||||||
|
go mod init github.com/yzguy/sPoNgEbOb
|
||||||
|
'';
|
||||||
|
} + "/bin/sPoNgEbOb";
|
||||||
|
in [
|
||||||
|
# all of these add invoke handlers like [invoke(plural)(argv1):stdin]
|
||||||
(mkMarkdollPlugin "plural" ./plugins/plural.sh)
|
(mkMarkdollPlugin "plural" ./plugins/plural.sh)
|
||||||
((mkMarkdollPlugin "tools" ./plugins/tools.py).override { buildInputs = [ pkgs.python3 ]; })
|
((mkMarkdollPlugin "tools" ./plugins/tools.py).override { buildInputs = [ pkgs.python3 ]; })
|
||||||
|
(mkMarkdollPlugin "sPoNgEbOb" sPoNgEbOb)
|
||||||
];
|
];
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
<!DOCTYPE html public "alt layout">
|
<!DOCTYPE html public "alt layout">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
<title>%%TITLE%% | alt layout</title>
|
<title>%%TITLE%% | alt layout</title>
|
||||||
%%HEAD%%
|
%%HEAD%%
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<!DOCTYPE html public "default layout">
|
<!DOCTYPE html public "default layout">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
<title>%%TITLE%% | default layout</title>
|
<title>%%TITLE%% | default layout</title>
|
||||||
%%HEAD%%
|
%%HEAD%%
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -3,10 +3,24 @@ title: plugin tests
|
||||||
---
|
---
|
||||||
|
|
||||||
&plural plugin
|
&plural plugin
|
||||||
[invoke(plural)(aki):hi this one is aki]
|
& referenced via $PATH
|
||||||
|
noe1: [invoke(plural)(aki):hi this one is aki]
|
||||||
|
|
||||||
|
aki1: [invoke(plural)(noe):hi this one is noe]
|
||||||
|
|
||||||
[invoke(plural)(noe):hi this one is noe]
|
& referenced via ./plugins/plural.sh
|
||||||
|
aki2: [invoke(./plugins/plural.sh)(aki):hi this one is aki]
|
||||||
|
|
||||||
hellorld [invoke(tools)(flip):hellorld]
|
noe2: [invoke(./plugins/plural.sh)(noe):hi this one is noe]
|
||||||
|
|
||||||
dolldolldoll|llodllodllod [invoke(tools)(flip):dolldolldoll|llodllodllod]
|
&python plugin (flip)
|
||||||
|
hellorld
|
||||||
|
[invoke(tools)(flip):hellorld]
|
||||||
|
|
||||||
|
dolldolldoll|llodllodllod
|
||||||
|
[invoke(tools)(flip):dolldolldoll|llodllodllod]
|
||||||
|
|
||||||
|
&go plugin
|
||||||
|
fights 41666's witch
|
||||||
|
|
||||||
|
[invoke(sPoNgEbOb):fights 41666's witch]
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
alterName=$1
|
alterName=$1
|
||||||
message=$(<"/dev/stdin")
|
message=$(cat /dev/stdin)
|
||||||
|
|
||||||
cat << EOF
|
cat << EOF
|
||||||
<div class="alter alter-${alterName}">
|
<div class="alter alter-${alterName}">
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
layoutSrc,
|
layoutSrc,
|
||||||
# otherwise set by frontmatter
|
# otherwise set by frontmatter
|
||||||
defaultLayout ? "default.html",
|
defaultLayout ? "default.html",
|
||||||
|
|
||||||
|
allowFailedRenders ? true,
|
||||||
}: let
|
}: let
|
||||||
markdoll = "${markdollParser}/bin/markdoll";
|
markdoll = "${markdollParser}/bin/markdoll";
|
||||||
in pkgs.stdenvNoCC.mkDerivation {
|
in pkgs.stdenvNoCC.mkDerivation {
|
||||||
|
@ -72,15 +74,15 @@ in pkgs.stdenvNoCC.mkDerivation {
|
||||||
### Frontmatter: Meta Head Stuff
|
### Frontmatter: Meta Head Stuff
|
||||||
local head=""
|
local head=""
|
||||||
local meta_description=$(get_frontmatter description $file)
|
local meta_description=$(get_frontmatter description $file)
|
||||||
if [ ! -z meta_description ]; then
|
if [ ! -z "$meta_description" ]; then
|
||||||
head="$head<meta name='description' content='$meta_description'>"
|
head="$head<meta name='description' content='$meta_description'>"
|
||||||
fi
|
fi
|
||||||
local meta_tags=$(get_frontmatter tags $file)
|
local meta_tags=$(get_frontmatter tags $file)
|
||||||
if [ ! -z meta_tags ]; then
|
if [ ! -z "$meta_tags" ]; then
|
||||||
head="$head<meta name='keywords' content='$meta_tags'>"
|
head="$head<meta name='keywords' content='$meta_tags'>"
|
||||||
fi
|
fi
|
||||||
local meta_author=$(get_frontmatter author $file)
|
local meta_author=$(get_frontmatter author $file)
|
||||||
if [ ! -z meta_author ]; then
|
if [ ! -z "$meta_author" ]; then
|
||||||
head="$head<meta name='author' content='$meta_author'>"
|
head="$head<meta name='author' content='$meta_author'>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -105,8 +107,16 @@ in pkgs.stdenvNoCC.mkDerivation {
|
||||||
echo "reading $file; plopping $outFile"
|
echo "reading $file; plopping $outFile"
|
||||||
|
|
||||||
### Markdoll: Convert
|
### Markdoll: Convert
|
||||||
local content=$(cat $file | ${markdoll} convert | tee $outFile.tmp.render)
|
local content=$(cat $file | ${markdoll} convert 2>$outFile.tmp.convert-log | tee $outFile.tmp.render)
|
||||||
|
|
||||||
|
if [ -z "$content" ]; then
|
||||||
|
echo "<pre style='padding: 1em; border: 1px solid red; width: fit-content;'>" >> $outFile.tmp.render
|
||||||
|
echo "<b style='color: red;'>[teapot]: render failed, check build logs.</b>" >> $outFile.tmp.render
|
||||||
|
echo "== build log ==" >> $outFile.tmp.render
|
||||||
|
cat $outFile.tmp.convert-log >> $outFile.tmp.render
|
||||||
|
echo "</pre>" >> $outFile.tmp.render
|
||||||
|
fi
|
||||||
|
|
||||||
render_final $file $outFile $outFile.tmp.render
|
render_final $file $outFile $outFile.tmp.render
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Add table
Reference in a new issue