From 8711224f2fbec7fbf7b0633f3e35fee051e030cb Mon Sep 17 00:00:00 2001 From: Chris Wells Date: Sun, 8 Feb 2026 12:19:55 -0600 Subject: Utilities for adding assets for testing as well as nix script for building and deploying --- .gitignore | 1 + app/Main.hs | 25 ++++++++++++------- flake.lock | 58 +++++++++++++++++++++++++++++++++++++++++++- flake.nix | 66 +++++++++++++++++++++++++++++++++++++++++++++++--- templates/default.html | 28 +++++++++++---------- www/credits/index.html | 12 +++------ 6 files changed, 155 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index ba2a521..03ba2da 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ result .cache/* tags output/ +assets/ diff --git a/app/Main.hs b/app/Main.hs index 4011995..9510471 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -21,10 +21,14 @@ import Text.Jasmine (minify) import WWW.Base (baseHakyll, domain, myHakyllWriterOptions, myHakyllReaderOptions) import WWW.Templates (myContext, defaultTemplate) +import GHC.IO.Encoding qualified as E + main :: IO () -main = baseHakyll domain $ do +main = do + E.setLocaleEncoding E.utf8 + baseHakyll domain $ do match "templates/**" $ compile templateCompiler -- match "data/*.bib" $ compile bibtexCompiler match "data/papers.bib" $ compile papersCompiler @@ -32,15 +36,18 @@ main = baseHakyll domain $ do match "data/licenses.yaml" $ compile $ yamlCompiler @(AliasMap StrictText License_) match "data/journals.yaml" $ compile $ yamlCompiler @(AliasMap StrictText Journal_) - match ("www/css/*.scss" .||. "www/css/*.sass") $ do - route $ dropParentRoute 1 `composeRoutes` setExtension "css" - compile $ compressCss <<$>> sassCompiler - match "www/css/*.css" $ do - route $ dropParentRoute 1 - compile compressCssCompiler - match "www/js/*.js" $ do + match "assets/**" $ do route $ dropParentRoute 1 - compile $ minify <<$>> getResourceLBS + compile copyFileCompiler + -- match ("www/css/*.scss" .||. "www/css/*.sass") $ do + -- route $ dropParentRoute 1 `composeRoutes` setExtension "css" + -- compile $ compressCss <<$>> sassCompiler + -- match "www/css/*.css" $ do + -- route $ dropParentRoute 1 + -- compile compressCssCompiler + -- match "www/js/*.js" $ do + -- route $ dropParentRoute 1 + -- compile $ minify <<$>> getResourceLBS let baseCtxt :: Context String diff --git a/flake.lock b/flake.lock index c8f0f7e..bd92cc8 100644 --- a/flake.lock +++ b/flake.lock @@ -33,6 +33,21 @@ "type": "github" } }, + "nix-filter_2": { + "locked": { + "lastModified": 1730207686, + "narHash": "sha256-SCHiL+1f7q9TAnxpasriP6fMarWE5H43t25F5/9e28I=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "776e68c1d014c3adde193a18db9d738458cd2ba4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1739120049, @@ -68,7 +83,8 @@ "flake-parts": "flake-parts", "nix-filter": "nix-filter", "nixpkgs": "nixpkgs", - "systems": "systems" + "systems": "systems", + "www-assets": "www-assets" } }, "systems": { @@ -85,6 +101,46 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "www-assets": { + "inputs": { + "flake-parts": [ + "flake-parts" + ], + "nix-filter": "nix-filter_2", + "nixpkgs": [ + "nixpkgs" + ], + "systems": "systems_2" + }, + "locked": { + "lastModified": 1770388997, + "narHash": "sha256-eh56UdQY6NlcB8uMwKaMoXdKtKwjIZYQ7z5ZYM7VDQI=", + "ref": "refs/heads/master", + "rev": "7bd883e0316cf1a62395b65ce7f5a2bc13768acb", + "revCount": 6, + "type": "git", + "url": "git://git.mathematicaster.org/www/assets.git" + }, + "original": { + "type": "git", + "url": "git://git.mathematicaster.org/www/assets.git" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 66caa92..79c9327 100644 --- a/flake.nix +++ b/flake.nix @@ -5,9 +5,16 @@ flake-parts.url = "github:hercules-ci/flake-parts"; systems.url = "github:nix-systems/default"; nix-filter.url = "github:numtide/nix-filter"; + www-assets = { + url = "git://git.mathematicaster.org/www/assets.git"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-parts.follows = "flake-parts"; + }; + }; }; - outputs = inputs@{self, flake-parts, nixpkgs, ... }: flake-parts.lib.mkFlake { inherit self inputs; } { + outputs = inputs@{self, flake-parts, nixpkgs, nix-filter, ... }: flake-parts.lib.mkFlake { inherit self inputs; } { systems = import inputs.systems; flake.lib = { @@ -45,8 +52,17 @@ flake.overlays.default = final: prev: { haskellPackages = prev.haskellPackages.extend (hfinal: _hprev: { - www-main = let - src = ./.; + www-main = let + src = nix-filter { + root = ./.; + include = [ + "src" + "app" + "templates" + "package.yaml" + "www-main.cabal" + ]; + }; in hfinal.callCabal2nix "www-main" src {}; }); }; @@ -54,7 +70,10 @@ perSystem = { self', config, pkgs, system, ... }: { _module.args.pkgs = import nixpkgs { inherit system; - overlays = [ self.overlays.default ]; + overlays = [ + self.overlays.default + inputs.www-assets.overlays.default + ]; }; # haskellProjects.default = { # projectRoot = ./.; @@ -70,6 +89,22 @@ pkgs.texlive.combined.scheme-full ]; }; + site = pkgs.runCommandLocal "build-site" {} '' + mkdir $out + cd $out + cp -r ${./data} data + cp -r ${./www} www + mkdir assets + + ${www-main-exe}/bin/www-main rebuild + ''; + deploy = pkgs.writeShellApplication { + name = "deploy"; + text = '' + cd ${site} + ${www-main-exe}/bin/www-main deploy + ''; + }; }; devShells.default = pkgs.haskellPackages.shellFor { @@ -83,6 +118,29 @@ pkgs.haskell-language-server pkgs.zlib pkgs.icu + (pkgs.writeShellApplication { + name = "site-rebuild"; + text = '' + nix run ${self}#www-main-exe -- rebuild "''${@}" + ''; + }) + (pkgs.writeShellApplication { + name = "site-watch"; + text = '' + nix run ${self}#www-main-exe -- watch "''${@}" + ''; + }) + (pkgs.writeShellApplication { + name = "mkassets"; + text = '' + toplevel="$(git rev-parse --show-toplevel)" + cd "$toplevel" + + dir="$toplevel/assets" + rm -rf "$dir" + cp -r "${pkgs.www-assets}" "$dir" + ''; + }) ]; }; }; diff --git a/templates/default.html b/templates/default.html index 5dc6aa5..878963c 100644 --- a/templates/default.html +++ b/templates/default.html @@ -7,22 +7,24 @@ - + + + + + - $if(toggle)$ - - $endif$ - $if(math)$ - - - - - $endif$ + + + + + + + - - + + @@ -39,7 +41,7 @@ Research Teaching Links - + Code Contact CV diff --git a/www/credits/index.html b/www/credits/index.html index 22e7abf..99def52 100644 --- a/www/credits/index.html +++ b/www/credits/index.html @@ -17,24 +17,20 @@ This website is possible thanks to some lovely projects: hakyll - $\LaTeX$ typesetting + $\LaTeX$ typesetting $\KaTeX$ - Color scheme + Color scheme gruvbox - Fonts + Fonts FiraSans and FiraCode - Icons + Icons Font Awesome - -

-I'm happy to share the code used to generate this webpage with anyone who's interested — simply send me an email. -

-- cgit v1.2.3