content

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: BSD-3-Clause Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWorkflowIncorrectlyConfigured = errors.New("workflow is incorrectly configured")
	ErrInvalidWorkflowState          = errors.New("invalid workflow state")
	ErrWorkflowUnsupported           = errors.New("workflow not supported for selected content type")
	ErrWorkflowTransitionFailed      = errors.New("workflow transition failed")
)
View Source
var ErrInternalServerError = errors.New("internal server error")
View Source
var (
	ErrInvalidContentType = errors.New("invalid content type")
)
View Source
var ErrUnsupportedMethod = errors.New("http method unsupported")
View Source
var ReferenceLoaderChunkSize = 20
View Source
var UploadType = "Upload"

Functions

func NewContentWorkflowTransitionHandler

func NewContentWorkflowTransitionHandler(contentService *Service, cfg config.ConfigCache, publicPath string) http.HandlerFunc

func NewEditContentFormHandler

func NewEditContentFormHandler(contentService *Service, cfg config.ConfigCache, publicPath string) http.HandlerFunc

func NewEditUploadFormHandler

func NewEditUploadFormHandler(uploadsService *UploadService) dashboard.Handler

func NewGetReferenceHandler

func NewGetReferenceHandler(service *Service, mapper *Mapper) http.HandlerFunc

func NewListReferencesHandler

func NewListReferencesHandler(service *Service, mapper *Mapper) http.HandlerFunc

func NewSaveContentHandler

func NewSaveContentHandler(contentService *Service, publicPath string) http.HandlerFunc

func NewSaveUploadHandler

func NewSaveUploadHandler(uploadService *UploadService, publicPath string) http.HandlerFunc

func RegisterRoutes

func RegisterRoutes(r router.Router, dashboardHandler dashboard.LayoutRouteHandler) error

Types

type EditContentFormViewModel

type EditContentFormViewModel struct {
	dashboard.RootViewModel
	Metadata
	Form  template.HTML
	Error error
}

func NewEditContentFormViewModel

func NewEditContentFormViewModel(
	entity interface{},
	cfg config.ConfigCache,
	publicPath string,
	contentTypes map[string]content.Builder,
	exception error,
) (*EditContentFormViewModel, error)

type EditUploadFormViewModel

type EditUploadFormViewModel struct {
	dashboard.RootViewModel
	ID         string
	EntityName string
	Slug       string
	Form       template.HTML
}

func NewEditUploadFormViewModel

func NewEditUploadFormViewModel(
	upload *entities.Upload,
	rootViewModel *dashboard.RootViewModel,
) (*EditUploadFormViewModel, error)

type GetReferenceInputResource

type GetReferenceInputResource struct {
	Type string
	ID   string
}

type ListReferencesInputResource

type ListReferencesInputResource struct {
	Type   string
	Search *search.Search
}

type ListReferencesOutputResource

type ListReferencesOutputResource struct {
	References []interface{} `json:"references"`
	Size       int           `json:"size"`
}

type Mapper

type Mapper struct{}

func NewMapper

func NewMapper() *Mapper

func (*Mapper) MapEntityToReference

func (m *Mapper) MapEntityToReference(entity interface{}) (*Reference, error)

func (*Mapper) MapReferenceMatchesToReferencesResourceOutput

func (m *Mapper) MapReferenceMatchesToReferencesResourceOutput(
	matches []interface{},
	size int,
) (*ListReferencesOutputResource, error)

func (*Mapper) MapReqToListReferencesInputResource

func (m *Mapper) MapReqToListReferencesInputResource(req *http.Request) (*ListReferencesInputResource, error)

func (*Mapper) MapRequestToGetReferenceInputResource

func (m *Mapper) MapRequestToGetReferenceInputResource(req *http.Request) (*GetReferenceInputResource, error)

type Metadata

type Metadata struct {
	ID         string
	EntityName string
	Slug       string
	Title      string
	Workflow   workflow.Workflow
}

type Query

type Query struct {
	ID   string
	Type string
}

func MapContentQueryFromRequest

