Documentation ¶
Index ¶
- Variables
- func Copy(src, dest string) error
- func ETag(contents []byte) (string, error)
- func Exists(path string) bool
- func ExtractCaptureDate(imagePath string) (captureDate time.Time, err error)
- func GenerateExifData(imagePath string) (*exif.Exif, error)
- func GetExifData(exifData *exif.Exif) (data model.Exif, err error)
- func GetRenderContext(ctx context.Context) *model.RenderContext
- func HasExtension(filename string, extensions ...string) bool
- func ListDirectory(path string) (files []os.FileInfo, err error)
- func MakeDir(path string) error
- func ParseTemplate(literal string) (*template.Template, error)
- func ReadImage(path string) (output model.Image, err error)
- func ReadYAML(path string, obj interface{}) error
- func RenderString(tmp *template.Template, vm interface{}) (string, error)
- func Slugify(v string) string
- func StripQuotes(v string) string
- func ViewFuncs() template.FuncMap
- func WithRenderContext(ctx context.Context, rc *model.RenderContext) context.Context
- func WriteFile(path string, contents []byte) error
- func WriteYAML(path string, obj interface{}) error
- type Engine
- func (e Engine) Build(ctx context.Context) error
- func (e Engine) BuildRenderContext(ctx context.Context) (*model.RenderContext, error)
- func (e Engine) CleanThumbnailCache(ctx context.Context) error
- func (e Engine) CompileTemplate(templatePath string, partials []string) (contents string, final *template.Template, err error)
- func (e Engine) CopyImageOriginal(ctx context.Context, originalPath, destinationPath string) error
- func (e Engine) CopyThumbnail(etag, destinationPath string, size int) error
- func (e Engine) CopyThumbnails(etag, destinationPath string) error
- func (e Engine) CreateSlug(slugTemplate *template.Template, p model.Post) string
- func (e Engine) DiscoverPartials(ctx context.Context) ([]string, error)
- func (e Engine) DiscoverPosts(ctx context.Context) (*model.Data, error)
- func (e Engine) GeneratePost(ctx context.Context, slugTemplate *template.Template, path string, ...) (*model.Post, error)
- func (e Engine) GenerateThumbnail(original image.Image, size int, imagePath, etag string) error
- func (e Engine) GenerateThumbnails(originalContents []byte, originalImagePath, etag string) error
- func (e Engine) GetImageSizePaths(post model.Post) map[string]string
- func (e Engine) InitializeOutputPath() error
- func (e Engine) InitializeThumbnailCache() error
- func (e Engine) ParallelismOrDefault() int
- func (e *Engine) ParseSlugTemplate() (*template.Template, error)
- func (e Engine) ProcessThumbnails(ctx context.Context, originalFilePath, destinationPath string) error
- func (e Engine) Render(ctx context.Context) error
- func (e Engine) RenderTemplateToFile(tpl *template.Template, outputPath string, data *model.ViewModel) (string, error)
- func (e Engine) Resize(original image.Image, destination string, maxDimension uint) error
- func (e Engine) ShouldGenerateThumbnails(etag string) bool
- func (e Engine) WriteDataJSON(data *model.Data, path string) error
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( ErrPartitionCountTooLarge = errors.New("partition count greater than number of posts") ErrPartitionIndexTooLarge = errors.New("partition index greater than number of partitions") ErrPartitionCountInvalid = errors.New("partition count invalid; must be greater than 1") )
Partition Errors
Functions ¶
func ExtractCaptureDate ¶
ExtractCaptureDate extracts the capture date from an image file by path.
func GenerateExifData ¶
GenerateExifData gets exif data from a file on disk.
func GetExifData ¶
GetExifData generates the parsed exif data for the post.
func GetRenderContext ¶
func GetRenderContext(ctx context.Context) *model.RenderContext
GetRenderContext returns the render context off a context.
func HasExtension ¶
HasExtension returns if a given filename has any of a given set of extensions.
func ListDirectory ¶
ListDirectory returns all the file infos within a given directory by path.
func ParseTemplate ¶
ParseTemplate creates a new template from a string
func RenderString ¶
RenderString renders a template to a string for a given viewmodel.
func WithRenderContext ¶
WithRenderContext returns a context with a render context set.
Types ¶
type Engine ¶
Engine returns a
func (Engine) BuildRenderContext ¶
BuildRenderContext builds the render context used by the render function.
func (Engine) CleanThumbnailCache ¶
CleanThumbnailCache cleans the thumbnail cache by purging cached thumbnails for posts that may have been deleted.
func (Engine) CompileTemplate ¶
func (e Engine) CompileTemplate(templatePath string, partials []string) (contents string, final *template.Template, err error)
CompileTemplate compiles a template.
func (Engine) CopyImageOriginal ¶
CopyImageOriginal copies the original image to the destination.
func (Engine) CopyThumbnail ¶
CopyThumbnail copies a cached thumbnail to the output directory.
func (Engine) CopyThumbnails ¶
CopyThumbnails copies all thumbnails to the destination path by etag from the thumbnail cache.
func (Engine) CreateSlug ¶
CreateSlug creates a slug for a post.
func (Engine) DiscoverPartials ¶
DiscoverPartials reads all the partials named in the config. These are then injected into any subsequent renders as potential helper views.
func (Engine) DiscoverPosts ¶
DiscoverPosts generates the blog data.
func (Engine) GeneratePost ¶
func (e Engine) GeneratePost(ctx context.Context, slugTemplate *template.Template, path string, postIndex int) (*model.Post, error)
GeneratePost reads post contents and metadata from a folder.
func (Engine) GenerateThumbnail ¶
GenerateThumbnail generates a thumbnail and stores it in the cache if it doesn't exist and copies the cached thumbail to the output directory.
func (Engine) GenerateThumbnails ¶
GenerateThumbnails generates and copies our main thumbnails for the post image. - originalContents should be the bytes of the original image file - etag should be the sha sum as an etag, it is used as a path component in the file cache
func (Engine) GetImageSizePaths ¶
GetImageSizePaths gets the map that corresponds to the image sizes and the image path.
func (Engine) InitializeOutputPath ¶
InitializeOutputPath creates the output path if it doesn't exist.
func (Engine) InitializeThumbnailCache ¶
InitializeThumbnailCache creates the output path if it doesn't exist.
func (Engine) ParallelismOrDefault ¶
ParallelismOrDefault is the parallelism or a default.
func (*Engine) ParseSlugTemplate ¶
ParseSlugTemplate ensures the slug template
func (Engine) ProcessThumbnails ¶
func (e Engine) ProcessThumbnails(ctx context.Context, originalFilePath, destinationPath string) error
ProcessThumbnails processes thumbnails.
func (Engine) RenderTemplateToFile ¶
func (e Engine) RenderTemplateToFile(tpl *template.Template, outputPath string, data *model.ViewModel) (string, error)
RenderTemplateToFile writes a template to a given path with a given data viewmodel.
func (Engine) ShouldGenerateThumbnails ¶
ShouldGenerateThumbnails returns if we should process any thumbnais for a given etag.
type Option ¶
Option is a mutator for an engine.
func OptParallelism ¶
OptParallelism sets the engine parallelism if relevant.