From 2be19b1b6e31451e7ac56fd80d60b6eb02c6c6c1 Mon Sep 17 00:00:00 2001 From: Philipp Winter Date: Sat, 25 May 2024 08:48:25 -0500 Subject: [PATCH] Add support for net4people links. We're going to use the `net4people_url` BibTeX key to link to a paper's net4people discussion. BibTeX parsers don't know about this key and should therefore ignore it. --- assets/discussion-icon.svg | 1 + src/html.go | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 assets/discussion-icon.svg diff --git a/assets/discussion-icon.svg b/assets/discussion-icon.svg new file mode 100644 index 0000000..62bdd3a --- /dev/null +++ b/assets/discussion-icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/html.go b/src/html.go index 623d484..ed6e581 100644 --- a/src/html.go +++ b/src/html.go @@ -68,8 +68,24 @@ func makeBibEntryTitle(entry *bibEntry) string { ``, } // Icons are on the right side. - icons := []string{ - ``, + icons := makeIcons(entry) + return strings.Join(append(title, icons...), "\n") +} + +func makeIcons(entry *bibEntry) []string { + var icons = []string{``} + + // Not all references have a corresponding net4people discussion but if they + // do, add an icon. + if field, ok := entry.Fields["net4people_url"]; ok { + s := fmt.Sprintf("", field.String()) + + `Discussion icon` + + `` + icons = append(icons, s) + } + + // Add icons that are always present. + icons = append(icons, []string{ fmt.Sprintf("", entry.Fields["url"].String()), `Download icon`, ``, @@ -82,9 +98,9 @@ func makeBibEntryTitle(entry *bibEntry) string { fmt.Sprintf("", entry.CiteName), `Paper link icon`, ``, - ``, - } - return strings.Join(append(title, icons...), "\n") + }...) + + return append(icons, ``) } func makeBibEntryAuthors(entry *bibEntry) string {