icon.go 824 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2017 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package model // import "miniflux.app/model"
  5. import (
  6. "encoding/base64"
  7. "fmt"
  8. )
  9. // Icon represents a website icon (favicon)
  10. type Icon struct {
  11. ID int64 `json:"id"`
  12. Hash string `json:"hash"`
  13. MimeType string `json:"mime_type"`
  14. Content []byte `json:"content"`
  15. }
  16. // DataURL returns the data URL of the icon.
  17. func (i *Icon) DataURL() string {
  18. return fmt.Sprintf("%s;base64,%s", i.MimeType, base64.StdEncoding.EncodeToString(i.Content))
  19. }
  20. // Icons represents a list of icons.
  21. type Icons []*Icon
  22. // FeedIcon is a junction table between feeds and icons.
  23. type FeedIcon struct {
  24. FeedID int64 `json:"feed_id"`
  25. IconID int64 `json:"icon_id"`
  26. }