v0.55.0 Latest Latest

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

Go to latest
Published: Apr 8, 2019 License: Apache-2.0 Imports: 43 Imported by: 49




View Source
const (
	CACHE_CLEAR_ALL = "clear_all"
	CACHE_OTHER     = "other"


This section is empty.


func AssignMetadata

func AssignMetadata(metadata []map[string]interface{}, resources ...resource.Resource) error

AssignMetadata assigns the given metadata to those resources that supports updates and matching by wildcard given in `src` using `filepath.Match` with lower cased values. This assignment is additive, but the most specific match needs to be first. The `name` and `title` metadata field support shell-matched collection it got a match in. See

func ResourceKeyPartition

func ResourceKeyPartition(filename string) string

ResourceKeyPartition returns a partition name to allow for more fine grained cache flushes. It will return the file extension without the leading ".". If no extension, it will return "other".


type Image

type Image struct {
	// contains filtered or unexported fields

Image represents an image resource.

func (Image) Content

func (l Image) Content() (interface{}, error)

func (Image) Data

func (l Image) Data() interface{}

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

Height returns i's height.

func (Image) Key

func (l Image) Key() string

func (Image) MediaType

func (l Image) MediaType() media.Type

func (Image) Name

func (l Image) Name() string

func (Image) Params

func (l Image) Params() map[string]interface{}
func (l Image) Permalink() string

func (Image) Publish

func (l Image) Publish() error

func (Image) ReadSeekCloser

func (l Image) ReadSeekCloser() (hugio.ReadSeekCloser, 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) String

func (l Image) String() string

func (Image) TargetPath added in v0.55.0

func (l Image) TargetPath() string

Path is stored with Unix style slashes.

func (Image) Title

func (l Image) Title() string

func (*Image) Width

func (i *Image) Width() int

Width returns i's width.

func (*Image) WithNewBase

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

WithNewBase implements 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
	ResampleFilter string

	// The anchor used in Fill. Default is "smart", i.e. Smart Crop.
	Anchor string

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

type ResourceCache

type ResourceCache struct {
	// contains filtered or unexported fields

func (*ResourceCache) Contains

func (c *ResourceCache) Contains(key string) bool

func (*ResourceCache) DeletePartitions

func (c *ResourceCache) DeletePartitions(partitions ...string)

func (*ResourceCache) GetOrCreate

func (c *ResourceCache) GetOrCreate(partition, key string, f func() (resource.Resource, error)) (resource.Resource, error)

type ResourceSourceDescriptor

type ResourceSourceDescriptor struct {
	// TargetPaths is a callback to fetch paths's relative to its owner.
	TargetPaths func() page.TargetPaths

	// Need one of these to load the resource content.
	SourceFile         source.File
	OpenReadSeekCloser resource.OpenReadSeekCloser

	// If OpenReadSeekerCloser is not set, we use this to open the file.
	SourceFilename string

	// The relative target filename without any language code.
	RelTargetFilename string

	// Any base paths prepended to the target path. This will also typically be the
	// language code, but setting it here means that it should not have any effect on
	// the permalink.
	// This may be several values. In multihost mode we may publish the same resources to
	// multiple targets.
	TargetBasePaths []string

	// Delay publishing until either Permalink or RelPermalink is called. Maybe never.
	LazyPublish bool

func (ResourceSourceDescriptor) Filename

func (r ResourceSourceDescriptor) Filename() string

type ResourceTransformation

type ResourceTransformation interface {
	Key() ResourceTransformationKey
	Transform(ctx *ResourceTransformationCtx) error

ResourceTransformation is the interface that a resource transformation step needs to implement.

type ResourceTransformationCtx

type ResourceTransformationCtx struct {
	// The content to transform.
	From io.Reader

	// The target of content transformation.
	// The current implementation requires that r is written to w
	// even if no transformation is performed.
	To io.Writer

	// This is the relative path to the original source. Unix styled slashes.
	SourcePath string

	// This is the relative target path to the resource. Unix styled slashes.
	InPath string

	// The relative target path to the transformed resource. Unix styled slashes.
	OutPath string

	// The input media type
	InMediaType media.Type

	// The media type of the transformed resource.
	OutMediaType media.Type

	// Data data can be set on the transformed Resource. Not that this need
	// to be simple types, as it needs to be serialized to JSON and back.
	Data map[string]interface{}

	// This is used to publis additional artifacts, e.g. source maps.
	// We may improve this.
	OpenResourcePublisher func(relTargetPath string) (io.WriteCloser, error)

func (*ResourceTransformationCtx) AddOutPathIdentifier

func (ctx *ResourceTransformationCtx) AddOutPathIdentifier(identifier string)

AddOutPathIdentifier transforming InPath to OutPath adding an identifier, eg '.min' before any extension.

func (*ResourceTransformationCtx) PublishSourceMap

func (ctx *ResourceTransformationCtx) PublishSourceMap(content string) error

PublishSourceMap writes the content to the target folder of the main resource with the ".map" extension added.

func (*ResourceTransformationCtx) ReplaceOutPathExtension

func (ctx *ResourceTransformationCtx) ReplaceOutPathExtension(newExt string)

ReplaceOutPathExtension transforming InPath to OutPath replacing the file extension, e.g. ".scss"

type ResourceTransformationKey

type ResourceTransformationKey struct {
	// contains filtered or unexported fields

ResourceTransformationKey are provided by the different transformation implementations. It identifies the transformation (name) and its configuration (elements). We combine this in a chain with the rest of the transformations with the target filename and a content hash of the origin to use as cache key.

func NewResourceTransformationKey

func NewResourceTransformationKey(name string, elements ...interface{}) ResourceTransformationKey

NewResourceTransformationKey creates a new ResourceTransformationKey from the transformation name and elements. We will create a 64 bit FNV hash from the elements, which when combined with the other key elements should be unique for all practical applications.

type Spec

type Spec struct {

	MediaTypes    media.Types
	OutputFormats output.Formats

	Logger *loggers.Logger

	TextTemplates tpl.TemplateParseFinder

	Permalinks page.PermalinkExpander

	ResourceCache *ResourceCache
	FileCaches    filecache.Caches
	// contains filtered or unexported fields

func NewSpec

func NewSpec(
	s *helpers.PathSpec,
	fileCaches filecache.Caches,
	logger *loggers.Logger,
	outputFormats output.Formats,
	mimeTypes media.Types) (*Spec, error)

func (*Spec) CacheStats

func (r *Spec) CacheStats() string

func (*Spec) ClearCaches

func (r *Spec) ClearCaches()

func (*Spec) DeleteCacheByPrefix

func (r *Spec) DeleteCacheByPrefix(prefix string)

func (*Spec) IsInImageCache

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

TODO(bep) unify

func (*Spec) New

func (*Spec) NewForFs

func (r *Spec) NewForFs(sourceFs afero.Fs, fd ResourceSourceDescriptor) (resource.Resource, error)

func (*Spec) Transform


Path Synopsis
Package page contains the core interfaces and types for the Page resource, a core component in Hugo.
Package page contains the core interfaces and types for the Page resource, a core component in Hugo.
Package bundler contains functions for concatenation etc.
Package bundler contains functions for concatenation etc.
Package create contains functions for to create Resource objects.
Package create contains functions for to create Resource objects.
Package templates contains functions for template processing of Resource objects.
Package templates contains functions for template processing of Resource objects.

Jump to

Keyboard shortcuts

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