Documentation ¶
Index ¶
- type Cache
- func (c *Cache) CleanKey(key string) string
- func (c *Cache) GetFile(key string) (filecache.ItemInfo, io.ReadCloser, []byte, bool)
- func (c *Cache) GetOrCreateImageResource(parent *ResourceImage, conf valueobject.ImageConfig, ...) (*ResourceImage, error)
- func (c *Cache) GetOrCreateResource(key string, f func() (resources.Resource, error)) (resources.Resource, error)
- func (c *Cache) GetOrCreateResources(key string, f func() ([]resources.Resource, error)) ([]resources.Resource, error)
- func (c *Cache) WriteMeta(key string, metaRaw []byte) (filecache.ItemInfo, io.WriteCloser, error)
- type Common
- type IntegrityClient
- type MinifierClient
- type PostBuildAssets
- type Publisher
- type Resource
- func (l *Resource) CloneTo(targetPath string) resources.Resource
- func (l *Resource) Content(context.Context) (any, error)
- func (l *Resource) Data() any
- func (l *Resource) DependencyManager() identity.Manager
- func (l *Resource) Err() resources.ResourceError
- func (l *Resource) Hash() string
- func (l *Resource) Key() string
- func (l *Resource) MediaType() media.Type
- func (l *Resource) Name() string
- func (l *Resource) NameNormalized() string
- func (l *Resource) Permalink() string
- func (l *Resource) ReadSeekCloser() (pio.ReadSeekCloser, error)
- func (l *Resource) RelPermalink() string
- func (l *Resource) ResourceType() string
- func (l *Resource) Size() int64
- func (l *Resource) TargetPath() string
- type ResourceImage
- func (i *ResourceImage) Colors() ([]string, error)
- func (i *ResourceImage) Crop(spec string) (resources.ImageResource, error)
- func (i *ResourceImage) DecodeImage() (image.Image, error)
- func (i *ResourceImage) Exif() *exif.ExifInfo
- func (i *ResourceImage) Fill(spec string) (resources.ImageResource, error)
- func (i *ResourceImage) Filter(filters ...any) (resources.ImageResource, error)
- func (i *ResourceImage) Fit(spec string) (resources.ImageResource, error)
- func (i *ResourceImage) Process(spec string) (resources.ImageResource, error)
- func (i *ResourceImage) Resize(spec string) (resources.ImageResource, error)
- type ResourceTransformable
- type ResourceTransformation
- type ResourceTransformer
- type Resources
- func (rs *Resources) Copy(r resources.Resource, targetPath string) (resources.Resource, error)
- func (rs *Resources) GetMatch(pattern string) (resources.Resource, error)
- func (rs *Resources) GetResource(pathname string) (resources.Resource, error)
- func (rs *Resources) GetResourceWithOpener(pathname string, opener io.OpenReadSeekCloser) (resources.Resource, error)
- func (rs *Resources) SetupTemplateClient(tmpl Template)
- type SassClient
- type Template
- type TemplateClient
- type Transformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { sync.RWMutex filecache.Caches CacheImage *dynacache.Partition[string, *ResourceImage] CacheResource *dynacache.Partition[string, resources.Resource] CacheResources *dynacache.Partition[string, []resources.Resource] CacheResourceTransformation *dynacache.Partition[string, *Resource] }
func (*Cache) GetOrCreateImageResource ¶
func (c *Cache) GetOrCreateImageResource(parent *ResourceImage, conf valueobject.ImageConfig, createImage func() (*ResourceImage, image.Image, error)) (*ResourceImage, error)
func (*Cache) GetOrCreateResource ¶
func (*Cache) GetOrCreateResources ¶
type Common ¶
type Common struct { Incr identity.Incrementer // Assets used after the build is done. // This is shared between all sites. *PostBuildAssets }
type IntegrityClient ¶
type IntegrityClient struct{}
func (*IntegrityClient) Fingerprint ¶
func (c *IntegrityClient) Fingerprint(res resources.Resource, algo string) (resources.Resource, error)
Fingerprint applies fingerprinting of the given resource and hash algorithm. It defaults to sha256 if none given, and the options are md5, sha256 or sha512. The same algo is used for both the fingerprinting part (aka cache busting) and the base64-encoded Subresource Integrity hash, so you will have to stay away from md5 if you plan to use both. See https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
type MinifierClient ¶
type MinifierClient struct { M *minify.M // Whether output minification is enabled (HTML in /public) MinifyOutput bool }
MinifierClient for minification of Resource objects. Supported minifiers are: css, html, js, json, svg and xml.
func (*MinifierClient) Transformer ¶
func (c *MinifierClient) Transformer(mediatype media.Type) transform.Transformer
type PostBuildAssets ¶
type PostBuildAssets struct { PostProcessResources map[string]resources.PostPublishedResource JSConfigBuilder *jsconfig.Builder // contains filtered or unexported fields }
type Publisher ¶
func (*Publisher) OpenPublishFileForWriting ¶
func (p *Publisher) OpenPublishFileForWriting(relTargetPath string) (io.WriteCloser, error)
func (*Publisher) PublishContentToTarget ¶
type Resource ¶
type Resource struct { stale.Staler valueobject.PublishOnce // contains filtered or unexported fields }
func (*Resource) DependencyManager ¶
func (*Resource) Err ¶
func (l *Resource) Err() resources.ResourceError
func (*Resource) NameNormalized ¶
func (*Resource) ReadSeekCloser ¶
func (l *Resource) ReadSeekCloser() (pio.ReadSeekCloser, error)
func (*Resource) RelPermalink ¶
func (*Resource) ResourceType ¶
func (*Resource) TargetPath ¶
type ResourceImage ¶
type ResourceImage struct { Resource *valueobject.Image ImageCache *Cache ImageConfig resources.ImageConfig // Image config ImageProc *valueobject.ImageProcessor // contains filtered or unexported fields }
func (*ResourceImage) Colors ¶
func (i *ResourceImage) Colors() ([]string, error)
Colors returns a slice of the most dominant colors in an images using a simple histogram method.
func (*ResourceImage) Crop ¶
func (i *ResourceImage) Crop(spec string) (resources.ImageResource, error)
Crop the images to the specified dimensions without resizing using the given anchor point. Space delimited config, e.g. `200x300 TopLeft`.
func (*ResourceImage) DecodeImage ¶
func (i *ResourceImage) DecodeImage() (image.Image, error)
DecodeImage decodes the images source into an Image. This for internal use only.
func (*ResourceImage) Exif ¶
func (i *ResourceImage) Exif() *exif.ExifInfo
func (*ResourceImage) Fill ¶
func (i *ResourceImage) Fill(spec string) (resources.ImageResource, error)
Fill scales the images to the smallest possible size that will cover the specified dimensions, crops the resized images to the specified dimensions using the given anchor point. Space delimited config, e.g. `200x300 TopLeft`.
func (*ResourceImage) Filter ¶
func (i *ResourceImage) Filter(filters ...any) (resources.ImageResource, error)
func (*ResourceImage) Fit ¶
func (i *ResourceImage) Fit(spec string) (resources.ImageResource, error)
Fit scales down the images using the specified resample filter to fit the specified maximum width and height.
func (*ResourceImage) Process ¶
func (i *ResourceImage) Process(spec string) (resources.ImageResource, error)
Process processes the images with the given spec. The spec can contain an optional action, one of "resize", "crop", "fit" or "fill". This makes this method a more flexible version that covers all of Resize, Crop, Fit and Fill, but it also supports e.g. format conversions without any resize action.
func (*ResourceImage) Resize ¶
func (i *ResourceImage) Resize(spec string) (resources.ImageResource, error)
Resize resizes the images to the specified width and height using the specified resampling filter and returns the transformed images. If one of width or height is 0, the images aspect ratio is preserved.
type ResourceTransformable ¶
type ResourceTransformable interface { resources.Resource Transformer }
type ResourceTransformation ¶
type ResourceTransformation interface { Key() valueobject.ResourceTransformationKey Transform(ctx *valueobject.ResourceTransformationCtx) error }
ResourceTransformation is the interface that a resource transformation step needs to implement.
type ResourceTransformer ¶
type ResourceTransformer struct { Resource TransformationCache *Cache // contains filtered or unexported fields }
func (*ResourceTransformer) Transform ¶
func (r *ResourceTransformer) Transform(t ...ResourceTransformation) (ResourceTransformable, error)
func (*ResourceTransformer) TransformWithContext ¶
func (r *ResourceTransformer) TransformWithContext(ctx context.Context, t ...ResourceTransformation) (ResourceTransformable, error)
func (*ResourceTransformer) TransformationKey ¶
func (r *ResourceTransformer) TransformationKey() string
type Resources ¶
type Resources struct { *Cache *Publisher ExecHelper *hexec.Exec *Common FsService resources.Fs MediaService resources.MediaTypesConfig ImageService resources.ImageConfig ImageProc *valueobject.ImageProcessor *MinifierClient *TemplateClient *IntegrityClient *SassClient }
func (*Resources) GetMatch ¶
GetMatch gets first resource matching the given pattern from the assets filesystem.
func (*Resources) GetResource ¶
func (*Resources) GetResourceWithOpener ¶
func (*Resources) SetupTemplateClient ¶
type SassClient ¶
type SassClient struct { BinaryFound bool AllowedExec bool FsService resources.Fs // contains filtered or unexported fields }
func (*SassClient) Close ¶
func (c *SassClient) Close() error
func (*SassClient) Open ¶
func (c *SassClient) Open() error
type TemplateClient ¶
type TemplateClient struct {
T Template
}
type Transformer ¶
type Transformer interface { Transform(...ResourceTransformation) (ResourceTransformable, error) TransformWithContext(context.Context, ...ResourceTransformation) (ResourceTransformable, error) }