Skip to content

Commit 2be19b1

Browse files
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.
1 parent 2fe526c commit 2be19b1

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

assets/discussion-icon.svg

Lines changed: 1 addition & 0 deletions
Loading

src/html.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,24 @@ func makeBibEntryTitle(entry *bibEntry) string {
6868
`</span>`,
6969
}
7070
// Icons are on the right side.
71-
icons := []string{
72-
`<span class="icons">`,
71+
icons := makeIcons(entry)
72+
return strings.Join(append(title, icons...), "\n")
73+
}
74+
75+
func makeIcons(entry *bibEntry) []string {
76+
var icons = []string{`<span class="icons">`}
77+
78+
// Not all references have a corresponding net4people discussion but if they
79+
// do, add an icon.
80+
if field, ok := entry.Fields["net4people_url"]; ok {
81+
s := fmt.Sprintf("<a href='%s'>", field.String()) +
82+
`<img class="icon" title="net4people discussion" src="assets/discussion-icon.svg" alt="Discussion icon">` +
83+
`</a>`
84+
icons = append(icons, s)
85+
}
86+
87+
// Add icons that are always present.
88+
icons = append(icons, []string{
7389
fmt.Sprintf("<a href='%s'>", entry.Fields["url"].String()),
7490
`<img class="icon" title="Download paper" src="assets/pdf-icon.svg" alt="Download icon">`,
7591
`</a>`,
@@ -82,9 +98,9 @@ func makeBibEntryTitle(entry *bibEntry) string {
8298
fmt.Sprintf("<a href='#%s'>", entry.CiteName),
8399
`<img class="icon" title="Link to paper" src="assets/link-icon.svg" alt="Paper link icon">`,
84100
`</a>`,
85-
`</span>`,
86-
}
87-
return strings.Join(append(title, icons...), "\n")
101+
}...)
102+
103+
return append(icons, `</span>`)
88104
}
89105

90106
func makeBibEntryAuthors(entry *bibEntry) string {

0 commit comments

Comments
 (0)