init
This commit is contained in:
commit
4d1663e588
12 changed files with 341 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
result/
|
10
default.nix
Normal file
10
default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
pkgs ? import <nixpkgs> {},
|
||||
inputs ? {},
|
||||
}: rec {
|
||||
default = brewTea;
|
||||
brewTea = import ./pkgs/brewTea.nix { inherit pkgs inputs; };
|
||||
mkMarkdollPlugin = import ./pkgs/mkMarkdollPlugin.nix { inherit pkgs; };
|
||||
|
||||
example_quickstart = import ./examples/quickstart { inherit pkgs brewTea mkMarkdollPlugin; };
|
||||
}
|
1
examples/quickstart/blog/today.doll
Normal file
1
examples/quickstart/blog/today.doll
Normal file
|
@ -0,0 +1 @@
|
|||
&hello world!!
|
7
examples/quickstart/default.nix
Normal file
7
examples/quickstart/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{ pkgs, brewTea, ... }: brewTea {
|
||||
name = "examples_quickstart";
|
||||
version = "0.0.0";
|
||||
|
||||
src = ./.;
|
||||
layoutSrc = ./layouts;
|
||||
}
|
16
examples/quickstart/index.doll
Normal file
16
examples/quickstart/index.doll
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
title: awawa!
|
||||
layout: alt.html
|
||||
---
|
||||
|
||||
this is markdoll!
|
||||
|
||||
&so it is really gay to use other doll's software right?
|
||||
yeah.........
|
||||
|
||||
&look at this
|
||||
[link(/page2.html):there's another page!!!!]
|
||||
|
||||
[img(https://codeberg.org/0x57e11a/markdoll/raw/branch/main/button.png)::
|
||||
alt text goes here (88x31 button that says MADE WITH MARKDOLL)
|
||||
]
|
12
examples/quickstart/layouts/alt.html
Normal file
12
examples/quickstart/layouts/alt.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html public "alt layout">
|
||||
<title>%%TITLE%% | alt layout</title>
|
||||
<style>
|
||||
body {
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<nav>alt layout!!!</nav>
|
||||
<main>%%CONTENT%%</main>
|
||||
</body>
|
6
examples/quickstart/layouts/default.html
Normal file
6
examples/quickstart/layouts/default.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html public "default layout">
|
||||
<title>%%TITLE%% | default layout</title>
|
||||
<body>
|
||||
<nav>default layout!!!</nav>
|
||||
<main>%%CONTENT%%</main>
|
||||
</body>
|
6
examples/quickstart/page2.doll
Normal file
6
examples/quickstart/page2.doll
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
title: AWAWAWA
|
||||
---
|
||||
|
||||
&real awawa shit
|
||||
haha gottem
|
168
flake.lock
generated
Normal file
168
flake.lock
generated
Normal file
|
@ -0,0 +1,168 @@
|
|||
{
|
||||
"nodes": {
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1744386647,
|
||||
"narHash": "sha256-DXwQEJllxpYeVOiSlBhQuGjfvkoGHTtILLYO2FvcyzQ=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "d02c1cdd7ec539699aa44e6ff912e15535969803",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"markdoll": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1745093370,
|
||||
"narHash": "sha256-M4Nal2SQ9hW08VVjgV80V5KqC3W/8flsc9hUluIYdYM=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "fb42921ee9a4592b5f055a4e8c4fe244275e4fef",
|
||||
"revCount": 79,
|
||||
"type": "git",
|
||||
"url": "https://codeberg.org/0x57e11a/markdoll.git"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://codeberg.org/0x57e11a/markdoll.git"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1744536153,
|
||||
"narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1744868846,
|
||||
"narHash": "sha256-5RJTdUHDmj12Qsv7XOhuospjAjATNiTMElplWnJE9Hs=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ebe4301cbd8f81c4f8d3244b3632338bbeb6d49c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"markdoll": "markdoll",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"markdoll",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1744770893,
|
||||
"narHash": "sha256-RMyTyFHN3w8zwfpgvcfRHQ4vX4zTqhuZbif/MXROtx8=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "1633514603fc0ed15ea0aef7327e26736ec003c0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
16
flake.nix
Normal file
16
flake.nix
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
description = "teapot is a static site generator using pure nix";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
markdoll.url = "git+https://codeberg.org/0x57e11a/markdoll.git";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
in {
|
||||
packages = import ./default.nix { inherit pkgs inputs; };
|
||||
});
|
||||
}
|
91
pkgs/brewTea.nix
Normal file
91
pkgs/brewTea.nix
Normal file
|
@ -0,0 +1,91 @@
|
|||
{ pkgs, inputs }:
|
||||
{
|
||||
name,
|
||||
version,
|
||||
|
||||
# TODO: do not require flakes
|
||||
markdollParser ? inputs.markdoll.packages.${pkgs.system}.markdoll,
|
||||
markdollPlugins ? [],
|
||||
src,
|
||||
|
||||
layoutSrc,
|
||||
# otherwise set by frontmatter
|
||||
defaultLayout ? "default.html",
|
||||
}: let
|
||||
markdoll = "${markdollParser}/bin/markdoll";
|
||||
in pkgs.stdenvNoCC.mkDerivation {
|
||||
inherit name version src;
|
||||
|
||||
buildPhase = ''
|
||||
mkdir dist
|
||||
|
||||
layout_inject() {
|
||||
layoutFile=$1
|
||||
placeholder=$2
|
||||
content=$3
|
||||
|
||||
layout=$(cat $layoutFile)
|
||||
echo ''${layout/"$placeholder"/"$content"}
|
||||
}
|
||||
|
||||
get_frontmatter() {
|
||||
key=$1
|
||||
file=$2
|
||||
|
||||
keyLine=$(grep -e "$key: " $file || echo "")
|
||||
sed "s/.*: //" <<<$keyLine | xargs
|
||||
}
|
||||
|
||||
render_final() {
|
||||
file=$1
|
||||
content=$2
|
||||
outFile=$3
|
||||
|
||||
### Frontmatter: Get Layout
|
||||
layout="${defaultLayout}"
|
||||
layoutFm=$(get_frontmatter layout $file)
|
||||
if [ ! -z $layoutFm ]; then
|
||||
layout="$layoutFm"
|
||||
fi
|
||||
|
||||
layoutPath="${layoutSrc}/$layout"
|
||||
if [ ! -f $layoutPath ]; then
|
||||
echo "Layout file $layout not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### Frontmatter: Title
|
||||
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: Cleanup Tmpfiles
|
||||
cp $outFile.tmp.final $outFile
|
||||
rm $outFile.tmp*
|
||||
}
|
||||
|
||||
echo ">>> DOLLFILES"
|
||||
dollFiles=$(find . -name '*.doll')
|
||||
echo $dollFiles
|
||||
|
||||
for file in $dollFiles; do
|
||||
outFile=$(realpath -m "dist/$(echo $file | sed -e 's/.doll$/.html/')")
|
||||
echo "reading $file; plopping $outFile"
|
||||
|
||||
### Markdoll: Convert
|
||||
content=$(cat $file | ${markdoll} convert)
|
||||
|
||||
render_final $file $content $outFile
|
||||
done
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
cp -rv dist $out
|
||||
'';
|
||||
}
|
7
pkgs/mkMarkdollPlugin.nix
Normal file
7
pkgs/mkMarkdollPlugin.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{ pkgs }: binPath: pkgs.stdenvNoCC.mkDerivation {
|
||||
src = binPath;
|
||||
buildPhase = ''
|
||||
mkdir -p $out
|
||||
cp $src $out/plugin
|
||||
'';
|
||||
}
|
Loading…
Add table
Reference in a new issue