API¶
Otvoreni web kalendar se može koristiti bez ograničenja. Ovaj API možeš koristiti za prilagođavanje kalendara.
Ovaj odjeljak može biti koristan u sljedećim slučajevima:
- Ti si web programer koji želi ugraditi „Otvoreni web kalendar”.
- Želiš iskoristiti potpunu fleksibilnost, a ne samo ono što je moguće na stranici konfiguracije.
- Želiš koristiti JavaScript za dinamičko generiranje dizajna i opcija kalendara.
- Želiš proširiti funkcionalnost otvorenog web kalendara.
- Želiš koristiti „Otvoreni web kalendar” kao proxy za traženje JSON događaja za tvoje stvorene događaje.
Identifikatori resursa¶
Osnovni parametri su isti pri ovim identifikatorima resursa:
/index.html
– uredi kalendar/about.html
– pogledaj stranicu s informacijama o aplikaciji/calendar.html
– pogledaj kalendar/calendar.spec
– preuzmi specifikaciju/calendar.ics
– pretplati se na ics datoteku/calendar.events.json
- FLEXIBLE - get the events as JSON Please note that you CAN use this but you cannot be sure that the JSON schema remains the same. If you want that, add tests.
Za /calendar.events.json
su potrebni dodatni parametri:
timezone=UTC
– vremenska zona u kojoj će se prikazati događajifrom=YYYY-MM-DD
– početak razdoblja u kojem se događaji događaju (uključujući)to=YYYY-MM-DD
– kraj razdoblja u kojem se događaji događaju (uključujući)
Parametri¶
All configuration parameters are described sufficiently in the default_specification. That is the reference. E.g. if you find the parameter title
in the default_specification, you have several options:
Promijeni naslov u parametru upita:
/index.html?title=calendar
Promijeni naslov u YAML specifikaciji:
title: calendar
Promijeni naslov u JSON specifikaciji:
{
"title": "calendar"
}
Kompiliranje specifikacije¶
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:
Parametri upita¶
All parameters to the calendar url are put into the specification. The query parameters have the highest precedence.
Primjeri:
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.
Primjeri:
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¶
Ovo je namijenjeno za programere i interne Python stvari.
from open_web_calendar.app import DEFAULT_SPECIFICATION
DEFAULT_SPECIFICATION['title'] = 'calendar'
OWC_SPECIFICATION¶
Ovo je opcionalna varijabla okruženja. Saznaj više o tome u Konfiguracija servera.
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.
Dodavanje parametara¶
Ako kao programer dodaš novi parametar:
- Dodaj parametar sa zadanom vrijednosti u default_specification
- Add an implementation, depending on its use in the
app.py
or the templates of the JavaScript files. The specification is already available in all of them to use. - Dodaj testove u features/configure-the-calendar.feature za provjeravanje je li kalendar odgovara na tu funkciju.
- Dodaj testove u features/edit-the-calendar.feature za osiguravanje da se parametar može koristiti kada se kalendar uređuje.
Specifikacija u kalendaru¶
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.
Također pogledaj:
Specifikacija u stranici indeksa¶
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.
Arhitektura¶
Pogledaj sliku arhitekture.
Osnova kalendara je specifikacija koja postoji u različitim oblicima. Ova specifikacija utječe na sve korake.
Nakon što se specifikacija kompilira, datoteke kalendara (ics) se preuzimaju s mjesta na internetu.
Događaji se generiraju iz datoteka kalendara.
Zatim se biraju različiti prikazi za prikaz događaja.
Na kraju, to dovodi do promjena HTML-a i stila web stranice kalendara.
U stvarnoj primjeni, ti su koraci pomalo pomiješani i neuređeni ili izostavljeni, ali ovo objašnjava osnovnu, početnu ideju o obradi događaja.