From 7b70622903dee88a76ffd6ec6a239d4018dbba74 Mon Sep 17 00:00:00 2001
From: Suzanne Soy
Date: Mon, 20 Nov 2023 22:51:46 +0000
Subject: [PATCH] Dynamically generate IPFS hash of current version; used Nix
for the few automations in the build process.
---
.gitignore | 1 +
.ipfsignore | 2 +
deploy.sh | 39 ++--
directory_hashes.js | 1 +
favicon.ico | Bin 0 -> 32038 bytes
favicon.svg | 86 +++++++++
flake.lock | 59 ++++++
flake.nix | 31 ++++
index.html | 35 ++--
ipfs-add.sh | 14 ++
micro_ipfs.js | 437 ++++++++++++++++++++++++++++++++++++++++++++
sha256.js | 204 +++++++++++++++++++++
12 files changed, 871 insertions(+), 38 deletions(-)
create mode 100644 .gitignore
create mode 100644 .ipfsignore
create mode 100644 directory_hashes.js
create mode 100644 favicon.ico
create mode 100644 favicon.svg
create mode 100644 flake.lock
create mode 100644 flake.nix
create mode 100755 ipfs-add.sh
create mode 100644 micro_ipfs.js
create mode 100644 sha256.js
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c4a847d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/result
diff --git a/.ipfsignore b/.ipfsignore
new file mode 100644
index 0000000..157ea12
--- /dev/null
+++ b/.ipfsignore
@@ -0,0 +1,2 @@
+/.git
+/result
diff --git a/deploy.sh b/deploy.sh
index 63ee0ea..6543b4d 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -3,44 +3,29 @@
set -euET -o pipefail
usage() {
- printf 'Usage: ./deploy.sh v1'\\n
- printf ' v1 will be used as the tag name for this version'\\n
+ printf 'Usage: ./deploy.sh v1.0.0'\\n
+ printf ' v1.0.0 will be used as the tag name for this version'\\n
}
if [ $# -ne 1 ]; then usage; exit 1; fi
-if [ "x$1" = "x-h" ] || [ "x$1" = "x--help" ]; then usage; exit 1; fi
+if [ "x$1" = "x-h" ] || [ "x$1" = "x--help" ]; then usage; exit 0; fi
-# e.g. v1
+# e.g. v1.0.0
version="$1"
-commit_hash="$(git log --format=%H -1 HEAD)"
-tempdir="$(mktemp -d)"
-tempdirgit="$(mktemp -d)"
-this_repo="$PWD"
-printf "Temporary directory: %s"\\n "$tempdir"
-
-# Clone this specific commit (could use a worktree, but I prefer not modifying the original repo if it can be avoided)
-git init "$tempdir"
-(cd "$tempdir"; git fetch --depth=1 "$this_repo" "$commit_hash")
-(cd "$tempdir"; git checkout "$commit_hash")
-(cd "$tempdir"; git log)
-(set -x; mv "$tempdir/.git" "$tempdirgit/")
-ls -a "$tempdir"
-
-if ! grep ''"$version"'' "$tempdir/index.html"; then
+if ! grep ''"$version"'' "index.html"; then
printf "Error: The version number given on the command-line does not match the one in the HTML source code."\\n
exit 1
fi
-# Add to IPFS and get the hash
-ipfs_hash="$(ipfs add --pin=true --recursive --hidden --progress --quieter "$tempdir")"
-ipfs_hash="$(ipfs cid base32 "$ipfs_hash")"
-printf \\n
+nix build
+diff result/www/directory_hashes.js directory_hashes.js
+diff result/www/favicon.ico favicon.ico
+# Add to IPFS and get the hash
+ipfs_hash="$(./result/www/ipfs-add.sh --pin=true)"
printf %s\\n "$ipfs_hash"
-ipfs name publish --key=git-tutorial "/ipfs/$ipfs_hash"
-
-sed -i -e 's~ipfs-this-hash-placeholder" href="#"~ipfs-this-hash-placeholder" href="ipfs://'"$ipfs_hash"'/"~' index.html
-git commit -m 'Stored IPFS hash of this version' index.html
git tag "$1"
git tag "ipfs-$1-${ipfs_hash}"
+
+ipfs name publish --key=git-tutorial "/ipfs/$ipfs_hash"
\ No newline at end of file
diff --git a/directory_hashes.js b/directory_hashes.js
new file mode 100644
index 0000000..6fe8ae7
--- /dev/null
+++ b/directory_hashes.js
@@ -0,0 +1 @@
+jsonp_ipfs_directory_hashes({"vanity_text":"soy","vanity_number":8104,"tree":{"Links":[{"Name":".gitignore","Hash":"QmW9iMXzmPqLSnzL4p6DKsvsL3nC1xKS3teRB4SRdukfrz","Size":16},{"Name":".ipfsignore","Hash":"QmPpQN29FbeaNwGsXbebbv588UZtSLCGRffa3Zrz68RAMp","Size":22},{"Name":"Blob.js","Hash":"QmSxKmtcBxBRkmkLGpnXAGrRc16kPrJx5Hmdsvt6LRWeSG","Size":21833},{"Name":"FileSaver.js","Hash":"QmUgg2HLo4W9bpf92CkHH6WWVFfg2DmNqJrz2Z46L7VmUq","Size":7367},{"Name":"JSZip","Hash":"QmWW2hDPrMU5e5KgSAMiqfM2YW5RSiZzWiNJSQ7w63ngiL","Size":422094},{"Name":"README","Hash":"QmPVpTsg2DmVqnCWRVua3vggVAoYLKzZPPgGf5ZQzzVUwf","Size":464},{"Name":"Viz.js","Hash":"QmaxUCu1gnFwTTpDoTAPB3fMQQav1NJZrZ7LGqLXECidKj","Size":3564410},{"Name":"codemirror-5.60.0","Hash":"QmXPbArMAid8MbC5G7HCyWz2PUkfSMWZaUQpnq63x8Dw2y","Size":4669604},{"Name":"deploy.sh","Hash":"QmTwid4ByPum8DdAcsGPaVpGuHcfr1GfXxbRpuPgabButs","Size":893},{"Name":"directory_hashes.js","Hash":"","Size":0},{"Name":"favicon.ico","Hash":"QmUq6pQamF58ZDNpPSvF3C2bcCWEJSjx3dFZZLjkSCrYpi","Size":32052},{"Name":"favicon.svg","Hash":"QmesnKGtStCZGpiTjoAcAETdSZgUUQ3wzekn1LSQMFtbgn","Size":3272},{"Name":"flake.lock","Hash":"QmdkX8PkV6j2sLH1JSPD1z4533rEGTa6JKSfsJcYAGSrvx","Size":1475},{"Name":"flake.nix","Hash":"QmVFaam6DfGDxQxWgWL2VdUaVtuQ9pj7W2aoopU8S26HKR","Size":1224},{"Name":"git-tutorial.css","Hash":"QmdsWg4RVZR3kRA7xFchoWLEQQzLpzVyspTtKwa9qttDMF","Size":10842},{"Name":"git-tutorial.js","Hash":"QmbcAMAuGyFumz4pHtKMnRY2VyRAr2tZoiYBLfNY3p2kCj","Size":47083},{"Name":"index.html","Hash":"QmehaJJ6fqMamiq2W17oP1zEb4kKWwEdUarRYBZweRnh3Q","Size":117132},{"Name":"ipfs-add.sh","Hash":"QmXSLYLy13efSFVEN3Ej3A3vyimH618Vrt82hoBKeKYgDB","Size":473},{"Name":"micro_ipfs.js","Hash":"QmeWPj4vzN66eCUwQkjjzTgfciBLBzNjQQdvqEBL8x1pmh","Size":16738},{"Name":"pako","Hash":"QmRtJhu2rJCe59JPS9UiyAja5iUZNmJ8nyBijdZpLLEgG9","Size":178431},{"Name":"sha1.js","Hash":"QmP7HPPYQqwKXYyDrkDm9vKt8FZE1WsDUJG8cLnjFf4a11","Size":7966},{"Name":"sha256.js","Hash":"QmRhgx5Fq4JqfCgsPcMxNSYwt8M9WRBkec9omPWzJ7gdwL","Size":8553}],"Data":"\b\u0001"}});
diff --git a/favicon.ico b/favicon.ico
new file mode 100644
index 0000000000000000000000000000000000000000..e3df14f3b88b531aa82065acb78d87433e2facdf
GIT binary patch
literal 32038
zcmeI54RD=Rna59>LYkyW+D@T>v}v2%B$O7qltP;}O%O&99Cg`(iXfeFcPP6o;L=@o
z9ktnY*-_L*aB*9ty*J5COBr!t6miE{3Fxk~AdD>{D6S16^3ek6N0J*FdiVD~?|bfj
zb9=v%+@wj(JM+);ew}lk|8vfJKA&@AOp%#xT3QTpp=o%(F&{9-EMM+jKM*qJX6`Lq
z=wHt==G2YG%tGq@jnj?!(cc@>Kp3Jhtw8tf(PGSxD?NBOM)tQd@_(i>^3uiS;e-8U
z;l6khz43~0_l>3DcSjcSBndUee=7f{%Ksnn_aFZ4A9ej#5&oU22=Bd!`oAw(_p2Q^
z9IuSLa7$Tuz|?g#O_JJt_-dAidrW!wowa4*-h)B@*dsnC^29$DZ;zWL?Q4f0@gxZW
zX9HG)1F8JywcY>Sl{-yIDB5J|qU$CJqv5HUiNDJK``Yi=UmrbpmH3BF&~G3!|6cfS
zj@Lz3b%vtrW>_0^o_OCucK)sLP_%IX?l(8wce$}Ppe&q7M;`pKLDSpd`Z;YY6E;|M
zKLeK&;K-A|Z14`ag?hl&hl|=9sS_uESr`U?*&qhCfCa$Rby6?VF4RwAI}DS*Y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ake.lock b/flake.lock
new file mode 100644
index 0000000..69e41f9
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,59 @@
+{
+ "nodes": {
+ "archivable": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ },
+ "locked": {
+ "lastModified": 1700523797,
+ "narHash": "sha256-aY7CqvgpJ9TOGIWJjpu0PmMGzXe36GXMHTMgAVlzZ8o=",
+ "owner": "SuzanneSoy",
+ "repo": "archivable",
+ "rev": "c35dc8f760f5640e0c769a6814568d6fe71e5726",
+ "type": "github"
+ },
+ "original": {
+ "owner": "SuzanneSoy",
+ "repo": "archivable",
+ "rev": "c35dc8f760f5640e0c769a6814568d6fe71e5726",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1700108881,
+ "narHash": "sha256-+Lqybl8kj0+nD/IlAWPPG/RDTa47gff9nbei0u7BntE=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "7414e9ee0b3e9903c24d3379f577a417f0aae5f1",
+ "type": "github"
+ },
+ "original": {
+ "id": "nixpkgs",
+ "type": "indirect"
+ }
+ },
+ "nixpkgs_2": {
+ "locked": {
+ "lastModified": 1700108881,
+ "narHash": "sha256-+Lqybl8kj0+nD/IlAWPPG/RDTa47gff9nbei0u7BntE=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "7414e9ee0b3e9903c24d3379f577a417f0aae5f1",
+ "type": "github"
+ },
+ "original": {
+ "id": "nixpkgs",
+ "type": "indirect"
+ }
+ },
+ "root": {
+ "inputs": {
+ "archivable": "archivable",
+ "nixpkgs": "nixpkgs_2"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..b7ab8aa
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,31 @@
+{
+ description = "GIT tutorial";
+ inputs.archivable.url = github:SuzanneSoy/archivable/c35dc8f760f5640e0c769a6814568d6fe71e5726;
+ outputs = { self, nixpkgs, archivable }: {
+ defaultPackage.x86_64-linux = self.packages.x86_64-linux.website;
+ packages.x86_64-linux.website =
+ let pkgs = import nixpkgs { system = "x86_64-linux"; }; in
+ pkgs.stdenv.mkDerivation {
+ name = "git-tutorial";
+ src = self;
+ buildInputs = with pkgs; [kubo jq nodejs-slim imagemagick];
+ buildPhase = ''
+ convert -background none favicon.svg -define icon:auto-resize=64,48,32,16 favicon.ico
+
+ mkdir "$out"
+ cp -ai . "$out/www"
+
+ export HOME=.
+ ipfs init
+ ${archivable.packages.x86_64-linux.update-directory-hashes}/bin/update-directory-hashes "$out/www/" 'soy'
+ printf 'ipfs://%s\n' "$(ipfs cid base32 "$(ipfs add --ignore-rules-path "$out/www/.ipfsignore" --pin=false --hidden -Qr "$out/www")")" > "$out/ipfs.url" 2>&1
+ '';
+
+ # Prevent automatic modification of files in the output.
+ dontInstall = true;
+ dontFixup = true;
+ dontPatchELF = true;
+ dontPatchShebangs = true;
+ };
+ };
+}
diff --git a/index.html b/index.html
index 85dd90b..0ca12b6 100644
--- a/index.html
+++ b/index.html
@@ -4,13 +4,11 @@
GIT tutorial
-
-
+
-
-
+
@@ -54,13 +52,14 @@ function ___example(id, f) {
Git tutorial: reimplementing part of GIT in JavaScript
By Suzanne Soy for LIGO. .
Please send remarks and suggestions to git-tutorial@suzanne.soy or simply fork this repository on GitHub.
-This version of the site matches the tag v1 on GitHub.
- You can access snapshots of this site via IPFS:
-
- v1 (permalink),
- or check the
- latest version via IPNS/IPFS or
- via HTTPS.
+This version of the site matches the tag v1.0.1 on GitHub.
+ Permalinks to snapshots of this site are available via IPFS:
+ v1.0.1 (current version) [computing URL…],
+ v1 (02021-06-29),
+ Alternatively check the
+ latest version via IPNS/IPFS
+ or
+ latest via HTTPS.
Credits and license
@@ -2451,5 +2450,19 @@ commands.
})();
___git_tutorial_onload()
+
+
+
+
+