From ca6be786a18aedcb3d5a649a2b00973c3e38bc65 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Thu, 30 Dec 2021 15:34:44 -0400 Subject: chore(wpcarro/website): Templatize website Preferring billandhiscomputer.com in lieu of wpcarro.dev. wpcarro is a bit of a tough username for others to remember and for me to say out-loud (it usually involves me spelling it and explaining to others why Carroll is missing 2x-Ls). I think it's time for a change. During the transition, I don't want to deal with stale links to https://wpcarro.dev, so I'm templatizing more of my website and blog so that these values can be replaced. Expect more forthcoming changes. Change-Id: Ic2f5519e6b0d76fcb8b737bf50009e8388f1b178 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4754 Tested-by: BuildkiteCI Reviewed-by: wpcarro Autosubmit: wpcarro --- users/wpcarro/website/blog/default.nix | 20 +++++++++----------- users/wpcarro/website/blog/fragments/posts.html | 2 +- users/wpcarro/website/default.nix | 23 +++++++++++++++++++---- users/wpcarro/website/fragments/homepage.html | 6 +++--- users/wpcarro/website/fragments/template.html | 24 ++++++++++++------------ 5 files changed, 44 insertions(+), 31 deletions(-) (limited to 'users/wpcarro') diff --git a/users/wpcarro/website/blog/default.nix b/users/wpcarro/website/blog/default.nix index 7056b026a21a..0eca77d9be3e 100644 --- a/users/wpcarro/website/blog/default.nix +++ b/users/wpcarro/website/blog/default.nix @@ -5,17 +5,17 @@ with depot.nix.yants; let inherit (builtins) hasAttr filter readFile; inherit (depot.web.blog) post includePost renderPost; - inherit (depot.users) wpcarro; + inherit (depot.users.wpcarro.website) domain renderTemplate withBrand; config = { - name = "wpcarro's blog"; - baseUrl = "https://wpcarro.dev/blog"; + name = "bill and his blog"; + baseUrl = "https://${domain}/blog"; footer = ""; }; posts = filter includePost (list post (import ./posts.nix)); - rendered = pkgs.runCommandNoCC "wpcarros-blog-posts" {} '' + rendered = pkgs.runCommandNoCC "blog-posts" {} '' mkdir -p $out ${lib.concatStringsSep "\n" (map (post: @@ -27,19 +27,17 @@ let date --date='@${toString date}' '+%B %e, %Y' > $out ''); - postsHtml = readFile (pkgs.substituteAll { - src = ./fragments/posts.html; + postsHtml = renderTemplate ./fragments/posts.html { postsHtml = lib.concatStringsSep "\n" (map toPostHtml posts); - }); + }; - toPostHtml = post: readFile (pkgs.substituteAll { - src = ./fragments/post.html; + toPostHtml = post: readFile (renderTemplate ./fragments/post.html { postUrl = "${config.baseUrl}/posts/${post.key}.html"; postTitle = post.title; postDate = formatDate post.date; }); -in pkgs.runCommandNoCC "wpcarros-blog" {} '' +in pkgs.runCommandNoCC "blog" {} '' mkdir -p $out - cp ${wpcarro.website.render postsHtml} $out/index.html + cp ${withBrand (readFile postsHtml)} $out/index.html cp -r ${rendered} $out/posts '' diff --git a/users/wpcarro/website/blog/fragments/posts.html b/users/wpcarro/website/blog/fragments/posts.html index 699b28f366c0..a85a4b71101e 100644 --- a/users/wpcarro/website/blog/fragments/posts.html +++ b/users/wpcarro/website/blog/fragments/posts.html @@ -1,7 +1,7 @@

- Personal blog by wpcarro. + Personal blog by Bill.

> Half-baked musings lossily encoded.

> - misc reviewer

diff --git a/users/wpcarro/website/default.nix b/users/wpcarro/website/default.nix index b20de562ab6f..9694aad17d60 100644 --- a/users/wpcarro/website/default.nix +++ b/users/wpcarro/website/default.nix @@ -4,18 +4,33 @@ let inherit (builtins) readFile; inherit (depot.users) wpcarro; - render = contentHtml: pkgs.substituteAll { + domain = "billandhiscomputer.com"; + + globalVars = { + inherit domain; + homepage = "https://${domain}/"; + blog = "https://${domain}/blog"; + habits = "https://${domain}/habits"; + github = "https://github.com/wpcarro"; + linkedin = "https://linkedin.com/in/williampatrickcarroll"; + depotWork = "https://cs.tvl.fyi/depot/-/blob/users/wpcarro"; + }; + + renderTemplate = src: vars: pkgs.substituteAll (globalVars // vars // { + inherit src; + }); + + withBrand = contentHtml: renderTemplate ./fragments/template.html { inherit contentHtml; - src = ./fragments/template.html; }; in { - inherit render; + inherit domain renderTemplate withBrand; root = pkgs.runCommandNoCC "wpcarro.dev" {} '' mkdir -p $out # / - cp ${render (readFile ./fragments/homepage.html)} $out/index.html + cp ${withBrand (readFile (renderTemplate ./fragments/homepage.html {}))} $out/index.html # /habits mkdir -p $out/habits diff --git a/users/wpcarro/website/fragments/homepage.html b/users/wpcarro/website/fragments/homepage.html index 54e38b990ef1..f515d974001e 100644 --- a/users/wpcarro/website/fragments/homepage.html +++ b/users/wpcarro/website/fragments/homepage.html @@ -1,6 +1,6 @@

- Hey! I'm William.👋 + Hey! I'm Bill.👋

I write software. Currently I work as a Site Reliability Engineer for @@ -8,10 +8,10 @@

I'm wpcarro on - GitHub + GitHub (and elsewhere), but if you're looking for code samples, the majority of my open-source work resides in a magical place called the - depot. + depot.

If I'm not coding, I'm likely meditating, training Jiu Jitsu, or diff --git a/users/wpcarro/website/fragments/template.html b/users/wpcarro/website/fragments/template.html index 96d19e849196..381dcad68040 100644 --- a/users/wpcarro/website/fragments/template.html +++ b/users/wpcarro/website/fragments/template.html @@ -1,7 +1,7 @@ - wpcarro.dev + @domain@ @@ -22,31 +22,31 @@