served

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package served shapes a stored item the way every public seam answers it.

Index

Constants

View Source
const MediaPrefix = "/media"

MediaPrefix is the URL prefix uploads are served under.

Variables

This section is empty.

Functions

func InlineMedia

func InlineMedia(ctx context.Context, library Library, t content.Type, values content.Values) error

InlineMedia rewrites every media key the type declares into the files it names, dropping what is gone.

func InlineTargets added in v0.13.0

func InlineTargets(ctx context.Context, links Reader, t content.Type, values content.Values) error

InlineTargets rewrites every relation key the type declares into the items it names, dropping what is gone.

func MediaIDs

func MediaIDs(t content.Type, values content.Values) []int64

MediaIDs returns every identity the values hold under the type's media fields.

func PerPage

func PerPage(ctx context.Context, settings Settings) int

PerPage returns how many items a public answer lists at once, as the site chose or by default.

func Pointing

func Pointing(
	ctx context.Context, stores Stores, t content.Type, c content.Content,
	values content.Values, hidden map[string]bool,
) (map[string]int, error)

Pointing writes the items pointing at the content under each backlinks key the hidden set leaves standing.

func Values

func Values(
	ctx context.Context, stores Stores, t content.Type, c content.Content,
) (content.Values, map[string]int, error)

Values returns the item's values as every public seam serves them, beside the pointer counts.

Types

type File

type File struct {
	ID       int64                `json:"id"`
	Src      string               `json:"src"`
	Title    string               `json:"title"`
	AltText  string               `json:"alt_text"`
	Caption  string               `json:"caption"`
	MimeType string               `json:"mime_type"`
	Width    int                  `json:"width"`
	Height   int                  `json:"height"`
	Sizes    map[string]Rendition `json:"sizes"`
}

File is one library file as a public reader sees it.

func FileOf

func FileOf(m media.Media) File

FileOf returns the public view of one stored file.

type Groups

type Groups interface {
	Groups(ctx context.Context) ([]content.Group, error)
	Params(ctx context.Context) *content.ParamRegistry
}

Groups reads the field groups a backlinks source resolves through.

type Library

type Library interface {
	ByIDs(ctx context.Context, ids []int64) ([]media.Media, error)
}

Library reads the stored files a media value names.

type Pointer

type Pointer struct {
	Target
	Type string `json:"type"`
}

Pointer is one item pointing at another, named as a relation target and typed besides.

func NamedPointers

func NamedPointers(held []content.Pointer) []Pointer

NamedPointers returns the pointing items a public answer carries under one backlinks field.

type Reader

type Reader interface {
	TargetsByIDs(ctx context.Context, ids []uuid.UUID) ([]content.Target, error)
	PointingAt(ctx context.Context, target uuid.UUID, field, page, perPage int) ([]content.Pointer, int, error)
}

Reader reads the items a public answer names beside the item's own values.

type Rendition

type Rendition struct {
	Src      string `json:"src"`
	Width    int    `json:"width"`
	Height   int    `json:"height"`
	MimeType string `json:"mime_type"`
}

Rendition is one stored rendition as a public reader sees it.

type Settings

type Settings interface {
	Lookup(ctx context.Context, key string) (string, bool, error)
}

Settings reads the values the site chose for itself.

type Stores

type Stores struct {
	Links    Reader
	Groups   Groups
	Library  Library
	Settings Settings
}

Stores are the readers a public answer is shaped through.

type Target

type Target struct {
	ID    string `json:"id"`
	Title string `json:"title"`
	Path  string `json:"path"`
}

Target is one item a relation points at, as a public reader sees it.

func NamedTargets

func NamedTargets(held []content.Target) []Target

NamedTargets returns the targets a public answer carries under one relation field.

Jump to

Keyboard shortcuts

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