Documentation ¶
Overview ¶
Package content contains the type definitions for contents on the platform. It also defines the content server interface.
Index ¶
- Variables
- func NormalizeSlug(seed string) string
- func ValidExtractType(t ExtractType) bool
- func ValidFlavorType(t FlavorType) bool
- func ValidLanguageComment(comment string) (bool, i18n.Key)
- func ValidSlug(slug string) (bool, i18n.Key)
- func ValidSummary(summary string) (bool, i18n.Key)
- func ValidTitle(title string) (bool, i18n.Key)
- type BasicServer
- type BlockId
- type BlockSlice
- type ContentType
- type EditType
- type Extract
- type ExtractId
- type ExtractShape
- func (s ExtractShape) Equals(t ExtractShape) bool
- func (s ExtractShape) IterateBodies(bodyA, bodyB BlockSlice, beforeBlock func(BlockId), ...)
- func (s ExtractShape) IterateBody(body BlockSlice, beforeBlock func(BlockId), unit func(BlockId, UnitId, *Unit), ...)
- func (s ExtractShape) IterateFlavorBodies(fA, fB *Flavor, beforeBlock func(BlockId), ...)
- func (s ExtractShape) IterateFlavorBody(f *Flavor, beforeBlock func(BlockId), unit func(BlockId, UnitId, *Unit), ...)
- func (s ExtractShape) Union(f *Flavor) ExtractShape
- type ExtractType
- type Flavor
- type FlavorByType
- type FlavorId
- type FlavorMap
- type FlavorType
- type Metadata
- type Note
- type NoteId
- type NotePointer
- type NoteType
- type Query
- type Server
- type Unit
- type UnitId
- type UnitSlice
- type Version
- type VersionedExtract
- type VersionedFlavor
- type VersionedUnit
- type VersionedUnitRef
Constants ¶
This section is empty.
Variables ¶
View Source
var AllExtractTypes = []ExtractType{ Dialog, WordList, ShortStory, Article, Poem, Song, }
View Source
var ErrInvalidInput = errors.New("Invalid input")
View Source
var ErrNotFound = errors.New("Not found")
Functions ¶
func NormalizeSlug ¶
NormalizeSlug attempts to create a valid slug based on the seed. There is no guarantee that the result is a valid slug.
func ValidExtractType ¶
func ValidExtractType(t ExtractType) bool
func ValidFlavorType ¶
func ValidFlavorType(t FlavorType) bool
Types ¶
type BasicServer ¶
type BasicServer interface { // Create NewExtract(author user.Name, e *Extract) error // sets e's ExtractId NewFlavor(author user.Name, f *Flavor) error // sets f's FlavorId // Read ExtractList() ([]*Extract, error) ExtractLanguages() ([]language.Code, error) GetExtract(id ExtractId) (*Extract, error) // Update UpdateExtract(author user.Name, e *Extract) error // doesn't update e.Flavors UpdateFlavor(author user.Name, f *Flavor) error // doesn't update f.Units InsertOrUpdateUnits(author user.Name, units []*Unit) error }
type BlockSlice ¶
type BlockSlice []UnitSlice
func (BlockSlice) Len ¶
func (bs BlockSlice) Len() int
func (BlockSlice) Less ¶
func (bs BlockSlice) Less(i, j int) bool
func (BlockSlice) Swap ¶
func (bs BlockSlice) Swap(i, j int)
type ContentType ¶
type ContentType string
const ( TypeText ContentType = "text" TypeFile ContentType = "file" )
type Extract ¶
type Extract struct { Id ExtractId Type ExtractType UrlSlug string Metadata *Metadata `json:",omitempty"` Flavors FlavorMap `json:",omitempty"` }
An Extract is the coarsest semantic unit on the platform. It corresponds to a group of Flavors describing the same content.
func (*Extract) SetFlavorLanguagesAndTypes ¶
func (e *Extract) SetFlavorLanguagesAndTypes()
func (*Extract) Shape ¶
func (e *Extract) Shape() ExtractShape
type ExtractShape ¶
type ExtractShape []int
func (ExtractShape) Equals ¶
func (s ExtractShape) Equals(t ExtractShape) bool
func (ExtractShape) IterateBodies ¶
func (s ExtractShape) IterateBodies(bodyA, bodyB BlockSlice, beforeBlock func(BlockId), unit func(BlockId, UnitId, *Unit, *Unit), afterBlock func(BlockId))
func (ExtractShape) IterateBody ¶
func (s ExtractShape) IterateBody(body BlockSlice, beforeBlock func(BlockId), unit func(BlockId, UnitId, *Unit), afterBlock func(BlockId))
func (ExtractShape) IterateFlavorBodies ¶
func (ExtractShape) IterateFlavorBody ¶
func (ExtractShape) Union ¶
func (s ExtractShape) Union(f *Flavor) ExtractShape
type ExtractType ¶
type ExtractType string
const ( Article ExtractType = "article" Dialog ExtractType = "dialog" ShortStory ExtractType = "short_story" Poem ExtractType = "poem" Song ExtractType = "song" WordList ExtractType = "word_list" )
type Flavor ¶
type Flavor struct { ExtractId ExtractId Id FlavorId Summary string Type FlavorType // text, audio, ... Language language.Code LanguageComment string Blocks BlockSlice `json:",omitempty"` }
A Flavor is a typically a short text in a certain language. The content Units are grouped into blocks.
func (*Flavor) GetBody ¶
func (f *Flavor) GetBody() BlockSlice
func (*Flavor) SetExtractId ¶
func (*Flavor) SetLanguage ¶
func (*Flavor) SetType ¶
func (f *Flavor) SetType(t FlavorType)
type FlavorByType ¶
type FlavorByType map[FlavorType][]*Flavor
type FlavorMap ¶
type FlavorMap map[language.Code]FlavorByType
type FlavorType ¶
type FlavorType string
const ( Audio FlavorType = "AUDIO" Text FlavorType = "TEXT" Transcript FlavorType = "TRANSCRIPT" )
type Metadata ¶
type Note ¶
type Note struct { Unit *VersionedUnitRef NoteId NoteId Language language.Code Content string }
type NotePointer ¶
type Query ¶
type Query struct { LanguageA language.Code LanguageB language.Code ExtractType ExtractType }
type Server ¶
type Server interface { BasicServer // Read GetExtractId(slug string) (ExtractId, error) ExtractsMatching(q *Query) ([]ExtractId, error) }
Sever is the interface a content server should comply to.
type Unit ¶
type Unit struct { ExtractId ExtractId FlavorId FlavorId Language language.Code FlavorType FlavorType BlockId BlockId Id UnitId ContentType ContentType // text, table header, table row, file, ... Content string }
A Unit is the finest content unit on the platform. It corresponds to a line of text, an image, or an utterance.
type VersionedExtract ¶
type VersionedFlavor ¶
type VersionedUnit ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.