besticon

package
v3.11.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2019 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package besticon includes functions finding icons for a given web site.

Index

Constants

View Source
const MaxIconSize = 500
View Source
const MinIconSize = 0
View Source
const VersionString = "v3.11.0"

Version string, same as VERSION, generated my Make

Variables

View Source
var BuildDate string // set via ldflags on Make
View Source
var PopularSites []string

PopularSites we might use for examples and testing.

Functions

func CacheEnabled

func CacheEnabled() bool

func Get

func Get(urlstring string) (*http.Response, error)

func GetBodyBytes

func GetBodyBytes(r *http.Response) ([]byte, error)

func GetCacheStats

func GetCacheStats() groupcache.CacheStats

GetCacheStats returns cache statistics.

func MainColorForIcons

func MainColorForIcons(icons []Icon) *color.RGBA

func SetCacheMaxSize

func SetCacheMaxSize(sizeInMB int64)

SetCacheMaxSize enables icon caching if sizeInMB > 0.

func SetLogOutput

func SetLogOutput(w io.Writer)

SetLogOutput sets the output for the package's logger.

Types

type Icon

type Icon struct {
	URL       string `json:"url"`
	Width     int    `json:"width"`
	Height    int    `json:"height"`
	Format    string `json:"format"`
	Bytes     int    `json:"bytes"`
	Error     error  `json:"error"`
	Sha1sum   string `json:"sha1sum"`
	ImageData []byte `json:",omitempty"`
}

Icon holds icon information.

func (*Icon) Image

func (ico *Icon) Image() (*image.Image, error)

type IconFinder

type IconFinder struct {
	FormatsAllowed  []string
	HostOnlyDomains []string
	KeepImageBytes  bool
	// contains filtered or unexported fields
}

func (*IconFinder) FetchIcons

func (f *IconFinder) FetchIcons(url string) ([]Icon, error)

func (*IconFinder) IconInSizeRange

func (f *IconFinder) IconInSizeRange(r SizeRange) *Icon

func (*IconFinder) Icons

func (f *IconFinder) Icons() []Icon

func (*IconFinder) MainColorForIcons

func (f *IconFinder) MainColorForIcons() *color.RGBA

type SizeRange

type SizeRange struct {
	Min     int
	Perfect int
	Max     int
}

SizeRange represents the desired icon dimensions

func ParseSizeRange

func ParseSizeRange(s string) (*SizeRange, error)

ParseSizeRange parses a string like 60..100..200 into a SizeRange

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL