Documentation
¶
Overview ¶
Package events implements the events module (see CWUP/tasks/events.md): dates, events and performances listed from one SML file of the content repo, with a page and a calendar file per event.
Index ¶
- Constants
- Variables
- func Downscale(src image.Image, width int) *image.RGBA
- func ICS(e Event, d ICSData) string
- func ParseTime(v string, loc *time.Location) (t time.Time, dateOnly bool, err error)
- func RenderDetail(d DetailData) (template.HTML, error)
- func RenderList(d ListData) (template.HTML, error)
- func Thumbable(path string) bool
- func Thumbnail(src []byte, width int) ([]byte, error)
- func ValidID(id string) bool
- type Card
- type DetailData
- type Event
- func (e Event) Alt(lang string) string
- func (e Event) HasEnd() bool
- func (e Event) IsPast(now time.Time) bool
- func (e Event) Local(key, lang string) string
- func (e Event) Place(lang string) string
- func (e Event) Teaser(lang string) string
- func (e Event) Text(lang string) string
- func (e Event) Title(lang string) string
- func (e Event) Until() time.Time
- type Formatter
- type ICSData
- type Index
- type Labels
- type ListData
- type Texts
Constants ¶
const ThumbWidth = 600
ThumbWidth is the width of list preview images: two times a typical list column, sharp on high-density screens.
Variables ¶
var ErrUnsupported = errors.New("image format not supported for thumbnails")
ErrUnsupported means the image cannot be turned into a thumbnail; the caller serves the original instead.
Functions ¶
func Downscale ¶
Downscale scales src down to at most width pixels wide (never up) with the same box filter as Thumbnail; transparent areas become white. Used by the market module for uploaded photos.
func ICS ¶
ICS returns an iCalendar (RFC 5545) file with one event. Times are written in UTC, all-day events as dates, so no VTIMEZONE is needed.
func RenderDetail ¶
func RenderDetail(d DetailData) (template.HTML, error)
RenderDetail renders the page of one event.
func RenderList ¶
RenderList renders the Events element.
Types ¶
type Card ¶
type Card struct {
URL string
Title string
When string
ISOStart string // machine-readable start for <time> and schema.org
ISOEnd string
Place string
Thumb string // list image (thumbnail when possible)
Image string // full image
Alt string
Past bool
}
Card is one event prepared for display: texts in the visitor's language, dates formatted, image URLs resolved.
type DetailData ¶
type DetailData struct {
Texts Texts
Card Card
ListURL string
Description template.HTML // compiled Markdown, empty = teaser
Link string // external link
ICS string // calendar file URL, empty for past events
}
DetailData feeds the page of one event.
type Event ¶
type Event struct {
ID string
Start time.Time
End time.Time // zero when the event has no end
AllDay bool // start given as a date only
EndAllDay bool // end given as a date only
Image string // path below static/ or an absolute URL
Link string // external link (tickets, more info)
// contains filtered or unexported fields
}
Event is one entry of the index file.
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter formats dates with the labels of one language.
type ICSData ¶
type ICSData struct {
UID string // globally unique, e.g. "<id>@<domain>"
Title string
Place string
Description string
URL string // the event's page
Stamp time.Time
}
ICSData is what goes into the calendar file of one event.
type Index ¶
Index is a parsed index file: the events in file order and the labels.
func Parse ¶
Parse parses an Events { Labels {} Event {} ... } document; times are local to loc. Only a broken document or a wrong root is an error: invalid events are skipped with a warning, so one typo never empties the list.
type Labels ¶
type Labels struct {
// contains filtered or unexported fields
}
Labels are the visible texts and date formats of the events module, set by the site in the index file's Labels {} block. Every key accepts key_<lang> variants for any language code.
func NewLabels ¶
NewLabels returns labels read from node (nil = no Labels {} block) with the given built-in fallback texts, keyed by language and label. Other modules (the blog) use it for their own texts and date formats.