From f8ac63853c0a6b6fb212bcba73bf963ecad83fa5 Mon Sep 17 00:00:00 2001 From: Kiara Grouwstra <kiara@procolix.eu> Date: Mon, 24 Mar 2025 08:41:16 +0100 Subject: [PATCH] source htmx by nix (#268) Reviewed-on: https://git.fediversity.eu/Fediversity/Fediversity/pulls/268 Reviewed-by: Valentin Gagarin <valentin.gagarin@tweag.io> Co-authored-by: Kiara Grouwstra <kiara@procolix.eu> Co-committed-by: Kiara Grouwstra <kiara@procolix.eu> --- npins/sources.json | 15 +++++++++++++++ panel/.gitignore | 1 + panel/default.nix | 1 + panel/nix/package.nix | 2 ++ panel/src/panel/static/htmx.min.js | 1 + panel/src/panel/templates/base.html | 1 + 6 files changed, 21 insertions(+) create mode 120000 panel/src/panel/static/htmx.min.js diff --git a/npins/sources.json b/npins/sources.json index 37368b4d..45efd6b4 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -1,5 +1,20 @@ { "pins": { + "htmx": { + "type": "GitRelease", + "repository": { + "type": "GitHub", + "owner": "bigskysoftware", + "repo": "htmx" + }, + "pre_releases": false, + "version_upper_bound": null, + "release_prefix": null, + "version": "v2.0.4", + "revision": "b82cf843e47e575dd8c2ad8fee547d8e2c3bb87f", + "url": "https://api.github.com/repos/bigskysoftware/htmx/tarball/v2.0.4", + "hash": "1c4zm3b7ym01ijydiss4amd14mv5fbgp1n71vqjk4alc35jlnqy2" + }, "nix-unit": { "type": "Git", "repository": { diff --git a/panel/.gitignore b/panel/.gitignore index f4abba73..5ab365e7 100644 --- a/panel/.gitignore +++ b/panel/.gitignore @@ -10,4 +10,5 @@ __pycache__ db.sqlite3 src/db.sqlite3 src/static +src/panel/static/htmx* .credentials diff --git a/panel/default.nix b/panel/default.nix index 0c39fce6..8a27c20c 100644 --- a/panel/default.nix +++ b/panel/default.nix @@ -29,6 +29,7 @@ in DATABASE_URL = "sqlite:///${toString ./src}/db.sqlite3"; }; shellHook = '' + ln -sf ${sources.htmx}/dist/htmx.js src/panel/static/htmx.min.js # in production, secrets are passed via CREDENTIALS_DIRECTORY by systemd. # use this directory for testing with local secrets mkdir -p $CREDENTIALS_DIRECTORY diff --git a/panel/nix/package.nix b/panel/nix/package.nix index e6196686..9337887c 100644 --- a/panel/nix/package.nix +++ b/panel/nix/package.nix @@ -2,6 +2,7 @@ lib, sqlite, python3, + sources ? import ../../npins, }: let src = @@ -58,5 +59,6 @@ python3.pkgs.buildPythonPackage { cp -v ${src}/manage.py $out/bin/manage.py chmod +x $out/bin/manage.py wrapProgram $out/bin/manage.py --prefix PYTHONPATH : "$PYTHONPATH" + cp ${sources.htmx}/dist/htmx.min.js* $out/${python3.sitePackages}/panel/static/ ''; } diff --git a/panel/src/panel/static/htmx.min.js b/panel/src/panel/static/htmx.min.js new file mode 120000 index 00000000..e4006f42 --- /dev/null +++ b/panel/src/panel/static/htmx.min.js @@ -0,0 +1 @@ +/home/vg/src/Fediversity/nix/store/mwqqk0qmldzvv4xj9kq2lbah2flhc44z-source/dist/htmx.js \ No newline at end of file diff --git a/panel/src/panel/templates/base.html b/panel/src/panel/templates/base.html index 913b19fb..0cc0da39 100644 --- a/panel/src/panel/templates/base.html +++ b/panel/src/panel/templates/base.html @@ -5,6 +5,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> + <script src="/static/htmx.min.js"></script> {% load compress %} {% compress css %}