From 1be63b59d0f9d1739c5fdc75e1f82079f6dd9d31 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Mon, 29 Jun 2020 05:52:05 +0200 Subject: pkgs/profpatsch/profpatsch.de: fetch webfonts --- pkgs/profpatsch/profpatsch.de/default.nix | 53 ++++++++++++++++------ pkgs/profpatsch/profpatsch.de/index.html.nix | 4 +- pkgs/profpatsch/profpatsch.de/main.css | 49 -------------------- pkgs/profpatsch/profpatsch.de/main.css.nix | 67 ++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 63 deletions(-) delete mode 100644 pkgs/profpatsch/profpatsch.de/main.css create mode 100644 pkgs/profpatsch/profpatsch.de/main.css.nix (limited to 'pkgs/profpatsch/profpatsch.de') diff --git a/pkgs/profpatsch/profpatsch.de/default.nix b/pkgs/profpatsch/profpatsch.de/default.nix index 9fa5d988..bed5c5c7 100644 --- a/pkgs/profpatsch/profpatsch.de/default.nix +++ b/pkgs/profpatsch/profpatsch.de/default.nix @@ -9,14 +9,32 @@ let sha256 = "0gbfbfcbcpl8nq2shknsyz5pirf5wbnb54m3dynxs68x9y4sbxpp"; }; + quattrocento-latin = pkgs.fetchurl { + url = "https://fonts.gstatic.com/s/quattrocento/v11/OZpEg_xvsDZQL_LKIF7q4jP3w2j6.woff2"; + sha256 = "161dzd0az6zw8js1q8ikf4yhm0h9zidc5wqlnsrpzw5npdzmbzbi"; + }; + + open-sans-latin = pkgs.fetchurl { + url = "https://fonts.gstatic.com/s/opensans/v17/mem5YaGs126MiZpBA-UN_r8OUuhp.woff2"; + sha256 = "1qj6qwajfjcs4l0mwj5lj7jdbc35y3rkqrsz2w41zcfzh8nywxzn"; + }; + joinPath = lib.concatStringsSep "/"; stderr-tee = writeExecline "stderr-tee" {} [ "pipeline" [ bins.multitee "0-1,2" ] "$@" ]; + applyTemplate = name: templateNix: deps: + pkgs.writeText name + (import templateNix + (lib.mapAttrs + # relative to the root of the webpage + (k: v: "/" + (joinPath (v.relativeDir ++ [ v.relativeFile ]))) + deps)); + staticFiles = - let + rec { jsJquery = { relativeDir = [ "js" ]; relativeFile = "jquery.js"; @@ -30,7 +48,22 @@ let cssMain = { relativeDir = [ "css" ]; relativeFile = "main.css"; - path = ./main.css; + path = applyTemplate "main.css" ./main.css.nix { + inherit + fontsQuattrocentoLatin + fontsOpenSansLatin + ; + }; + }; + fontsQuattrocentoLatin = { + relativeDir = [ "fonts" ]; + relativeFile = "quattrocento-latin.woff2"; + path = quattrocento-latin; + }; + fontsOpenSansLatin = { + relativeDir = [ "fonts" ]; + relativeFile = "open-sans-latin.woff2"; + path = open-sans-latin; }; cv_pdf = { relativeDir = []; @@ -45,18 +78,12 @@ let index_html = { relativeDir = []; relativeFile = "index.html"; - path = pkgs.writeText "index.html" - (import ./index.html.nix - (lib.mapAttrs - (k: v: joinPath (v.relativeDir ++ [ v.relativeFile ])) - { - inherit jsJquery cssNormalize cssMain; - inherit cv_pdf id_txt; - })); + path = applyTemplate "index.html" ./index.html.nix { + inherit jsJquery; + inherit cssNormalize cssMain; + inherit cv_pdf id_txt; + }; }; - in { - inherit jsJquery cssNormalize cssMain; - inherit cv_pdf id_txt index_html; }; record-get = writeRustSimple "record-get" { diff --git a/pkgs/profpatsch/profpatsch.de/index.html.nix b/pkgs/profpatsch/profpatsch.de/index.html.nix index 95e6f2ca..141570ad 100644 --- a/pkgs/profpatsch/profpatsch.de/index.html.nix +++ b/pkgs/profpatsch/profpatsch.de/index.html.nix @@ -1,4 +1,6 @@ -{ jsJquery, cssNormalize, cssMain, id_txt, cv_pdf }: +{ jsJquery +, cssNormalize, cssMain +, id_txt, cv_pdf }: '' diff --git a/pkgs/profpatsch/profpatsch.de/main.css b/pkgs/profpatsch/profpatsch.de/main.css deleted file mode 100644 index f3c862dd..00000000 --- a/pkgs/profpatsch/profpatsch.de/main.css +++ /dev/null @@ -1,49 +0,0 @@ -@import url(http://fonts.googleapis.com/css?family=Quattrocento|Open+Sans:400,300); - -body { - font-family: 'Open Sans', sans-serif; - font-size: 1em; -} - -main { - margin: 0 auto; - width: 500px; -} - -#title { - text-align: center; -} -#title h1 { - font-size: 4em; - font-weight: 300; - margin-bottom: 0em; -} -#title h2 { - font-size: 1.5em; - font-weight: 300; - margin-top: 0; -} -#title h2 a { - color: #000; - text-decoration: none; -} -#title h2 a:hover { - color: #333; -} -#title hr { - width: 100px; - border: 1px solid grey; - margin-bottom: 2em; -} - -p { - font-family: 'Quattrocento', serif; - text-align: justify; - line-height: 1.5em; -} - -#codeblock { - text-align: center; - font-family: monospace; - font-size: 16px; -} diff --git a/pkgs/profpatsch/profpatsch.de/main.css.nix b/pkgs/profpatsch/profpatsch.de/main.css.nix new file mode 100644 index 00000000..9ac10fc5 --- /dev/null +++ b/pkgs/profpatsch/profpatsch.de/main.css.nix @@ -0,0 +1,67 @@ +{ fontsQuattrocentoLatin, fontsOpenSansLatin }: +'' +/* latin */ +@font-face { + font-family: 'Quattrocento'; + font-style: normal; + font-weight: 400; + src: local('Quattrocento'), url(${fontsQuattrocentoLatin}) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} +/* latin */ +@font-face { + font-family: 'Open Sans'; + font-style: normal; + font-weight: 300; + src: local('Open Sans Light'), local('OpenSans-Light'), url(${fontsOpenSansLatin}) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; +} + +body { + font-family: 'Open Sans', sans-serif; + font-size: 1em; +} + +main { + margin: 0 auto; + width: 500px; +} + +#title { + text-align: center; +} +#title h1 { + font-size: 4em; + font-weight: 300; + margin-bottom: 0em; +} +#title h2 { + font-size: 1.5em; + font-weight: 300; + margin-top: 0; +} +#title h2 a { + color: #000; + text-decoration: none; +} +#title h2 a:hover { + color: #333; +} +#title hr { + width: 100px; + border: 1px solid grey; + margin-bottom: 2em; +} + +p { + font-family: 'Quattrocento', serif; + text-align: justify; + line-height: 1.5em; +} + +#codeblock { + text-align: center; + font-family: monospace; + font-size: 16px; +} +'' -- cgit 1.4.1