26ebe3bd86
New 🌳 Pedigree view: enter a dog's ISO chip or SKK registration number
and see its ancestry rendered as a tree. SKK has no public API, so the
server drives SKK Hunddata like a browser: it resolves the input to an
internal hundid via the Hund_sok.aspx/HundData page-method, renders 7
generations per pedigree page, parses the rowspan grid into ahnentafel
positions, and follows each generation's leaves deeper by reading their
hundid out of the __doPostBack response viewstate.
A lookup returns the first 7 generations immediately and crawls deeper in
the background; the client polls and fills the tree in as ancestors
arrive. Finished trees are cached per dog in a new pedigree_cache table
(pedigrees don't change), so a dog is crawled once and repeats are instant.
The endpoints sit behind auth like the rest of /api/*, and the crawl is
kept polite (warmed session, delay between requests, one coalesced job per
dog, hard caps).
86 lines
2.8 KiB
Nix
86 lines
2.8 KiB
Nix
{
|
|
description = "Puppy Tracker — offline-first puppy tracking app with server-side sync.";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, flake-utils }:
|
|
let
|
|
mkStatic = pkgs:
|
|
pkgs.stdenvNoCC.mkDerivation {
|
|
pname = "puppy-tracker-static";
|
|
version = "0.2.0";
|
|
src = ./src;
|
|
dontConfigure = true;
|
|
dontBuild = true;
|
|
installPhase = ''
|
|
mkdir -p $out/share/puppy-tracker
|
|
cp -r ./* $out/share/puppy-tracker/
|
|
'';
|
|
};
|
|
|
|
mkServer = pkgs:
|
|
pkgs.buildGoModule {
|
|
pname = "puppy-tracker-server";
|
|
version = "0.2.0";
|
|
src = ./server;
|
|
vendorHash = "sha256-J1lYhwbaRh2PeAh3SzyB9WgUZa1gCNXBWdaJ5isUedA=";
|
|
# Pure-Go build for a tiny static binary.
|
|
env.CGO_ENABLED = "0";
|
|
ldflags = [ "-s" "-w" ];
|
|
# The binary built from `module puppy-tracker` is `puppy-tracker`,
|
|
# rename so the executable name reflects its role.
|
|
postInstall = ''
|
|
mv $out/bin/puppy-tracker $out/bin/puppy-tracker-server
|
|
'';
|
|
meta.mainProgram = "puppy-tracker-server";
|
|
};
|
|
in
|
|
{
|
|
nixosModules.default = import ./module.nix self;
|
|
nixosModules.puppy-tracker = self.nixosModules.default;
|
|
}
|
|
//
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = import nixpkgs { inherit system; };
|
|
static = mkStatic pkgs;
|
|
server = mkServer pkgs;
|
|
in
|
|
{
|
|
packages.static = static;
|
|
packages.server = server;
|
|
# `default` bundles both so `nix build` produces a runnable directory.
|
|
packages.default = pkgs.symlinkJoin {
|
|
name = "puppy-tracker";
|
|
paths = [ server static ];
|
|
};
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
packages = [ pkgs.go pkgs.python3 ];
|
|
shellHook = ''
|
|
echo "puppy-tracker dev shell"
|
|
echo " cd server && go run . -static ../src -data /tmp/puppy-events.json"
|
|
'';
|
|
};
|
|
|
|
# `nix run` → start the server, serving the bundled static files,
|
|
# storing data in $XDG_DATA_HOME/puppy-tracker/events.json.
|
|
apps.default = {
|
|
type = "app";
|
|
program = toString (pkgs.writeShellScript "puppy-tracker-run" ''
|
|
data_dir="''${XDG_DATA_HOME:-$HOME/.local/share}/puppy-tracker"
|
|
mkdir -p "$data_dir"
|
|
exec ${server}/bin/puppy-tracker-server \
|
|
-addr "''${PUPPY_ADDR:-:8080}" \
|
|
-static ${static}/share/puppy-tracker \
|
|
-data "$data_dir/puppy.db"
|
|
'');
|
|
meta.description = "Run puppy-tracker locally (data in $XDG_DATA_HOME/puppy-tracker)";
|
|
};
|
|
}
|
|
);
|
|
}
|