Merge pull request #39 from NullHypothesis/add-net4people-links

Add net4people discussion links to papers.
This commit is contained in:
Philipp Winter 2024-05-25 09:30:01 -05:00 committed by GitHub
commit 2c1e7652ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 5 deletions

View file

@ -68,8 +68,24 @@ func makeBibEntryTitle(entry *bibEntry) string {
`</span>`,
}
// Icons are on the right side.
icons := []string{
`<span class="icons">`,
icons := makeIcons(entry)
return strings.Join(append(title, icons...), "\n")
}
func makeIcons(entry *bibEntry) []string {
var icons = []string{`<span class="icons">`}
// Not all references have a corresponding discussion (e.g., on net4people)
// but if they do, add an icon.
if field, ok := entry.Fields["discussion_url"]; ok {
s := fmt.Sprintf("<a href='%s'>", field.String()) +
`<img class="icon" title="Online discussion" src="assets/discussion-icon.svg" alt="Discussion icon">` +
`</a>`
icons = append(icons, s)
}
// Add icons that are always present.
icons = append(icons, []string{
fmt.Sprintf("<a href='%s'>", entry.Fields["url"].String()),
`<img class="icon" title="Download paper" src="assets/pdf-icon.svg" alt="Download icon">`,
`</a>`,
@ -82,9 +98,9 @@ func makeBibEntryTitle(entry *bibEntry) string {
fmt.Sprintf("<a href='#%s'>", entry.CiteName),
`<img class="icon" title="Link to paper" src="assets/link-icon.svg" alt="Paper link icon">`,
`</a>`,
`</span>`,
}
return strings.Join(append(title, icons...), "\n")
}...)
return append(icons, `</span>`)
}
func makeBibEntryAuthors(entry *bibEntry) string {