package grils import ( "database/sql" "fmt" "strconv" "strings" "time" "fagott.pw/grilist/modules/series" "github.com/lib/pq" ) type DataSource int const ( DataSourceACD DataSource = iota DataSourceAniDB DataSourceAnilist ) type Trait struct { Name string Value string OfficialValue string } type Gril struct { ID int KanjiName string RomajiName string OtherNames []string Age sql.NullInt64 Birthday pq.NullTime Tags []string Traits []Trait ForeignIDs map[DataSource]int UpdatedAt time.Time Lists []int Series []series.Series } func (g *Gril) Slug() string { if g.RomajiName == "" { return strconv.Itoa(g.ID) } return fmt.Sprintf( "%d/%s", g.ID, strings.Replace(g.RomajiName, " ", "", -1)) } func ImagePath(id int, useThumbnail bool) string { if useThumbnail { return fmt.Sprintf("http://img.grilist.moe/gril/thumb/%d.jpg", id) } return fmt.Sprintf("http://img.grilist.moe/gril/full/%d.jpg", id) } func (g *Gril) ImagePath(prioritizeThumbnail bool) string { return ImagePath(g.ID, prioritizeThumbnail) }