Documentation
¶
Overview ¶
Package documents keeps the Markdown documents a bot (the facilitator of the kunveno-facilitator add-on) prepares during a meeting: per room and meeting, each under an id the bot chooses, with its title, revision and update time. A document is kept for keep after its last update.
Index ¶
- Constants
- Variables
- func CleanTitle(s string) (string, bool)
- func FileName(slug string, start time.Time, title, id string, loc *time.Location) string
- func ValidID(id string) bool
- type Gone
- type Info
- type Store
- func (s *Store) Bytes() int64
- func (s *Store) Delete(slug string, meeting int64, id string) error
- func (s *Store) Has(slug string, meeting int64) bool
- func (s *Store) Keep() time.Duration
- func (s *Store) List(slug string, meeting int64) []Info
- func (s *Store) Load(slug string, meeting int64, id string) (Info, []byte, error)
- func (s *Store) Meetings(slug string) []int64
- func (s *Store) Put(slug string, meeting int64, id, title string, body []byte) (Info, error)
- func (s *Store) Remove(slug string) error
- func (s *Store) Sweep() []Gone
Constants ¶
const ( MaxBody = 512 << 10 // bytes of Markdown MaxTitle = 120 // characters after trim MaxPerMeeting = 20 )
Limits of the bot contract.
Variables ¶
var ( ErrBadSlug = errors.New("documents: bad room slug") ErrBadID = errors.New("documents: bad document id") ErrBadTitle = errors.New("documents: bad title") ErrTooMany = errors.New("documents: the meeting already has the most documents") ErrNoDocument = errors.New("documents: no such document") )
Functions ¶
func CleanTitle ¶
CleanTitle collapses every whitespace run of s to one space and trims the ends; false when the result is not valid UTF-8, holds a control character or is not 1..MaxTitle characters long.
Types ¶
type Info ¶
type Info struct {
ID string `json:"id"`
Title string `json:"title"`
Rev int `json:"rev"`
Created time.Time `json:"created"` // first stored; orders the list
Updated time.Time `json:"updated"`
}
Info describes one stored document.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps dir/<slug>/<meeting>/<id>.md and, per meeting, index.json with the documents' Info. Safe for concurrent use.
func Open ¶
Open reads the indexes in dir (a missing dir holds none). An index that cannot be read is logged and skipped, left on disk; only a failure to list dir is an error.
func (*Store) Delete ¶
Delete removes one document at a person's request; ErrNoDocument when it is not there or has expired.
func (*Store) List ¶
List returns the meeting's documents that have not expired, in the order first stored.
func (*Store) Meetings ¶
Meetings lists the starts of the room's meetings that keep a document, newest first.
func (*Store) Put ¶
Put stores body as the document id of the room's meeting. A new id is refused with ErrTooMany once the meeting has MaxPerMeeting documents; an id already stored is replaced, its revision grows by one and its title becomes title.