cms

package
v0.0.0-...-0afa638 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ContentTypeSchema = `` /* 1359-byte string literal not displayed */

ContentTypeSchema is the core schema for all content types

Variables

This section is empty.

Functions

func GenerateSchema

func GenerateSchema(c *ContentType) ([]byte, error)

GenerateSchema generates a JSON schema for a given ContentType

func Init

func Init(d string, s Store)

Init initializes the CMS with the given dir & store

Types

type ContentType

type ContentType struct {
	ID           string   `json:"id"`
	Type         string   `json:"type"`
	Name         string   `json:"name"`
	Description  string   `json:"description"`
	DisplayField string   `json:"displayField"`
	Fields       []*Field `json:"fields"`
}

ContentType defines the structure

type Field

type Field struct {
	ID       string `json:"id"`
	Type     string `json:"type"`
	Required bool   `json:"required"`
	Items    struct {
		Type          string `json:"type"`
		ReferenceType string `json:"referenceType"`
		ReferenceID   string `json:"referenceID"`
	} `json:"items,omitempty"`
}

Field defines the structure

type Repository

type Repository struct {
	Name  string
	Store Store
}

Repository represents a single repository

func NewRepository

func NewRepository(name string) (*Repository, error)

NewRepository returns a Repository for the given store/bucket

func (*Repository) CreateIndex

func (r *Repository) CreateIndex(namespace string) error

CreateIndex is an experiment with indexing

func (*Repository) GetDocument

func (r *Repository) GetDocument(typeID, id string) ([]byte, error)

GetDocument gets a document from the Repository

func (*Repository) GetSchema

func (r *Repository) GetSchema(id string) ([]byte, error)

GetSchema gets a schema from the Repository

func (*Repository) GetType

func (r *Repository) GetType(id string) ([]byte, error)

GetType returns a type from the repository

func (*Repository) IndexDocument

func (r *Repository) IndexDocument(namespace, id string, document []byte) error

IndexDocument indexes the document in the correct index with the given id

func (*Repository) ListDocuments

func (r *Repository) ListDocuments(typeID string) ([][]byte, error)

ListDocuments returns a collection of documents of the specified type

func (*Repository) PutDocument

func (r *Repository) PutDocument(typeID, id string, content []byte) error

PutDocument stores a document in the Repository

func (*Repository) PutSchema

func (r *Repository) PutSchema(id string, content []byte) error

PutSchema stores a schema in the repository

func (*Repository) PutType

func (r *Repository) PutType(id string, content []byte) error

PutType stores a ContentType in the repository

func (*Repository) Query

func (r *Repository) Query(namespace, query string, count, offset int) ([]string, error)

Query performs a search on the given content type

type Store

type Store interface {
	CreateBucket(name string) error
	PutDocument(bucket, namespace, id string, data []byte) error
	GetDocument(bucket, namespace, id string) ([]byte, error)
	ListDocuments(bucket, namespace string) ([][]byte, error)
	Close() error
}

Store is the generic interface to a uCMS store

Directories

Path Synopsis
store

Jump to

Keyboard shortcuts

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