Pages
The Wave server stores and manages content. Content is stored in a page cache, called a site. A Wave server contains exactly one site. A site holds a collection of pages. A page is composed of cards. Cards hold content and data buffers.
To reference a site from within a Wave script, import site
.
site
is a dictionary-like object.
To reference the current site from within a Wave app, use q.site
.
To reference a page hosted at /foo
, use site['/foo']
.
To reference the current page in a Wave app, use q.page
.
page
is also a dictionary-like object. To reference a card named foo
, use page['foo']
.
There are two ways to add a card to a page.
The first way is to assign a new card to page['foo']
.
The second way is to use page.add()
. This is useful when you want to add a card to a page and obtain a reference to the new card.
The following two forms are equivalent. The second form is more concise.
To delete a card named foo
from a page, use del page['foo']
:
Assigning a card to page['foo']
replaces any previously assigned card named foo
. Therefore, the following two forms are equivalent. The second form is more concise, hence preferred.
To save a page from within a Wave script, use page.save()
.
To save the active page from within a Wave app, use q.page.save()
.
caution
q.page.save()
is an async
function, so you must await
while calling it.
You don't need to explicitly create a new page. A page is automatically created on save if it doesn't exist.
To delete the page hosted at /foo
, use page.drop()
or del site['/foo']
. The following three forms are equivalent.
Deleting a page automatically drops all cards associated with that page. Conversely, to delete all cards from a page, simply delete the page.
To clear all cards in the active page from within a Wave app, use q.page.drop()
: