Documentation ¶
Index ¶
- Variables
- type FaviconImage
- type FaviconList
- func (l *FaviconList) PreProcess(convert func(in []byte) ([]byte, error)) error
- func (l *FaviconList) ProduceForExt(ext string) (raw []byte, contentType string, err error)
- func (l *FaviconList) ProduceIco() ([]byte, error)
- func (l *FaviconList) ProducePng() ([]byte, error)
- func (l *FaviconList) ProduceSvg() ([]byte, error)
- type Favicons
Constants ¶
This section is empty.
Variables ¶
var ErrFaviconNotFound = errors.New("favicon not found")
var ErrInvalidFaviconExtension = errors.New("invalid favicon extension")
var Logger = logger.Logger.WithPrefix("Violet Favicons")
Functions ¶
This section is empty.
Types ¶
type FaviconImage ¶
FaviconImage stores the url, hash and raw bytes of an image
func CreateFaviconImage ¶
func CreateFaviconImage(url sql.NullString) *FaviconImage
CreateFaviconImage outputs a FaviconImage with the specified URL or nil if the URL is an empty string.
type FaviconList ¶
type FaviconList struct { Ico *FaviconImage // can be generated from png with wrapper Png *FaviconImage // can be generated from svg with inkscape Svg *FaviconImage }
FaviconList contains the ico, png and svg icons for separate favicons
func (*FaviconList) PreProcess ¶
func (l *FaviconList) PreProcess(convert func(in []byte) ([]byte, error)) error
PreProcess takes an input of the svg2png conversion function and outputs an error if the SVG, PNG or ICO fails to download or generate
func (*FaviconList) ProduceForExt ¶
func (l *FaviconList) ProduceForExt(ext string) (raw []byte, contentType string, err error)
ProduceForExt outputs the bytes for the ico/png/svg icon and the HTTP Content-Type header to output.
func (*FaviconList) ProduceIco ¶
func (l *FaviconList) ProduceIco() ([]byte, error)
ProduceIco outputs the bytes of the ico icon or an error
func (*FaviconList) ProducePng ¶
func (l *FaviconList) ProducePng() ([]byte, error)
ProducePng outputs the bytes of the png icon or an error
func (*FaviconList) ProduceSvg ¶
func (l *FaviconList) ProduceSvg() ([]byte, error)
ProduceSvg outputs the bytes of the svg icon or an error
type Favicons ¶
type Favicons struct {
// contains filtered or unexported fields
}
Favicons is a dynamic favicon generator which supports overwriting favicons
func (*Favicons) Compile ¶
func (f *Favicons) Compile()
Compile downloads the list of favicon mappings from the database and loads them and the target favicons into memory for faster lookups
This method makes use of the rescheduler instead of just ignoring multiple calls.
func (*Favicons) GetIcons ¶
func (f *Favicons) GetIcons(host string) *FaviconList
GetIcons returns the favicon list for the provided host or nil if no icon is found or generated