From 1036c49e9e3c3ff311a713cccf0054c8c16a9857 Mon Sep 17 00:00:00 2001 From: "quentin@aristote.fr" Date: Sat, 30 Sep 2023 21:25:03 +0200 Subject: format --- html/basics/default.nix | 118 ++++++++++++++++--------------- html/default.nix | 123 ++++++++++++++++---------------- html/education/default.nix | 39 ++++++----- html/experience/default.nix | 41 ++++++----- html/languages/default.nix | 19 ++--- html/publications/default.nix | 113 +++++++++++++++++------------- html/sections.nix | 29 ++++---- html/software/default.nix | 39 ++++++----- lib/default.nix | 6 +- lib/html.nix | 159 +++++++++++++++++++++++------------------- pkgs/line-awesome-css.nix | 11 +-- 11 files changed, 378 insertions(+), 319 deletions(-) diff --git a/html/basics/default.nix b/html/basics/default.nix index 55de692..55517f4 100644 --- a/html/basics/default.nix +++ b/html/basics/default.nix @@ -1,72 +1,76 @@ -{ html, data, lib, ... }: - -let - basics = data.basics // { - fullname = with data.basics.name; "${first} ${last}"; - }; +{ + html, + data, + lib, + ... +}: let + basics = + data.basics + // { + fullname = with data.basics.name; "${first} ${last}"; + }; col = html.div { class = "col"; style = "align-self: center"; }; center = container: content: - container { style = "text-align: center"; } content; + container {style = "text-align: center";} content; icon-lab = name: html.icon "lab la-${name}"; in { title = "About me"; priority = 0; body = with html; - with basics; [ - br - (div { class = "row"; } [ - (col [ - (imgWith { - src = avatar; - srcset = lib.concatStringsSep ", " - (builtins.map (size: "${avatar}.${size} ${size}w") [ + with basics; [ + br + (div {class = "row";} [ + (col [ + (imgWith { + src = avatar; + srcset = + lib.concatStringsSep ", " + (builtins.map (size: "${avatar}.${size} ${size}w") [ "128" "256" "512" - ] ++ [ "${avatar} 934w" ]); - sizes = "(max-width: 480px) 60vw, 30vw"; - alt = fullname; - style = '' - aspect-ratio: 1 / 1; - border-radius: 50%; - margin: auto; - display: block; - ''; - }) - (center h3 fullname) - (center p (with institution; [ position wbr "@ ${href url name}" ])) - ]) - (col (dl [ - (dt "${icon "las la-at"} e-mail") - (dd - (lib.mapAttrsToList (name: value: "${mailto value} (${name}) ${br}") - email)) - (dt "${icon "las la-key"} keys") - (dd (for keys.pgp (name: path: href path name))) - (dt "${icon "las la-map-marker"} address") - (dd (with location; '' - Office ${office}${br} - ${number} ${street}${br} - ${postalCode} ${city} - '')) - (dt "${icon "las la-globe"} online") - (dd (for profiles (name: value: - with value; - "${icon-lab icon} ${ - if value ? url then - href url name - else - "${name}: ${ - lines (for profiles (name: value: - with value; - "${icon-lab icon} ${href url name}")) - } ${br}" - }"))) - ])) + ] + ++ ["${avatar} 934w"]); + sizes = "(max-width: 480px) 60vw, 30vw"; + alt = fullname; + style = '' + aspect-ratio: 1 / 1; + border-radius: 50%; + margin: auto; + display: block; + ''; + }) + (center h3 fullname) + (center p (with institution; [position wbr "@ ${href url name}"])) ]) - description - ]; + (col (dl [ + (dt "${icon "las la-at"} e-mail") + (dd + (lib.mapAttrsToList (name: value: "${mailto value} (${name}) ${br}") + email)) + (dt "${icon "las la-key"} keys") + (dd (for keys.pgp (name: path: href path name))) + (dt "${icon "las la-map-marker"} address") + (dd (with location; '' + Office ${office}${br} + ${number} ${street}${br} + ${postalCode} ${city} + '')) + (dt "${icon "las la-globe"} online") + (dd (for profiles (name: value: + with value; "${icon-lab icon} ${ + if value ? url + then href url name + else "${name}: ${ + lines (for profiles (name: value: + with value; "${icon-lab icon} ${href url name}")) + } ${br}" + }"))) + ])) + ]) + description + ]; } diff --git a/html/default.nix b/html/default.nix index 0d4f19a..22686bc 100644 --- a/html/default.nix +++ b/html/default.nix @@ -1,7 +1,10 @@ -{ html, make, data, ... }: - -let - sections = html.sort.byKey "priority" (make ./sections.nix { }); +{ + html, + make, + data, + ... +}: let + sections = html.sort.byKey "priority" (make ./sections.nix {}); preloadFont = href: html.linkWith { inherit href; @@ -9,58 +12,60 @@ let as = "font"; }; fullname = with data.basics.name; "${first} ${last}"; -in with html; -doctype "html" + html.html { lang = "en"; } [ - (head [ - # Basic page needs - (metaWith { charset = "utf-8"; }) - (title fullname) - (metaWith { - name = "description"; - content = "Personal webpage of ${fullname}"; - }) - (metaWith { - name = "author"; - content = "Quentin Aristote"; - }) - (metaWith { - http-equiv = "x-ua-compatible"; - content = "ie=edge"; - }) - # Mobile specific needs - (metaWith { - name = "viewport"; - content = "width=device-width, initial-scale=1"; - }) - # Font - (linkWith { - rel = "stylesheet"; - href = "/static/css/fonts/line-awesome/line-awesome.min.css"; - }) - (preloadFont "/static/css/fonts/line-awesome/webfonts/la-solid-900.woff2") - (preloadFont "/static/css/fonts/line-awesome/webfonts/la-brands-400.woff2") - # CSS - (linkWith { - rel = "stylesheet"; - href = "/static/css/classless.min.css"; - }) - # Favicon - (linkWith { - rel = "icon"; - type = "image/png"; - href = "/static/icon.png"; - }) - ]) - (body [ - (main { role = "main"; } (for sections (section: section.body))) - (footer "Webpage ${ - href "#Software#aristoteWebpage" "generated" - } with the help of ${href "https://nixos.org/" "Nix"} and ${ - href "https://classless.de/" "Classless CSS" - }, and compressed with the help of ${ - href "https://github.com/uncss/uncss" "uncss" - }, ${href "https://yui.github.io/yuicompressor/" "YUI Compressor"} and ${ - href "https://imagemagick.org/" "ImageMagick" - }.") - ]) -] +in + with html; + doctype "html" + + html.html {lang = "en";} [ + (head [ + # Basic page needs + (metaWith {charset = "utf-8";}) + (title fullname) + (metaWith { + name = "description"; + content = "Personal webpage of ${fullname}"; + }) + (metaWith { + name = "author"; + content = "Quentin Aristote"; + }) + (metaWith { + http-equiv = "x-ua-compatible"; + content = "ie=edge"; + }) + # Mobile specific needs + (metaWith { + name = "viewport"; + content = "width=device-width, initial-scale=1"; + }) + # Font + (linkWith { + rel = "stylesheet"; + href = "/static/css/fonts/line-awesome/line-awesome.min.css"; + }) + (preloadFont "/static/css/fonts/line-awesome/webfonts/la-solid-900.woff2") + (preloadFont "/static/css/fonts/line-awesome/webfonts/la-brands-400.woff2") + # CSS + (linkWith { + rel = "stylesheet"; + href = "/static/css/classless.min.css"; + }) + # Favicon + (linkWith { + rel = "icon"; + type = "image/png"; + href = "/static/icon.png"; + }) + ]) + (body [ + (main {role = "main";} (for sections (section: section.body))) + (footer "Webpage ${ + href "#Software#aristoteWebpage" "generated" + } with the help of ${href "https://nixos.org/" "Nix"} and ${ + href "https://classless.de/" "Classless CSS" + }, and compressed with the help of ${ + href "https://github.com/uncss/uncss" "uncss" + }, ${href "https://yui.github.io/yuicompressor/" "YUI Compressor"} and ${ + href "https://imagemagick.org/" "ImageMagick" + }.") + ]) + ] diff --git a/html/education/default.nix b/html/education/default.nix index 56f0915..0dcc977 100644 --- a/html/education/default.nix +++ b/html/education/default.nix @@ -1,8 +1,12 @@ -{ html, data, lib, ... }: - -let +{ + html, + data, + lib, + ... +}: let education = data.education; - sortByDateStart = html.sort.reverse.byFun + sortByDateStart = + html.sort.reverse.byFun (item: with item.date.start; day + 100 * month + 10000 * year); in { title = "Education"; @@ -18,20 +22,19 @@ in { (dd [ (lib.optionalString (item ? years) (for (sortByDateStart years) (year: with year; - details [ - (summary [ - (with program; - "${studyType} @ ${href url (abbr { title = name; } acronym)}") - br - (with date; small (timerange start end)) - ]) - description - (for courses (category: list: - details [ - (summary "${category} courses") - (lib.concatStringsSep " · " (lib.naturalSort list)) - ])) - ]))) + details [ + (summary [ + (with program; "${studyType} @ ${href url (abbr {title = name;} acronym)}") + br + (with date; small (timerange start end)) + ]) + description + (for courses (category: list: + details [ + (summary "${category} courses") + (lib.concatStringsSep " · " (lib.naturalSort list)) + ])) + ]))) description ]) ])); diff --git a/html/experience/default.nix b/html/experience/default.nix index abe1109..b7f258b 100644 --- a/html/experience/default.nix +++ b/html/experience/default.nix @@ -1,6 +1,10 @@ -{ html, data, lib, ... }: - -let experience = data.experience; +{ + html, + data, + lib, + ... +}: let + experience = data.experience; in { title = "Experience"; priority = 20; @@ -8,21 +12,22 @@ in { dl (for (sort.reverse.byFun (item: with item.date.start; day + 100 * month + 10000 * year) experience) (item: - with item; [ - (dt [ - (with institution; "${position} @ ${href url name}, ${location}") - br - (small (lib.concatStringsSep " · " - ([ (with date; timerange start end) ] - ++ lib.optional (item ? supervisors) "supervised by ${ - lib.concatStringsSep " " (for supervisors - (supervisor: with supervisor; href url name)) - }" ++ lib.optional (item ? assets) (lib.concatStringsSep " " - (for assets (asset: - with asset; + with item; [ + (dt [ + (with institution; "${position} @ ${href url name}, ${location}") + br + (small (lib.concatStringsSep " · " + ([(with date; timerange start end)] + ++ lib.optional (item ? supervisors) "supervised by ${ + lib.concatStringsSep " " (for supervisors + (supervisor: with supervisor; href url name)) + }" + ++ lib.optional (item ? assets) (lib.concatStringsSep " " + (for assets (asset: + with asset; href "#${type}#${id}" "${icon "las la-paperclip"} ${name}")))))) - ]) - (dd description) - ])); + ]) + (dd description) + ])); } diff --git a/html/languages/default.nix b/html/languages/default.nix index f7c49f0..06df694 100644 --- a/html/languages/default.nix +++ b/html/languages/default.nix @@ -1,13 +1,14 @@ -{ html, data, ... }: - -let languages = data.languages; +{ + html, + data, + ... +}: let + languages = data.languages; in { title = "Languages"; priority = 40; - body = with html; - (for languages (language: - with language; - "${ - lib.concatStrings (for icon.codepoints (codepoint: "&x${codepoint}")) - } ${name} (${proficiency})")); + body = with html; (for languages (language: + with language; "${ + lib.concatStrings (for icon.codepoints (codepoint: "&x${codepoint}")) + } ${name} (${proficiency})")); } diff --git a/html/publications/default.nix b/html/publications/default.nix index 289f9e3..800d3aa 100644 --- a/html/publications/default.nix +++ b/html/publications/default.nix @@ -1,6 +1,9 @@ -{ html, data, lib, ... }: - -let +{ + html, + data, + lib, + ... +}: let publications = data.publications; attrValsOpt = attrs: attrSet: lib.attrVals (builtins.filter (attr: lib.hasAttr attr attrSet) attrs) @@ -12,58 +15,68 @@ let format = publication: with html; with publication; - { - inherit id title url year abstract cite; - } // (let - authorsOther = - lib.remove "${data.basics.name.first} ${data.basics.name.last}" - (builtins.map (author: "${author.given} ${author.family}") author); - in lib.optionalAttrs (authorsOther != [ ]) { - authors = "With ${lib.concatStringsSep ", " authorsOther}"; - }) // lib.optionalAttrs (publication ? container-title) { - published = "In ${em container-title}" + concatStringsPrefix ", " - (attrValsOpt [ "volume" "issue" "publisher" ] publication); - } // lib.optionalAttrs (publication ? ISBN) { - isbn = "${small "ISBN"}: ${ISBN}"; - } // lib.optionalAttrs (publication ? ISSN) { - issn = "${small "ISSN"}: ${ISSN}"; - } // lib.optionalAttrs (publication ? DOI) { - doi = "${small "DOI"}: ${href "https://doi.org/${DOI}" (code DOI)}"; - }; + { + inherit id title url year abstract cite; + } + // (let + authorsOther = + lib.remove "${data.basics.name.first} ${data.basics.name.last}" + (builtins.map (author: "${author.given} ${author.family}") author); + in + lib.optionalAttrs (authorsOther != []) { + authors = "With ${lib.concatStringsSep ", " authorsOther}"; + }) + // lib.optionalAttrs (publication ? container-title) { + published = + "In ${em container-title}" + + concatStringsPrefix ", " + (attrValsOpt ["volume" "issue" "publisher"] publication); + } + // lib.optionalAttrs (publication ? ISBN) { + isbn = "${small "ISBN"}: ${ISBN}"; + } + // lib.optionalAttrs (publication ? ISSN) { + issn = "${small "ISSN"}: ${ISSN}"; + } + // lib.optionalAttrs (publication ? DOI) { + doi = "${small "DOI"}: ${href "https://doi.org/${DOI}" (code DOI)}"; + }; in { title = "Publications"; priority = 10; body = with html; - dl (for (sort.reverse.byPath [ "issued" "date-parts" ] publications) - (publication: - let formatted = format publication; - in with formatted; - lines [ - (dt { id = "Publications#${id}"; } - "${href { target = "_blank"; } url title} (${year})") - (dd [ - (concatStringsSuffix ". " - (attrValsOpt [ "authors" "published" "isbn" "issn" "doi" ] - formatted)) - (details [ - (summary "More") - (dl [ - (dt "Abstract.") - (dd (blockquote abstract)) - (dt "Cite.") - (let - citeWith = title: attr: - details [ - (summary title) - (pre (code (lib.getAttr attr cite))) - ]; - in dd [ - (citeWith "BibLaTeX" "biblatex") - (citeWith "BibTeX" "bibtex") - (citeWith "CSL JSON" "csljson") + dl (for (sort.reverse.byPath ["issued" "date-parts"] publications) + (publication: let + formatted = format publication; + in + with formatted; + lines [ + (dt {id = "Publications#${id}";} + "${href {target = "_blank";} url title} (${year})") + (dd [ + (concatStringsSuffix ". " + (attrValsOpt ["authors" "published" "isbn" "issn" "doi"] + formatted)) + (details [ + (summary "More") + (dl [ + (dt "Abstract.") + (dd (blockquote abstract)) + (dt "Cite.") + (let + citeWith = title: attr: + details [ + (summary title) + (pre (code (lib.getAttr attr cite))) + ]; + in + dd [ + (citeWith "BibLaTeX" "biblatex") + (citeWith "BibTeX" "bibtex") + (citeWith "CSL JSON" "csljson") + ]) ]) ]) ]) - ]) - ])); + ])); } diff --git a/html/sections.nix b/html/sections.nix index 4c4f0b0..3c4065f 100644 --- a/html/sections.nix +++ b/html/sections.nix @@ -1,19 +1,22 @@ -{ html, make, ... }: - -let +{ + html, + make, + ... +}: let sectionTemplate = section: { inherit (section) title priority; - body = html.section { id = section.title; } [ + body = html.section {id = section.title;} [ (html.h1 section.title) section.body ]; }; - makeSection = path: sectionTemplate (make path { }); -in builtins.map makeSection [ - ./basics - ./education - ./experience - # ./languages - ./publications - ./software -] + makeSection = path: sectionTemplate (make path {}); +in + builtins.map makeSection [ + ./basics + ./education + ./experience + # ./languages + ./publications + ./software + ] diff --git a/html/software/default.nix b/html/software/default.nix index 49f4627..9d42345 100644 --- a/html/software/default.nix +++ b/html/software/default.nix @@ -1,27 +1,34 @@ -{ html, data, lib, ... }: - -let +{ + html, + data, + lib, + ... +}: let software = data.software; format = softwarePiece: with html; with softwarePiece; - { - inherit id title abstract; - url = URL; - } // (let - authorsOther = lib.remove data.basics.name - (builtins.map (author: "${author.given} ${author.family}") author); - in lib.optionalAttrs (authorsOther != [ ]) { - authors = "With ${lib.concatStringsSep ", " authorsOther}"; - }); + { + inherit id title abstract; + url = URL; + } + // (let + authorsOther = + lib.remove data.basics.name + (builtins.map (author: "${author.given} ${author.family}") author); + in + lib.optionalAttrs (authorsOther != []) { + authors = "With ${lib.concatStringsSep ", " authorsOther}"; + }); in { title = "Software"; priority = 15; body = with html; - dl (for (sort.byPath [ "title" ] software) (softwarePiece: - let formatted = format softwarePiece; - in with formatted; [ - (dt { id = "Software#${id}"; } (href { target = "_blank"; } url title)) + dl (for (sort.byPath ["title"] software) (softwarePiece: let + formatted = format softwarePiece; + in + with formatted; [ + (dt {id = "Software#${id}";} (href {target = "_blank";} url title)) (dd abstract) ])); } diff --git a/lib/default.nix b/lib/default.nix index 2e3127d..0264e55 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,5 +1,3 @@ -{ lib }: - -{ - pp.html = import ./html.nix { inherit lib; }; +{lib}: { + pp.html = import ./html.nix {inherit lib;}; } diff --git a/lib/html.nix b/lib/html.nix index f66184b..105888e 100644 --- a/lib/html.nix +++ b/lib/html.nix @@ -1,34 +1,30 @@ -{ lib, ... }: - -let +{lib, ...}: let comment = content: ""; lines = content: - if lib.isList content then - (if content == [ ] then - "" - else - lines (builtins.head content) + "\n" + lines (builtins.tail content)) - else - content; + if lib.isList content + then + ( + if content == [] + then "" + else lines (builtins.head content) + "\n" + lines (builtins.tail content) + ) + else content; sortByFun = cmp: f: lib.sort (x: y: cmp (f x) (f y)); sortByPath = cmp: keys: sortByFun cmp (lib.getAttrFromPath keys); - sortByKey = cmp: key: sortByPath cmp [ key ]; + sortByKey = cmp: key: sortByPath cmp [key]; for = iterable: f: - if lib.isList iterable then - builtins.map f iterable - else - lib.mapAttrsToList f iterable; + if lib.isList iterable + then builtins.map f iterable + else lib.mapAttrsToList f iterable; setAttr = attr: value: ''${attr}="${value}"''; - tagWithAttrs = tag: attrs: - "<${tag}${ - lib.concatMapStrings (x: " ${x}") (lib.mapAttrsToList setAttr attrs) - }>"; + tagWithAttrs = tag: attrs: "<${tag}${ + lib.concatMapStrings (x: " ${x}") (lib.mapAttrsToList setAttr attrs) + }>"; tryOverride = f: arg: - if lib.isAttrs arg then - tryOverride (attrs: content: f (arg // attrs) content) - else - f { } arg; + if lib.isAttrs arg + then tryOverride (attrs: content: f (arg // attrs) content) + else f {} arg; container = tag: tryOverride (attrs: content: "${tagWithAttrs tag attrs}${lines content}"); @@ -169,7 +165,7 @@ let "template" ]; tagsContainerFuns = - builtins.foldl' (module: tag: module // { "${tag}" = container tag; }) { } + builtins.foldl' (module: tag: module // {"${tag}" = container tag;}) {} tagsContainer; tagsEmpty = [ @@ -189,61 +185,82 @@ let "track" "wbr" ]; - tagsEmptyFuns = builtins.foldl' (module: tag: - let tagWith = empty tag; - in module // { + tagsEmptyFuns = builtins.foldl' (module: tag: let + tagWith = empty tag; + in + module + // { "${tag}With" = tagWith; - "${tag}" = tagWith { }; - }) { } tagsEmpty; + "${tag}" = tagWith {}; + }) {} + tagsEmpty; file = path: "/static/files/${path}"; - href = tryOverride (attrs: url: content: - tagsContainerFuns.a ({ href = url; } // attrs) content); + href = + tryOverride (attrs: url: content: + tagsContainerFuns.a ({href = url;} // attrs) content); icon = - tryOverride (attrs: id: tagsContainerFuns.i (attrs // { class = id; }) ""); + tryOverride (attrs: id: tagsContainerFuns.i (attrs // {class = id;}) ""); mailto = tryOverride (attrs: address: href attrs "mailto:${address}" address); timerange = let - print = date: - let - year = builtins.toString date.year; - month = lib.optionalString (date.month < 10) "0" - + builtins.toString date.month; - monthPretty = builtins.head (lib.drop (date.month - 1) [ - "jan" - "feb" - "mar" - "apr" - "may" - "jun" - "jul" - "aug" - "sep" - "oct" - "nov" - "dev" - ]); - day = builtins.toString date.day; - in tagsContainerFuns.time { date = "${year}-${month}-${day}"; } + print = date: let + year = builtins.toString date.year; + month = + lib.optionalString (date.month < 10) "0" + + builtins.toString date.month; + monthPretty = builtins.head (lib.drop (date.month - 1) [ + "jan" + "feb" + "mar" + "apr" + "may" + "jun" + "jul" + "aug" + "sep" + "oct" + "nov" + "dev" + ]); + day = builtins.toString date.day; + in + tagsContainerFuns.time {date = "${year}-${month}-${day}";} "${monthPretty}. ${year}"; - in start: end: "${print start} - ${print end}"; + in + start: end: "${print start} - ${print end}"; doctype = type: '' ''; -in tagsContainerFuns // tagsEmptyFuns // { - inherit for comment container doctype empty file href icon lines mailto - timerange; -} // { - sort = let - lt = x: y: x < y; - gt = x: y: x > y; - in { - byKey = sortByKey lt; - byPath = sortByPath lt; - byFun = sortByFun lt; - reverse = { - byKey = sortByKey gt; - byPath = sortByPath gt; - byFun = sortByFun gt; +in + tagsContainerFuns + // tagsEmptyFuns + // { + inherit + for + comment + container + doctype + empty + file + href + icon + lines + mailto + timerange + ; + } + // { + sort = let + lt = x: y: x < y; + gt = x: y: x > y; + in { + byKey = sortByKey lt; + byPath = sortByPath lt; + byFun = sortByFun lt; + reverse = { + byKey = sortByKey gt; + byPath = sortByPath gt; + byFun = sortByFun gt; + }; }; - }; -} + } diff --git a/pkgs/line-awesome-css.nix b/pkgs/line-awesome-css.nix index 3bbfaa3..45b902e 100644 --- a/pkgs/line-awesome-css.nix +++ b/pkgs/line-awesome-css.nix @@ -1,16 +1,19 @@ -{ stdenv, fetchurl, fontsRelativeDirectory ? "./webfonts", fontDisplay ? "swap" +{ + stdenv, + fetchurl, + fontsRelativeDirectory ? "./webfonts", + fontDisplay ? "swap", }: stdenv.mkDerivation rec { name = "line-awesome.css"; version = "v1.2.1"; src = fetchurl { - url = - "https://raw.githubusercontent.com/icons8/line-awesome/${version}/dist/line-awesome/css/line-awesome.css"; + url = "https://raw.githubusercontent.com/icons8/line-awesome/${version}/dist/line-awesome/css/line-awesome.css"; sha256 = "sha256:GU24Xz6l3Ww4ZCcL2ByssTe04fHBRz9k2aZVRdj0xm4="; }; - phases = [ "installPhase" ]; + phases = ["installPhase"]; installPhase = '' cp $src $out substituteInPlace $out --replace '../fonts' '${fontsRelativeDirectory}' \ -- cgit v1.2.3