feat: can now create the pdf's directly using `nix run .#handovers`

This commit is contained in:
silver 2024-05-10 03:14:03 +01:00
parent 527465ab07
commit e42a2b221a
Signed by: silver
GPG key ID: 54E2C71918E93B74
5 changed files with 55 additions and 13 deletions

3
.gitignore vendored
View file

@ -16,7 +16,8 @@ test.*
# Output of compiling
/out
/build
/*/*_build
/*/*_html
/*/*_pdf
/target
/cmake-build-debug
# for QT, both as single directory and as subfolders

View file

@ -9,7 +9,7 @@ indentation = 2
src = "./_Handovers"
# Optional
dest= "./_Handovers_build"
dest= "./_Handovers_html"
# html blocks you dont want to include in teh finished page
# Optional

View file

@ -0,0 +1,37 @@
#!/usr/bin/env bash
cd Committee
cargo-bfom
# recursively parse _Handovers_html use wkhtmltopdf to convert to pdf
cd _Handovers_html
out_folder="../_Handovers_pdf"
rm -rf "$out_folder"
for d in */ ; do
# skip symlinks
[ -L "''${d%/}" ] && continue
# exclude teh template fodler
if [[ $d == *"_Templates"* ]]; then
continue
fi
# create output folder
mkdir -p "$out_folder/$d"
# iterate the files
for file in $d*.html; do
if [ -f "$file" ]; then
# we need teh filename/path
stripped=''${file/.html/""}
echo "$out_folder/$stripped.pdf"
# convert teh html to pdf
wkhtmltopdf -q --enable-local-file-access --no-stop-slow-scripts "$stripped.html" "$out_folder/$stripped.pdf" 2> ./tmp.txt
fi
done
done
cd ../

View file

@ -68,11 +68,11 @@
},
"nixpkgs_3": {
"locked": {
"lastModified": 1705856552,
"narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=",
"lastModified": 1715087517,
"narHash": "sha256-CLU5Tsg24Ke4+7sH8azHWXKd0CFd4mhLWfhYgUiDBpQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d",
"rev": "b211b392b8486ee79df6cdfb1157ad2133427a29",
"type": "github"
},
"original": {
@ -141,11 +141,11 @@
"systems": "systems_2"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {

View file

@ -14,7 +14,10 @@
config = {
allowUnfree = true;
permittedInsecurePackages = [
# for obsidian
"electron-25.9.0"
# for wkhtmltopdf
"qtwebkit-5.212.0-alpha4"
];
};
};
@ -35,11 +38,12 @@
program = "${bfom.defaultPackage.x86_64-linux}/bin/cargo-bfom";
};
packages.handovers = pkgs.writeShellScriptBin "format_handovers" ''
cd Committee
${bfom.defaultPackage.x86_64-linux}/bin/cargo-bfom
packages = {
handovers = pkgs.writeShellScriptBin "format_handovers" ''
export PATH=${pkgs.lib.makeBinPath [ pkgs.wkhtmltopdf bfom.defaultPackage.x86_64-linux ]}:$PATH
${./_scripts/format_handovers.sh}
'';
};
});
}