diff options
Diffstat (limited to 'model/icon.go')
-rw-r--r-- | model/icon.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/model/icon.go b/model/icon.go index 7bf12bf..3608a0a 100644 --- a/model/icon.go +++ b/model/icon.go @@ -4,6 +4,11 @@ package model +import ( + "encoding/base64" + "fmt" +) + // Icon represents a website icon (favicon) type Icon struct { ID int64 `json:"id"` @@ -12,6 +17,14 @@ type Icon struct { Content []byte `json:"content"` } +// DataURL returns the data URL of the icon. +func (i *Icon) DataURL() string { + return fmt.Sprintf("%s;base64,%s", i.MimeType, base64.StdEncoding.EncodeToString(i.Content)) +} + +// Icons represents a list of icon. +type Icons []*Icon + // FeedIcon is a jonction table between feeds and icons type FeedIcon struct { FeedID int64 `json:"feed_id"` |