Zum Inhalt

API

Generell ist der offene Web-Kalender da, um ohne Enschränkung genutzt zu werden. Die API kann genutzt werden, um Kalender dynamisch anzupassen.

Dieses Dokument ist von Belang, wenn davon was zutrifft:

  • Du bist ein Web-Entwickler, der den offenen Web-Kalender einbauen möchte.
  • Du möchtest die volle Flexibilität, nicht nur das, was mit der Konfigurationsseite möglich ist.
  • Du nutzt JavaScript, um dynamisch das Kalenderdesign und die Optionen anzupassen.
  • Du möchtest die Funktionalität des offenen Web-Kalenders erweitern.
  • Du möchtest den offenen Web-Kalender als Proxy benutzen, um JSON-Daten zu Terminen selbst anzuzeigen.

Endpunkte

Diese Endpunkte benutzen die selben Parameter:

  • /index.html - Editiere den Kalender
  • /about.html - Zeige die Beschreibung des Kalenders an
  • /calendar.html - Zeige den Kalender an
  • /calendar.spec - Lade die Spezifikation herunter
  • /calendar.ics - Lade die ICS-Kalenderdatei herunter
  • /calendar.events.json - FLEXIBEL - hole die Termine als JSON. Bitte wisse, dass Du das nutzen KANNST aber nicht sicher sein kannst, dass das JSON-Schema so bleibt. Wenn du das willst, füge neue Tests hinzu.

Additional parameters are required for /calendar.events.json:

  • timezone=UTC - die Zeitzone, in der die Termine angezeigt werden
  • from=YYYY-MM-DD - der Start des Zeitabschnitts, der angezeit werden soll (eingeschlossen)
  • to=YYYY-MM-DD - Das Ende des Zeitabschnitts, in dem Termine angezeigt werden sollen (nicht eingeschlossen)

Parameter

Alle Konfigurationsparameter sind ausreichend in der default_specification beschrieben. Das ist die Referenz. Z.B. wenn Du den Parameter title in der default_specification findest, dann hast du mehrere Optionen:

Ändere den Titel in den URL-Parametern:

/index.html?title=calendar

Ändere den Titel in der YAML-Spezifikation:

title: calendar

Ändere den Titel in der JSON-Spezifikation:

{
  "title": "calendar"
}

Die Spezifikation Zusammenstellen

You can change the calendar behavior and looks with parameters. If the same parameter is specified in different places, the earlier place listed below has the highest precedence. These are the places to specify parameters:

URL-Parameter

All parameters to the calendar url are put into the specification. The query parameters have the highest precedence.

Examples:

index.html?language=de
calendar.html?title=CALENDAR

specification_url

If you specify this query parameter, the editor configuration is loaded from this url, too. Query parameters are still more important than what is written in this file. The source format can be YAML or JSON.

Examples:

calendar.html?specification_url=https://github.com/niccokunzmann/open-web-calendar/raw/master/open_web_calendar/default_specification.yml

open_web_calendar.app.DEFAULT_SPECIFICATION

This is intended for developers and Python-internal.

from open_web_calendar.app import DEFAULT_SPECIFICATION
DEFAULT_SPECIFICATION['title'] = 'calendar'

OWC_SPECIFICATION

This is an optional environment variable. Please read more about it in the Server Configuration.

default_specification

This file contains the default parameters. They must not be hard-coded in the source code. All parameters are listed and documented there so this file can be used for reference. Do not modify this file, instead use the OWC_SPECIFICATION environment variable.

Parameter hinzufügen

If you add a new parameter as a developer:

Spezifikation im Kalender

app.py compiles the specification from the given parameters in get_specification(). In the template you can access the specification through the specification variable. The specification is available to JavaScript as the specification variable.

Spezifikation auf der Index-Seite

The default specification is available before the calendar is built via JavaScript in the configuration.default_specification variable. There is a getSpecification() function which created the specification from the inputs. Generally, the specification variable should be used.

Architektur

Das Bild der Architektur ist hier unten.

architecture

The base of a calendar is the specification, given in the various forms. This specification influences all the steps.

After the specification is compiled, the calendar (ics) files are downloaded from the locations on the Internet.

From the calendar files, the events are generated.

Then, different views are chosen to display the events.

In the end, these lead to HTML and style changes of the calendar website.

In the real application, these steps are bit bit mixed up and unordered or omitted but this explains simply the basic, initial idea behind the event processing.