content

package
v0.0.0-...-106d939 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTypeNotRegistered means content type isn't registered (not found in Types map)
	ErrTypeNotRegistered = errors.New(typeNotRegistered)

	// ErrAllowHiddenItem should be used as an error to tell a caller of Hideable#Hide
	// that this type is hidden, but should be shown in a particular case, i.e.
	// if requested by a valid admin or user
	ErrAllowHiddenItem = errors.New(`allow hidden item`)
)

Functions

This section is empty.

Types

type CSVFormattable

type CSVFormattable interface {
	FormatCSV() []string
}

CSVFormattable is implemented with the method FormatCSV, which must return the ordered slice of JSON struct tag names for the type implmenting it

type Content

type Content interface {
	AllContentTypeNames() []string
	AllContentTypes() map[string]Creator
	NormalizeString(s string) (string, error)
	GetContentCreator(string) (Creator, bool)

	GetContents([]Identifier) ([][]byte, error)

	GetContent(contentType, id, status string) ([]byte, error)
	DeleteContent(contentType, id, status string) error
	NewContent(contentType string, data url.Values) (string, error)
	UpdateContent(contentType string, data url.Values) error
}

type Createable

type Createable interface {
	// Create enables external clients to submit content of a specific type
	Create(http.ResponseWriter, *http.Request) error
}

Createable accepts or rejects external POST requests to endpoints such as: /api/content/create?type=Review

type Creator

type Creator func() interface{}

type Hideable

type Hideable interface {
	Hide(http.ResponseWriter, *http.Request) error
}

Hideable lets a user keep items hidden

type Hookable

type Hookable interface {
	BeforeAPIResponse(http.ResponseWriter, *http.Request, []byte) ([]byte, error)
	AfterAPIResponse(http.ResponseWriter, *http.Request, []byte) error

	BeforeAPICreate(http.ResponseWriter, *http.Request) error
	AfterAPICreate(http.ResponseWriter, *http.Request) error

	BeforeAPIUpdate(http.ResponseWriter, *http.Request) error
	AfterAPIUpdate(http.ResponseWriter, *http.Request) error

	BeforeAPIDelete(http.ResponseWriter, *http.Request) error
	AfterAPIDelete(http.ResponseWriter, *http.Request) error

	BeforeAdminCreate(http.ResponseWriter, *http.Request) error
	AfterAdminCreate(http.ResponseWriter, *http.Request) error

	BeforeAdminUpdate(http.ResponseWriter, *http.Request) error
	AfterAdminUpdate(http.ResponseWriter, *http.Request) error

	BeforeAdminDelete(http.ResponseWriter, *http.Request) error
	AfterAdminDelete(http.ResponseWriter, *http.Request) error

	BeforeSave(http.ResponseWriter, *http.Request) error
	AfterSave(http.ResponseWriter, *http.Request) error

	BeforeDelete(http.ResponseWriter, *http.Request) error
	AfterDelete(http.ResponseWriter, *http.Request) error

	BeforeApprove(http.ResponseWriter, *http.Request) error
	AfterApprove(http.ResponseWriter, *http.Request) error

	BeforeReject(http.ResponseWriter, *http.Request) error
	AfterReject(http.ResponseWriter, *http.Request) error

	// Enable/Disable used for addons
	BeforeEnable(http.ResponseWriter, *http.Request) error
	AfterEnable(http.ResponseWriter, *http.Request) error

	BeforeDisable(http.ResponseWriter, *http.Request) error
	AfterDisable(http.ResponseWriter, *http.Request) error
}

Hookable provides our user with an easy way to intercept or add functionality to the different lifecycles/events a struct may encounter. Item implements Hookable with no-ops so our user can override only whichever ones necessary.

type Identifiable

type Identifiable interface {
	ItemID() int
	SetItemID(int)

	UniqueID() uuid.UUID
	SetUniqueID(uuid.UUID)

	String() string
	ItemName() string
}

Identifiable enables a struct to have its ID set/get. Typically this is done to set an ID to -1 indicating it is new for DB inserts, since by default a newly initialized struct would have an ID of 0, the int zero-value, and bbolt's starting key per bucket is 0, thus overwriting the first record.

type Identifier

type Identifier interface {
	ID() string
	ContentType() string
}

type Omittable

type Omittable interface {
	Omit(http.ResponseWriter, *http.Request) ([]string, error)
}

Omittable lets a user define certin fields within a content struct to remove from an API response. Helpful when you want data in the CMS, but not entirely shown or available from the content API. All items in the slice should be the json tag names of the struct fields to which they correspond.

type Pushable

type Pushable interface {
	// Push the values contained by fields returned by Push must strictly be URL paths
	Push(http.ResponseWriter, *http.Request) ([]string, error)
}

Pushable lets a user define which values of certain struct fields are 'pushed' down to a client via HTTP/2 Server Push. All items in the slice should be the json tag names of the struct fields to which they correspond.

type Searchable

type Searchable interface {
	SearchMapping() (*mapping.IndexMappingImpl, error)
	IndexContent() bool
}

Searchable ...

type Sluggable

type Sluggable interface {
	SetSlug(string)
	ItemSlug() string
}

Sluggable makes a struct locatable by URL with it's own path. As an Item implementing Sluggable, slugs may overlap. If this is an issue, make your content struct (or one which embeds Item) implement Sluggable and it will override the slug created by Item's SetSlug with your own

type Sortable

type Sortable interface {
	Time() int64
	Touch() int64
}

Sortable ensures data is sortable by time

type Status

type Status string
const (
	Public  Status = "public"
	Pending Status = "pending"
)

type Statusable

type Statusable interface {
	ItemStatus() Status
	SetItemStatus(Status)
}

type Trustable

type Trustable interface {
	AutoApprove(http.ResponseWriter, *http.Request) error
}

Trustable allows external content to be auto-approved, meaning content sent as an Createable will be stored in the public content bucket

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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