Documentation
¶
Index ¶
- Constants
- type CalendarInfo
- type Core
- func (c *Core) CloneCalendar(repoUrl *url.URL, password string) error
- func (c *Core) CreateCalendar(name, password string) error
- func (c *Core) CreateEvent(event Event) (*Event, error)
- func (c *Core) ExportZip(calendar string) ([]byte, error)
- func (c *Core) GetEvent(id uuid.UUID) (*Event, error)
- func (c *Core) GetEvents(from, to time.Time) []Event
- func (c *Core) ListCalendars() ([]CalendarInfo, error)
- func (c *Core) LoadCalendars() error
- func (c *Core) RemoveCalendar(name string) error
- func (c *Core) RemoveEvent(event Event) error
- func (c *Core) RemoveRepeatingEvent(event Event, strat UpdateStrategy) error
- func (c *Core) RenameCalendar(oldName, newName string) error
- func (c *Core) SetCorsProxy(proxyUrl string) error
- func (c *Core) SyncAll() error
- func (c *Core) UpdateEvent(event Event) (*Event, error)
- func (c *Core) UpdateRemote(calendar string, remoteURL *url.URL) error
- func (c *Core) UpdateRepeatingEvent(old, new Event, strat UpdateStrategy) (*Event, error)
- type Event
- type Freq
- type IntervalTree
- type Repetition
- type Tag
- type UpdateStrategy
Constants ¶
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CalendarInfo ¶ added in v0.1.3
type CalendarInfo struct {
Name string `json:"name"`
Tags []Tag `json:"tags,omitempty"`
Encrypted bool `json:"encrypted"`
RemoteUrl string `json:"remote_url,omitempty"`
}
A DTO like calendar struct.
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
The real API.
Works with raw Go structs, use api.Api to work with JSON.
func (*Core) CloneCalendar ¶
Clones a repository/calendar from url, using CORS proxy, if specified.
func (*Core) CreateCalendar ¶
Creates a new calendar.
func (*Core) CreateEvent ¶
Creates a new event and save it into git.
func (*Core) GetEvents ¶
Returns an array of events which fall into the specified interval [from, to].
func (*Core) ListCalendars ¶
func (c *Core) ListCalendars() ([]CalendarInfo, error)
ListCalendars returns calendar metadata.
func (*Core) LoadCalendars ¶
Tries to load every directory/repo/calendar in the fs root.
func (*Core) RemoveCalendar ¶
Removes and deletes the whole calendar.
func (*Core) RemoveEvent ¶
Removes a real (basic/parent) event from the calendar. Use RemoveRepeatingEvent method for repeating events.
func (*Core) RemoveRepeatingEvent ¶
func (c *Core) RemoveRepeatingEvent(event Event, strat UpdateStrategy) error
Removes a child event by adding an exception to its parent repeat rule.
func (*Core) RenameCalendar ¶ added in v0.1.3
func (*Core) SetCorsProxy ¶
Sets a url for CORS proxy. This is only needed inside a browser.
func (*Core) UpdateEvent ¶
Updates a Basic event based on its id. Use UpdateRepeatingEvent method for repeating events.
func (*Core) UpdateRemote ¶ added in v0.1.4
func (*Core) UpdateRepeatingEvent ¶
func (c *Core) UpdateRepeatingEvent(old, new Event, strat UpdateStrategy) (*Event, error)
Removes a child event by adding an exception to its parent repeat rule.
type Event ¶
type Event struct {
Id uuid.UUID `json:"id"` // Should not change (different id = different event). Only UUIDv4 or UUIDv8 (for children) is being used.
Title string `json:"title"` // Should not be empty.
Location string `json:"location"` // Physical or virtual location (e.g., URL).
Description string `json:"description"`
From time.Time `json:"from"`
To time.Time `json:"to"`
Calendar string `json:"calendar"` // The name of the calendar the event belongs to.
Tag string `json:"tag"` // User-defined category or label.
ParentId uuid.UUID `json:"parent_id"` // Specific for child events. It is uuid.Nil if the event is basic or parent.
Repeat *Repetition `json:"repeat"`
UpdatedAt time.Time `json:"updated_at"` // Used for git conflict resolution; latest wins.
}
Event represents a single calendar entry.
Can be one of these:
- Basic: A standalone event that does not repeat (ParentId is nil, Repeat is nil).
- Parent: The "source of truth" for a recurring series (ParentId is nil, Repeat defines the rule).
- Child: A generated occurrence from a Parent (ParentId points to its Parent, Repeat copies the Parent rule).
func (*Event) LoadFromFile ¶
type IntervalTree ¶
type IntervalTree struct {
// contains filtered or unexported fields
}
func NewIntervalTree ¶
func NewIntervalTree() *IntervalTree
func (*IntervalTree) InsertEvent ¶
func (et *IntervalTree) InsertEvent(event Event) error
Inserts an Event to its interval in the tree.
func (*IntervalTree) RemoveEvent ¶
func (et *IntervalTree) RemoveEvent(event Event) error
Deletes an Event from the interval tree.
type Repetition ¶
type Repetition struct {
Frequency Freq `json:"frequency"` // The unit of time for recurrence (Day, Week, Month, etc.).
Interval int `json:"interval"` // The multiplier for Frequency (e.g., Interval:2 * Frequency:Week = every other week).
Until time.Time `json:"until"` // Hard stop date for the series. (Inclusive: occurrences starting BEFORE or even ON this time are included.)
Count int `json:"count"` // Total number of occurrences to generate.
Exceptions []uuid.UUID `json:"exceptions"` // List of Child IDs that deviate from the base rule (edited or cancelled).
}
Repetition defines the recurrence rules for a Parent event.
A Repetition object exists only on Parent events to generate Children. A series must be capped by either Until (date) or Count (occurrences). Not both.
func (*Repetition) Validate ¶
func (r *Repetition) Validate() error
type UpdateStrategy ¶
type UpdateStrategy int
const ( Current UpdateStrategy = iota Following All )
func (UpdateStrategy) IsValid ¶
func (opt UpdateStrategy) IsValid() bool