summaryrefslogtreecommitdiff
path: root/html/research/writings.nix
diff options
context:
space:
mode:
Diffstat (limited to 'html/research/writings.nix')
-rw-r--r--html/research/writings.nix94
1 files changed, 94 insertions, 0 deletions
diff --git a/html/research/writings.nix b/html/research/writings.nix
new file mode 100644
index 0000000..d34ea66
--- /dev/null
+++ b/html/research/writings.nix
@@ -0,0 +1,94 @@
+{
+ html,
+ data,
+ lib,
+ ...
+}: let
+ attrValsOpt = attrs: attrSet:
+ lib.attrVals (builtins.filter (attr: lib.hasAttr attr attrSet) attrs)
+ attrSet;
+ concatStringsPrefix = prefix: strings:
+ lib.concatStrings (builtins.map (string: prefix + string) strings);
+ concatStringsSuffix = suffix: strings:
+ lib.concatStrings (builtins.map (string: string + suffix) strings);
+ 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 ? note) {
+ note = publication.note;
+ }
+ // lib.optionalAttrs (publication ? container-title) {
+ published =
+ "In ${em container-title}"
+ + concatStringsPrefix ", "
+ (attrValsOpt ["volume" "issue" "publisher"] publication);
+ }
+ // lib.optionalAttrs (publication ? event-title) {
+ published = "At ${em event-title}";
+ }
+ // 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)}";
+ };
+ listPublications = collection:
+ with html;
+ section [
+ (dl (for (sort.reverse.byPath ["issued" "date-parts"] collection)
+ (publication: let
+ formatted = format publication;
+ in
+ with formatted;
+ lines [
+ (dt {id = "Writings#${id}";}
+ "${href {target = "_blank";} url (em title)} (${year})")
+ (dd [
+ (concatStringsSuffix ". "
+ (attrValsOpt ["authors" "note" "published" "isbn" "issn" "doi"]
+ formatted))
+ (details [
+ (summary "More")
+ (dl [
+ (dt "Abstract.")
+ (dd (blockquote abstract))
+ (dt "Cite.")
+ (let
+ citeWith = title: type:
+ details [
+ (summary title)
+ (pre (code (
+ lib.readFile "${data.publications.files}/${type}/${id}"
+ )))
+ ];
+ in
+ dd [
+ (citeWith "BibLaTeX" "biblatex")
+ (citeWith "BibTeX" "bibtex")
+ (citeWith "CSL JSON" "csljson")
+ ])
+ ])
+ ])
+ ])
+ ])))
+ ];
+in {
+ conferences = listPublications data.publications.conferences;
+ journals = listPublications data.publications.journals;
+ misc = listPublications data.publications.misc;
+ reports = listPublications data.publications.reports;
+}