models

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRecord = errors.New("models: no matching record found")
)

Functions

This section is empty.

Types

type Excerpt

type Excerpt struct {
	ID        uuid.UUID
	Title     string
	Content   string
	Grammar   Grammar
	Technical Technical
	CLocked   bool
	GLocked   bool
	CShare    uuid.UUID
	GShare    uuid.UUID
	TShare    uuid.UUID
	Created   time.Time
	Updated   time.Time
}

type ExcerptModel

type ExcerptModel struct {
	DB *sql.DB
}

func (ExcerptModel) Get

func (m ExcerptModel) Get(id uuid.UUID) (Excerpt, error)

func (ExcerptModel) GetSharedContent

func (m ExcerptModel) GetSharedContent(cShare uuid.UUID) (Excerpt, error)

func (ExcerptModel) GetSharedGrammar

func (m ExcerptModel) GetSharedGrammar(gShare uuid.UUID) (Excerpt, error)

func (ExcerptModel) GetSharedTechnical

func (m ExcerptModel) GetSharedTechnical(tShare uuid.UUID) (Excerpt, error)

func (ExcerptModel) Insert

func (m ExcerptModel) Insert(title string) (uuid.UUID, error)

func (ExcerptModel) ResetGrammar

func (m ExcerptModel) ResetGrammar(id uuid.UUID) error

Assumes content is clean

func (ExcerptModel) ResetTechnical

func (m ExcerptModel) ResetTechnical(id uuid.UUID) error

func (ExcerptModel) SetContentLock

func (m ExcerptModel) SetContentLock(id uuid.UUID, lock bool) error

func (ExcerptModel) SetGrammarLock

func (m ExcerptModel) SetGrammarLock(id uuid.UUID, lock bool) error

func (ExcerptModel) UpdateContent

func (m ExcerptModel) UpdateContent(id uuid.UUID, content string) error

func (ExcerptModel) UpdateGrammar

func (m ExcerptModel) UpdateGrammar(id uuid.UUID, grammar Grammar) error

func (ExcerptModel) UpdateSharedContent

func (m ExcerptModel) UpdateSharedContent(cShare uuid.UUID, content string) error

func (ExcerptModel) UpdateSharedGrammar

func (m ExcerptModel) UpdateSharedGrammar(gShare uuid.UUID, grammar Grammar) error

func (ExcerptModel) UpdateSharedTechnical added in v0.1.5

func (m ExcerptModel) UpdateSharedTechnical(tShare uuid.UUID, technical Technical) error

func (ExcerptModel) UpdateTechnical

func (m ExcerptModel) UpdateTechnical(id uuid.UUID, technical Technical) error

type GWord

type GWord struct {
	Word     string   `json:"word"`
	Shrinked bool     `json:"shrinked"`
	LeftOver bool     `json:"leftOver"`
	Tags     []string `json:"tags"`

	// true if the word is preceding a punctuation or if the punctuation is
	// preceding a word (for rendering)
	Preceding   bool `json:"preceding"`
	Punctuation bool `json:"punctuation"`
}

type Grammar

type Grammar struct {
	Words []GWord `json:"words"`
}

func (*Grammar) Scan

func (g *Grammar) Scan(src any) error

type Letter

type Letter struct {
	Letter string `json:"letter"`
	Vowel  string `json:"tashkeel"`
	Shadda bool   `json:"shadda"`
}

func (Letter) String

func (l Letter) String() string

type TWord

type TWord struct {
	Letters []Letter `json:"letters"`

	// Rendering data
	Shrinked  bool `json:"finale"`
	Preceding bool `json:"preceding"`

	// Word data
	Tags        []string `json:"tags"` // TODO(Amr Ojjeh): Delete once tagging is async
	Punctuation bool     `json:"punctuation"`

	// Word data (configurable)
	SentenceStart bool `json:"sentenceStart"`
}

func (TWord) String

func (w TWord) String() string

type Technical

type Technical struct {
	Words []TWord `json:"words"`
}

func (*Technical) Disambiguate added in v0.1.5

func (t *Technical) Disambiguate() error

TODO(Amr Ojjeh): Automatically vowelize mabni words

func (*Technical) Scan

func (t *Technical) Scan(src any) error

func (Technical) Text added in v0.1.5

func (t Technical) Text() string

func (Technical) TextWithoutPunctuation added in v0.1.5

func (t Technical) TextWithoutPunctuation() string

Jump to

Keyboard shortcuts

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