Documentation

Overview

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

    Index

    Constants

    View Source
    const MaxIconSize = 500

      TODO: Turn into env var: https://github.com/rendomnet/besticon/commit/c85867cc80c00c898053ce8daf40d51a93b9d39f#diff-37b57e3fdbe4246771791e86deb4d69dL41

      View Source
      const MinIconSize = 0
      View Source
      const VersionString = "v3.12.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