func MapContentQueryFromRequest(r *http.Request) (*Query, error)

type Reference

type Reference struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type ReferenceLoader

type ReferenceLoader struct {
	// contains filtered or unexported fields
}

func (*ReferenceLoader) GetEntity

func (l *ReferenceLoader) GetEntity(entityName, entityId string) (interface{}, error)

type ReferenceLoaderInterface

type ReferenceLoaderInterface interface {
	GetReferences(entityName string, entityIds ...string) ([]interface{}, error)
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(
	db database.Database,
	types map[string]content.Builder,
	searchClient search.SearchInterface,
	dataExporter dataexporter.DataExporter,
	uploadService *UploadService,
) (*Service, error)

func (*Service) ContentTypes

func (s *Service) ContentTypes() map[string]content.Builder

func (*Service) CreateContent

func (s *Service) CreateContent(entityType string, entity interface{}) (string, error)

func (*Service) DeleteContent

func (s *Service) DeleteContent(entityType string, entityIds ...string) error

func (*Service) Export

func (s *Service) Export(entityName, exportType string) (datasource.Datasource, error)

func (*Service) GetAll

func (s *Service) GetAll(entityType string) ([]interface{}, error)

func (*Service) GetAllWithOptions

func (s *Service) GetAllWithOptions(entityType string, search *search.Search) ([]interface{}, int, error)

func (*Service) GetContent

func (s *Service) GetContent(entityType, entityId string) (interface{}, error)

func (*Service) GetContentByIds

func (s *Service) GetContentByIds(entityType string, entityIds ...string) ([]interface{}, error)

func (*Service) GetContentBySlug

func (s *Service) GetContentBySlug(slug string) (interface{}, error)

func (*Service) GetNumberOfRows

func (s *Service) GetNumberOfRows(entityType string) (int, error)

func (*Service) GetReference

func (s *Service) GetReference(entityName, entityId string) (interface{}, error)

func (*Service) GetReferences

func (s *Service) GetReferences(entityName string, entityIds ...string) ([]interface{}, error)

func (*Service) GetSlug

func (s *Service) GetSlug(entityType, entityId string) (*entities.Slug, error)

func (*Service) ListReferences

func (s *Service) ListReferences(typeName string, searchQuery *search.Search) ([]interface{}, int, error)

func (*Service) TransitionWorkflowState

func (s *Service) TransitionWorkflowState(entityType, entityId string, targetState workflow.State) (interface{}, error)

func (*Service) Type

func (s *Service) Type(name string) (interface{}, error)

func (*Service) UpdateContent

func (s *Service) UpdateContent(entityType, entityId string, update interface{}) (interface{}, error)

UpdateContent supports only full updates. The entire structure will be overwritten.

type TransitionInput

type TransitionInput struct {
	Query
	TargetState string
}

func MapContentTransitionInputFromRequest

func MapContentTransitionInputFromRequest(r *http.Request) (*TransitionInput, error)

type UploadService

type UploadService struct {
	// contains filtered or unexported fields
}

func NewUploadService

func NewUploadService(
	db database.Database,
	searchClient search.SearchInterface,
	client storage.Client) (*UploadService, error)

func (*UploadService) DeleteUpload

func (s *UploadService) DeleteUpload(entityIds ...string) error

func (*UploadService) GetAllWithOptions

func (s *UploadService) GetAllWithOptions(search *search.Search) ([]interface{}, int, error)

func (*UploadService) GetUpload

func (s *UploadService) GetUpload(entityId string) (*contentEntities.Upload, error)

func (*UploadService) GetUploads

func (s *UploadService) GetUploads(entityIds ...string) ([]*contentEntities.Upload, error)

func (*UploadService) Open

func (s *UploadService) Open(name string) (http.File, error)

func (*UploadService) UploadFiles

func (s *UploadService) UploadFiles(files map[string]*multipart.FileHeader) ([]*entities.Upload, error)

UploadFiles stores file uploads at paths like /YYYY/MM/filename.ext

Directories

Path Synopsis
csv

Jump to

Keyboard shortcuts

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