36 lines
503 B
Go
36 lines
503 B
Go
package tal
|
|
|
|
import "fmt"
|
|
|
|
type Book struct {
|
|
Path string
|
|
Base string
|
|
Meta map[string]string
|
|
}
|
|
|
|
func (b *Book) String() string {
|
|
title := b.Meta["SORTtitle"]
|
|
if title == "" {
|
|
title = b.Meta["title"]
|
|
}
|
|
|
|
author := b.Meta["SORTauthors"]
|
|
if author == "" {
|
|
author = b.Meta["author"]
|
|
}
|
|
|
|
if title != "" && author != "" {
|
|
return fmt.Sprintf("%s - %s", author, title)
|
|
}
|
|
|
|
if title == "" && author != "" {
|
|
return author
|
|
}
|
|
|
|
if title != "" && author == "" {
|
|
return title
|
|
}
|
|
|
|
return b.Base
|
|
}
|