resource

package
v0.32.4 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2018 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultResourceType = "unknown"

Variables

This section is empty.

Functions

This section is empty.

Types

type Cloner

type Cloner interface {
	WithNewBase(base string) Resource
}

type Image

type Image struct {
	// contains filtered or unexported fields
}

func (Image) AbsSourceFilename

func (l Image) AbsSourceFilename() string

func (*Image) Fill

func (i *Image) Fill(spec string) (*Image, error)

Fill scales the image to the smallest possible size that will cover the specified dimensions, crops the resized image to the specified dimensions using the given anchor point. Space delimited config: 200x300 TopLeft

func (*Image) Fit

func (i *Image) Fit(spec string) (*Image, error)

Fit scales down the image using the specified resample filter to fit the specified maximum width and height.

func (*Image) Height

func (i *Image) Height() int
func (l Image) Permalink() string

func (Image) Publish

func (l Image) Publish() error
func (l Image) RelPermalink() string

func (*Image) Resize

func (i *Image) Resize(spec string) (*Image, error)

Resize resizes the image to the specified width and height using the specified resampling filter and returns the transformed image. If one of width or height is 0, the image aspect ratio is preserved.

func (Image) ResourceType

func (l Image) ResourceType() string

func (*Image) Width

func (i *Image) Width() int

func (*Image) WithNewBase

func (i *Image) WithNewBase(base string) Resource

Implement the Cloner interface.

type Imaging

type Imaging struct {
	// Default image quality setting (1-100). Only used for JPEG images.
	Quality int

	// Resample filter used. See https://github.com/disintegration/imaging
	ResampleFilter string
}

Imaging contains default image processing configuration. This will be fetched from site (or language) config.

type Resource

type Resource interface {
	Permalink() string
	RelPermalink() string
	ResourceType() string
}

Resource represents a linkable resource, i.e. a content page, image etc.

type Resources

type Resources []Resource

Resources represents a slice of resources, which can be a mix of different types. I.e. both pages and images etc.

func (Resources) ByType

func (r Resources) ByType(tp string) Resources

func (Resources) GetByPrefix

func (r Resources) GetByPrefix(prefix string) Resource

GetBySuffix gets the first resource matching the given filename prefix, e.g "logo" will match logo.png. It returns nil of none found. In potential ambiguous situations, combine it with ByType.

type Source

type Source interface {
	AbsSourceFilename() string
	Publish() error
}

type Spec

type Spec struct {
	*helpers.PathSpec

	AbsGenImagePath string
	// contains filtered or unexported fields
}

func NewSpec

func NewSpec(s *helpers.PathSpec, mimeTypes media.Types) (*Spec, error)

func (*Spec) CacheStats

func (r *Spec) CacheStats() string

func (*Spec) DeleteCacheByPrefix

func (r *Spec) DeleteCacheByPrefix(prefix string)

func (*Spec) IsInCache

func (r *Spec) IsInCache(key string) bool

func (*Spec) NewResourceFromFile

func (r *Spec) NewResourceFromFile(
	targetPathBuilder func(base string) string,
	absPublishDir string,
	file source.File, relTargetFilename string) (Resource, error)

func (*Spec) NewResourceFromFilename

func (r *Spec) NewResourceFromFilename(
	targetPathBuilder func(base string) string,
	absPublishDir,
	absSourceFilename, relTargetFilename string) (Resource, error)

Jump to

Keyboard shortcuts

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