mirror of
https://github.com/Smaug123/static-site-pipeline
synced 2025-10-05 08:18:39 +00:00
Add flake check
This commit is contained in:
6
build.sh
6
build.sh
@@ -26,8 +26,7 @@ docker build docker/hugo -t build-hugo || exit 1
|
|||||||
|
|
||||||
echo Building thumbnails.
|
echo Building thumbnails.
|
||||||
docker run --user "$(id -u):$(id -g)" -v "$IMAGES:/output" build-pictures sh -c "/build.sh /output" || exit 1
|
docker run --user "$(id -u):$(id -g)" -v "$IMAGES:/output" build-pictures sh -c "/build.sh /output" || exit 1
|
||||||
while read -r d
|
while read -r d; do
|
||||||
do
|
|
||||||
mkdir -p "$HUGO/$d" || exit 1
|
mkdir -p "$HUGO/$d" || exit 1
|
||||||
DESIRED_LOCATION=$(basename "$d")
|
DESIRED_LOCATION=$(basename "$d")
|
||||||
DEST=$(dirname "$d")
|
DEST=$(dirname "$d")
|
||||||
@@ -36,8 +35,7 @@ done < "$IMAGES/image-targets.txt"
|
|||||||
|
|
||||||
echo Building LaTeX.
|
echo Building LaTeX.
|
||||||
docker run --user "$(id -u):$(id -g)" -v "$PDFS:/inputs" build-latex sh -c "/build.sh /inputs" || exit 1
|
docker run --user "$(id -u):$(id -g)" -v "$PDFS:/inputs" build-latex sh -c "/build.sh /inputs" || exit 1
|
||||||
while read -r texfile
|
while read -r texfile; do
|
||||||
do
|
|
||||||
DIR="$HUGO"/$(dirname "$texfile")
|
DIR="$HUGO"/$(dirname "$texfile")
|
||||||
TEXFILE_BASE=$(basename "$texfile")
|
TEXFILE_BASE=$(basename "$texfile")
|
||||||
PDFFILE=$(basename "$texfile" .tex).pdf
|
PDFFILE=$(basename "$texfile" .tex).pdf
|
||||||
|
@@ -8,8 +8,7 @@ katex=$5
|
|||||||
extraContent=$6
|
extraContent=$6
|
||||||
|
|
||||||
echo "Linking PDFs: $PDF_FOLDER/pdf-targets.txt"
|
echo "Linking PDFs: $PDF_FOLDER/pdf-targets.txt"
|
||||||
while IFS= read -r texfile || [[ -n "$r" ]]
|
while IFS= read -r texfile || [[ -n $r ]]; do
|
||||||
do
|
|
||||||
DIR=$(dirname "$texfile")
|
DIR=$(dirname "$texfile")
|
||||||
TEXFILE_BASE=$(basename "$texfile")
|
TEXFILE_BASE=$(basename "$texfile")
|
||||||
if [ -z "${TEXFILE_BASE}" ]; then
|
if [ -z "${TEXFILE_BASE}" ]; then
|
||||||
@@ -25,8 +24,7 @@ do
|
|||||||
done <"${pdfs}/pdf-targets.txt"
|
done <"${pdfs}/pdf-targets.txt"
|
||||||
|
|
||||||
echo "Linking thumbnails."
|
echo "Linking thumbnails."
|
||||||
while IFS= read -r d || [[ -n "$d" ]]
|
while IFS= read -r d || [[ -n $d ]]; do
|
||||||
do
|
|
||||||
if [ -n "${d}" ]; then
|
if [ -n "${d}" ]; then
|
||||||
DIR=$(dirname "$d")
|
DIR=$(dirname "$d")
|
||||||
mkdir -p "$DIR" || exit 1
|
mkdir -p "$DIR" || exit 1
|
||||||
@@ -47,8 +45,7 @@ cp -r "$katex/dist/contrib" themes/anatole/assets/contrib
|
|||||||
cp "$katex"/dist/*.js themes/anatole/assets/
|
cp "$katex"/dist/*.js themes/anatole/assets/
|
||||||
cp "$katex"/dist/*.css themes/anatole/assets/
|
cp "$katex"/dist/*.css themes/anatole/assets/
|
||||||
|
|
||||||
while IFS= read -r file_to_copy
|
while IFS= read -r file_to_copy; do
|
||||||
do
|
|
||||||
echo "$file_to_copy"
|
echo "$file_to_copy"
|
||||||
sourcefile=$(echo "$file_to_copy" | cut -d ' ' -f 1)
|
sourcefile=$(echo "$file_to_copy" | cut -d ' ' -f 1)
|
||||||
destfile=$(echo "$file_to_copy" | cut -d ' ' -f 2-)
|
destfile=$(echo "$file_to_copy" | cut -d ' ' -f 2-)
|
||||||
|
@@ -3,5 +3,5 @@
|
|||||||
SOURCE_DIR=$(readlink -f "$1")
|
SOURCE_DIR=$(readlink -f "$1")
|
||||||
OUTPUT_DIR=$(readlink -f "$2")
|
OUTPUT_DIR=$(readlink -f "$2")
|
||||||
|
|
||||||
rm -rf "${OUTPUT_DIR:?}/*" && \
|
rm -rf "${OUTPUT_DIR:?}/*" &&
|
||||||
hugo --minify --source "$SOURCE_DIR" --destination "$OUTPUT_DIR"
|
hugo --minify --source "$SOURCE_DIR" --destination "$OUTPUT_DIR"
|
||||||
|
8
flake.lock
generated
8
flake.lock
generated
@@ -104,11 +104,11 @@
|
|||||||
"scripts": "scripts_2"
|
"scripts": "scripts_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1696161637,
|
"lastModified": 1696175612,
|
||||||
"narHash": "sha256-GwkTsWHakdktMrIlaonEGl/+/GxEgC3xpn1QzNNxKhU=",
|
"narHash": "sha256-8V8klzc7T3EdAdS4r8RRjNvTTytQOsvfi7DfK6NFK6M=",
|
||||||
"ref": "refs/heads/main",
|
"ref": "refs/heads/main",
|
||||||
"rev": "f47d539cedfaab677133b53fd4d02e24d2256985",
|
"rev": "ac0b0180304bce7683dc8b4466a6e92b339c0b7e",
|
||||||
"revCount": 14,
|
"revCount": 15,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "file:/Users/patrick/Desktop/website/static-site-images"
|
"url": "file:/Users/patrick/Desktop/website/static-site-images"
|
||||||
},
|
},
|
||||||
|
42
flake.nix
42
flake.nix
@@ -44,12 +44,7 @@
|
|||||||
}:
|
}:
|
||||||
flake-utils.lib.eachDefaultSystem (system: let
|
flake-utils.lib.eachDefaultSystem (system: let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
in rec {
|
in let
|
||||||
packages = flake-utils.lib.flattenTree {
|
|
||||||
gitAndTools = pkgs.gitAndTools;
|
|
||||||
};
|
|
||||||
defaultPackage =
|
|
||||||
let
|
|
||||||
buildHugo = scripts.lib.createShellScript pkgs "hugo" ./docker/hugo/build.sh;
|
buildHugo = scripts.lib.createShellScript pkgs "hugo" ./docker/hugo/build.sh;
|
||||||
in let
|
in let
|
||||||
katex-parts = pkgs.stdenv.mkDerivation {
|
katex-parts = pkgs.stdenv.mkDerivation {
|
||||||
@@ -64,8 +59,8 @@
|
|||||||
cp -r ./libexec/katex/dist "$out/dist"
|
cp -r ./libexec/katex/dist "$out/dist"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in let
|
||||||
pkgs.stdenv.mkDerivation {
|
website = pkgs.stdenv.mkDerivation {
|
||||||
__contentAddressed = true;
|
__contentAddressed = true;
|
||||||
pname = "patrickstevens.co.uk";
|
pname = "patrickstevens.co.uk";
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
@@ -90,5 +85,36 @@
|
|||||||
mv output $out
|
mv output $out
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
in rec {
|
||||||
|
packages = flake-utils.lib.flattenTree {
|
||||||
|
gitAndTools = pkgs.gitAndTools;
|
||||||
|
default = website;
|
||||||
|
};
|
||||||
|
checks = {
|
||||||
|
fmt-check = pkgs.stdenvNoCC.mkDerivation {
|
||||||
|
name = "fmt-check";
|
||||||
|
src = ./.;
|
||||||
|
nativeBuildInputs = [pkgs.alejandra pkgs.shellcheck pkgs.shfmt];
|
||||||
|
checkPhase = ''
|
||||||
|
find . -type f -name '*.sh' | xargs shfmt -d -s -i 2 -ci
|
||||||
|
alejandra -c .
|
||||||
|
find . -type f -name '*.sh' -exec shellcheck -x {} \;
|
||||||
|
'';
|
||||||
|
installPhase = "mkdir $out";
|
||||||
|
dontBuild = true;
|
||||||
|
doCheck = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
website-check = pkgs.stdenvNoCC.mkDerivation {
|
||||||
|
name = "website-check";
|
||||||
|
src = website;
|
||||||
|
installPhase = "mkdir $out";
|
||||||
|
dontBuild = true;
|
||||||
|
doCheck = true;
|
||||||
|
checkPhase = ''
|
||||||
|
${pkgs.bash}/bin/bash ${scripts.lib.createShellScript pkgs "linkcheck" ./linkcheck.sh}/run.sh ${pkgs.lynx}/bin/lynx
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -10,9 +10,9 @@ I have deleted almost all of the Anki decks on this page, because I think they w
|
|||||||
They were made during a time when I didn't really know how to use Anki appropriately.
|
They were made during a time when I didn't really know how to use Anki appropriately.
|
||||||
Any remaining decks here are CC-BY-SA.
|
Any remaining decks here are CC-BY-SA.
|
||||||
|
|
||||||
* [Geography]. You can filter out the `london-tube` tag if you like, or `world-capitals`, or `american-geography`.
|
* [Geography] (the deck has a misleading name; it's actually a general Geography deck). You can filter out the `london-tube` tag if you like, or `world-capitals`, or `american-geography`.
|
||||||
|
|
||||||
<a href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_GB" rel="license"><img style="border-width: 0;" alt="Creative Commons Licence" src="https://licensebuttons.net/l/by-sa/3.0/88x31.png" /></a>
|
<a href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_GB" rel="license"><img style="border-width: 0;" alt="Creative Commons Licence" src="https://licensebuttons.net/l/by-sa/3.0/88x31.png" /></a>
|
||||||
This work by <a href="/anki-decks" rel="cc:attributionURL">Patrick Stevens</a> is licensed under a <a href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_GB" rel="license">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.
|
This work by <a href="/anki-decks" rel="cc:attributionURL">Patrick Stevens</a> is licensed under a <a href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_GB" rel="license">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.
|
||||||
|
|
||||||
[Geography]: /AnkiDecks/Geography.apkg
|
[Geography]: /AnkiDecks/CapitalsOfTheWorld.apkg
|
@@ -14,7 +14,7 @@ summary: "A fairly long and winding way through a proof of the three Sylow theor
|
|||||||
---
|
---
|
||||||
(This post is mostly to set up a kind of structure for the website; in particular, to be the first in a series of posts summarising some mathematical results I stumble across.)
|
(This post is mostly to set up a kind of structure for the website; in particular, to be the first in a series of posts summarising some mathematical results I stumble across.)
|
||||||
|
|
||||||
EDIT: There is now [an Anki deck](/AnkiDecks/SylowTheoremsProof.apkg) of this proof, and a [collection of poems][sylow sonnets] summarising it.
|
EDIT: There is now a [collection of poems][sylow sonnets] summarising this proof.
|
||||||
|
|
||||||
In Part IB of the Mathematical Tripos (that is, second-year material), there is a course called Groups, Rings and Modules. I took it in the academic year 2012-2013, when it was lectured by [Imre Leader](https://en.wikipedia.org/wiki/Imre_Leader). He told us that there were three main proofs of the [Sylow theorems](https://en.wikipedia.org/wiki/Sylow_theorems), two of which were horrible and one of which was nice; he presented the "nice" one. At the time, I thought this was the most beautiful proof of anything I'd ever seen, although other people have told me it's a disgusting proof.
|
In Part IB of the Mathematical Tripos (that is, second-year material), there is a course called Groups, Rings and Modules. I took it in the academic year 2012-2013, when it was lectured by [Imre Leader](https://en.wikipedia.org/wiki/Imre_Leader). He told us that there were three main proofs of the [Sylow theorems](https://en.wikipedia.org/wiki/Sylow_theorems), two of which were horrible and one of which was nice; he presented the "nice" one. At the time, I thought this was the most beautiful proof of anything I'd ever seen, although other people have told me it's a disgusting proof.
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ aliases:
|
|||||||
title: Sum-of-two-squares theorem
|
title: Sum-of-two-squares theorem
|
||||||
---
|
---
|
||||||
|
|
||||||
*Wherein I detail the most beautiful proof of a theorem I've ever seen, in a bite-size form suitable for an Anki deck. I attach the [Anki deck], which contains the bulleted lines of this post as flashcards.*
|
*Wherein I detail the most beautiful proof of a theorem I've ever seen, in a bite-size form suitable for an Anki deck.
|
||||||
|
|
||||||
# Statement
|
# Statement
|
||||||
There's no particularly nice way to motivate this in this context, I'm afraid, so we'll just dive in. I have found this method extremely hard to motivate - a few of the steps are a glorious magic.
|
There's no particularly nice way to motivate this in this context, I'm afraid, so we'll just dive in. I have found this method extremely hard to motivate - a few of the steps are a glorious magic.
|
||||||
@@ -32,8 +32,6 @@ Additionally, we'll call a number which is the sum of two squares a **nice** num
|
|||||||
## First implication: if primes 3 mod 4 appear only to even powers…
|
## First implication: if primes 3 mod 4 appear only to even powers…
|
||||||
We prove the result first for the primes, and will then show that niceness is preserved on taking products.
|
We prove the result first for the primes, and will then show that niceness is preserved on taking products.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* Let \\(p=2\\). Then \\(p\\) is trivially the sum of two squares: it is \\(1+1\\).
|
* Let \\(p=2\\). Then \\(p\\) is trivially the sum of two squares: it is \\(1+1\\).
|
||||||
* Let \\(p\\) be 1 mod 4.
|
* Let \\(p\\) be 1 mod 4.
|
||||||
* Then modulo \\(p\\), we have \\(-1\\) is square.
|
* Then modulo \\(p\\), we have \\(-1\\) is square.
|
||||||
@@ -82,4 +80,3 @@ That ends the proof. Its beauty lies in the way it regards sums of two squares a
|
|||||||
[UFD]: https://en.wikipedia.org/wiki/Unique_factorization_domain
|
[UFD]: https://en.wikipedia.org/wiki/Unique_factorization_domain
|
||||||
[irreducible]: https://en.wikipedia.org/wiki/Irreducible_element
|
[irreducible]: https://en.wikipedia.org/wiki/Irreducible_element
|
||||||
[prime]: https://en.wikipedia.org/wiki/Prime_element
|
[prime]: https://en.wikipedia.org/wiki/Prime_element
|
||||||
[Anki deck]: {{< baseurl >}}AnkiDecks/SumOfTwoSquaresTheorem.apkg
|
|
||||||
|
37
linkcheck.sh
Normal file
37
linkcheck.sh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
bad=0
|
||||||
|
|
||||||
|
LYNX=$1
|
||||||
|
|
||||||
|
evaluate_file() {
|
||||||
|
target=$1
|
||||||
|
links=$("$LYNX" -dump --listonly -image_links --nonumbers -hiddenlinks=listonly "$target" | awk '
|
||||||
|
/Visible links/ {
|
||||||
|
found=1
|
||||||
|
next
|
||||||
|
}
|
||||||
|
found { print }
|
||||||
|
' | grep 'file:' | cut -d '/' -f 3- | grep -v '#')
|
||||||
|
|
||||||
|
# hurr durrr accidentally quadratic
|
||||||
|
for link in $links; do
|
||||||
|
filename=".$link"
|
||||||
|
if [ -d "$filename" ]; then
|
||||||
|
filename="$filename/index.html"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [ -e "$filename" ]; then
|
||||||
|
echo "File does not exist, while parsing '$target': $filename" >&2
|
||||||
|
bad=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
while IFS= read -d '' -u3 -r file; do
|
||||||
|
evaluate_file "$file"
|
||||||
|
done 3< <(find . -type f -name '*.html' -print0)
|
||||||
|
|
||||||
|
if [ $bad -eq 1 ]; then
|
||||||
|
exit $bad
|
||||||
|
fi
|
Reference in New Issue
Block a user