mirror of
https://github.com/NullHypothesis/censorbib.git
synced 2025-07-22 22:21:15 -04:00
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.
This commit is contained in:
parent
2fe526c0c0
commit
2be19b1b6e
2 changed files with 22 additions and 5 deletions
26
src/html.go
26
src/html.go
|
@ -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 net4people discussion but if they
|
||||
// do, add an icon.
|
||||
if field, ok := entry.Fields["net4people_url"]; ok {
|
||||
s := fmt.Sprintf("<a href='%s'>", field.String()) +
|
||||
`<img class="icon" title="net4people 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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue