content

package
v0.0.0-...-894ab8b Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2014 License: MIT Imports: 8 Imported by: 5

Documentation

Overview

Package content contains the type definitions for contents on the platform. It also defines the content server interface.

Index

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

func NormalizeSlug(seed string) string

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

func ValidLanguageComment

func ValidLanguageComment(comment string) (bool, i18n.Key)

func ValidSlug

func ValidSlug(slug string) (bool, i18n.Key)

ValidSlug returns true if slug has at least 5 characters and matches ^[A-Za-z0-9_]*$. Otherwise an (error) message is returned.

func ValidSummary

func ValidSummary(summary string) (bool, i18n.Key)

func ValidTitle

func ValidTitle(title string) (bool, i18n.Key)

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 BlockId

type BlockId int

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 EditType

type EditType string
const (
	EditNew    EditType = "new"
	EditUpdate EditType = "update"
	EditDelete EditType = "delete"
)

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) Equals

func (e *Extract) Equals(f *Extract) bool

func (*Extract) GetFlavor

func (e *Extract) GetFlavor(langCode language.Code, flavorType FlavorType, id FlavorId) (*Flavor, error)

func (*Extract) SetFlavorLanguagesAndTypes

func (e *Extract) SetFlavorLanguagesAndTypes()

func (*Extract) SetId

func (e *Extract) SetId(id ExtractId)

func (*Extract) Shape

func (e *Extract) Shape() ExtractShape

type ExtractId

type ExtractId string

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 (s ExtractShape) IterateFlavorBodies(fA, fB *Flavor, beforeBlock func(BlockId), unit func(BlockId, UnitId, *Unit, *Unit), afterBlock func(BlockId))

func (ExtractShape) IterateFlavorBody

func (s ExtractShape) IterateFlavorBody(f *Flavor, beforeBlock func(BlockId), unit func(BlockId, UnitId, *Unit), afterBlock func(BlockId))

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) Equals

func (f *Flavor) Equals(g *Flavor) bool

func (*Flavor) GetBody

func (f *Flavor) GetBody() BlockSlice

func (*Flavor) GetTitle

func (f *Flavor) GetTitle() *Unit

func (*Flavor) SetExtractId

func (f *Flavor) SetExtractId(id ExtractId)

func (*Flavor) SetId

func (f *Flavor) SetId(id FlavorId)

func (*Flavor) SetLanguage

func (f *Flavor) SetLanguage(lang language.Code)

func (*Flavor) SetType

func (f *Flavor) SetType(t FlavorType)

type FlavorByType

type FlavorByType map[FlavorType][]*Flavor

type FlavorId

type FlavorId int

type FlavorMap

type FlavorMap map[language.Code]FlavorByType

func (FlavorMap) Equals

func (m FlavorMap) Equals(n FlavorMap) bool

type FlavorType

type FlavorType string
const (
	Audio      FlavorType = "AUDIO"
	Text       FlavorType = "TEXT"
	Transcript FlavorType = "TRANSCRIPT"
)

type Metadata

type Metadata struct {
	SourceUrl      string        `json:",omitempty"`
	Previous       ExtractId     `json:",omitempty"`
	Next           ExtractId     `json:",omitempty"`
	TargetLanguage language.Code `json:",omitempty"`
}

func (*Metadata) Equals

func (m *Metadata) Equals(n *Metadata) bool

type Note

type Note struct {
	Unit     *VersionedUnitRef
	NoteId   NoteId
	Language language.Code
	Content  string
}

type NoteId

type NoteId int

type NotePointer

type NotePointer struct {
	Unit  *VersionedUnitRef
	Start int
	End   int
	Type  NoteType
	Id    NoteId
	Notes []*Note
}

type NoteType

type NoteType string
const (
	Vocabular     NoteType = "vocabular"
	Grammar       NoteType = "grammar"
	Pronunciation NoteType = "pronunciation"
	Culture       NoteType = "culture"
)

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 UnitId

type UnitId int

type UnitSlice

type UnitSlice []*Unit

func (UnitSlice) Len

func (us UnitSlice) Len() int

func (UnitSlice) Less

func (us UnitSlice) Less(i, j int) bool

func (UnitSlice) Swap

func (us UnitSlice) Swap(i, j int)

type Version

type Version struct {
	Author   user.Name
	Time     time.Time
	Number   int
	EditType EditType
}

type VersionedExtract

type VersionedExtract struct {
	*Extract
	*Version
}

type VersionedFlavor

type VersionedFlavor struct {
	*Flavor
	*Version
}

type VersionedUnit

type VersionedUnit struct {
	*Unit
	*Version
}

type VersionedUnitRef

type VersionedUnitRef struct {
	ExtractId     ExtractId
	FlavorId      FlavorId
	BlockId       BlockId
	UnitId        UnitId
	VersionNumber int
}

Directories

Path Synopsis
Package rpc provides the rpc content client used by the Polyglottis Application and a simple content server wrapper.
Package rpc provides the rpc content client used by the Polyglottis Application and a simple content server wrapper.

Jump to

Keyboard shortcuts

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