diff options
| author | Chris Wells <chris@mathematicaster.org> | 2026-02-08 12:19:55 -0600 |
|---|---|---|
| committer | Chris Wells <chris@mathematicaster.org> | 2026-02-08 12:19:55 -0600 |
| commit | 8711224f2fbec7fbf7b0633f3e35fee051e030cb (patch) | |
| tree | 78b5bc4c3eca03b57353ee745006536dd4d05552 | |
| parent | bcc218171696a4830e5d3f173ce86ddb73164433 (diff) | |
| download | main-8711224f2fbec7fbf7b0633f3e35fee051e030cb.tar main-8711224f2fbec7fbf7b0633f3e35fee051e030cb.tar.gz main-8711224f2fbec7fbf7b0633f3e35fee051e030cb.tar.bz2 main-8711224f2fbec7fbf7b0633f3e35fee051e030cb.tar.lz main-8711224f2fbec7fbf7b0633f3e35fee051e030cb.tar.xz main-8711224f2fbec7fbf7b0633f3e35fee051e030cb.tar.zst main-8711224f2fbec7fbf7b0633f3e35fee051e030cb.zip | |
Utilities for adding assets for testing as well as nix script for
building and deploying
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | app/Main.hs | 25 | ||||
| -rw-r--r-- | flake.lock | 58 | ||||
| -rw-r--r-- | flake.nix | 66 | ||||
| -rw-r--r-- | templates/default.html | 28 | ||||
| -rw-r--r-- | www/credits/index.html | 12 |
6 files changed, 155 insertions, 35 deletions
@@ -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 @@ -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", @@ -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 @@ <meta name="viewport" content="width=device-width, initial-scale=1" > <link rel="stylesheet" href="/css/main.css"> - <link rel="stylesheet" href="/css/fontawesome.css"> + <link rel="stylesheet" href="/fontawesome/css/fontawesome.css"> + <link rel="stylesheet" href="/katex/katex.min.css"> + <script defer type="text/javascript" src="/katex/katex.min.js"></script> + <script defer type="text/javascript" src="/katex/contrib/autorender.min.js"></script> + <script type="text/javascript" src="/js/katex.js"></script> <script type="text/javascript" src="/js/colors.js"></script> - $if(toggle)$ - <script type="text/javascript" src="/js/toggle.js"></script> - $endif$ - $if(math)$ - <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous"> - <script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script> - <script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"></script> - <script type="text/javascript" src="/js/katex.js"></script> - $endif$ + <script type="text/javascript" src="/js/toggle.js"></script> + <!-- $if(math)$ --> + <!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous"> --> + <!-- <script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script> --> + <!-- <script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"></script> --> + <!-- <script type="text/javascript" src="/js/katex.js"></script> --> + <!-- $endif$ --> <!-- <script src="https://kit.fontawesome.com/cd6957df2d.js" crossorigin="anonymous"></script> --> <!-- favicons --> - <link rel="shortcut icon" href="/favicon.ico"> - <link rel="icon" sizes="16x16 32x32 64x64" href="/favicon.ico"> + <link rel="shortcut icon" href="/favicon/favicon.ico"> + <link rel="icon" sizes="16x16 32x32 64x64" href="/favicon/favicon.ico"> <link rel="icon" type="image/png" sizes="196x196" href="/favicon/favicon-192.png"> <link rel="icon" type="image/png" sizes="160x160" href="/favicon/favicon-160.png"> <link rel="icon" type="image/png" sizes="96x96" href="/favicon/favicon-96.png"> @@ -39,7 +41,7 @@ <a href="/research"><i class="fa fa-book"></i> Research</a> <a href="/teaching"><i class="fa fa-chalkboard-teacher"></i> Teaching</a> <a href="/links"><i class="fa fa-link"></i> Links</a> - <!-- <a href="/code"><i class="fa fa-code"></i> Code</a> --> + <a href="https://git.mathematicaster.org/"><i class="fa fa-code"></i> Code</a> <a href="/contact"><i class="fa fa-address-book"></i> Contact</a> <a href="/doc/cv.pdf"><i class="fa fa-file-alt"></i> CV</a> </span> 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: <td><a href="https://hackage.haskell.org/package/hakyll">hakyll</a></td> </tr> <tr> - <td>$\LaTeX$ typesetting</td> + <td>$\LaTeX$ typesetting</td> <td><a href="https://katex.org/">$\KaTeX$</a></td> </tr> <tr> - <td>Color scheme</td> + <td>Color scheme</td> <td><a href="https://github.com/morhetz/gruvbox">gruvbox</a></td> </tr> <tr> - <td>Fonts</td> + <td>Fonts</td> <td><a href="https://github.com/mozilla/Fira">FiraSans</a> and <a href="https://github.com/tonsky/FiraCode">FiraCode</a></td> </tr> <tr> - <td>Icons</td> + <td>Icons</td> <td><a href="https://fontawesome.com/">Font Awesome</a></td> </tr> </table> </div> - -<p> -I'm happy to share the code used to generate this webpage with anyone who's interested — simply send me an email. -</p> |
