Script Services
Last modified by Eleni Cojocariu on 2026/11/11 11:02
Content
Reference
$services.advancedbookmarks gives scripts access to the bookmarks of the current wiki. Each method returns a map ready to be serialized as JSON, with an HTTP status code under the status key and, on failure, an error key. Write methods only accept POST requests carrying a valid CSRF token in the form_token parameter. The admin methods return forbidden to the users who do not administer the wiki.
| Member | Returns | Default | What it does |
|---|---|---|---|
| getBookmarks(String user) | user, version, size, maxSize, folders, bookmarks | Current user | Reads the folders and bookmarks of a user, in display order. Each bookmark has page, label, folder, order, panel and viewable, plus exists and url when the current user can view the page. size and maxSize are the space used and allowed, in bytes. |
| getPanel() | bookmarks | Reads the bookmarks of the current user selected for the Panel, or the first ones, up to the Panel size of the wiki. | |
| isBookmarked(String page) | bookmarked, bookmarkable | Tells whether the current user bookmarked the page, and whether the page may be bookmarked (false for an excluded page). | |
| isStarEnabled() | boolean | Tells whether the current wiki displays the star. | |
| toggle(String page) | bookmarked | Adds the page to the uncategorized bookmarks of the current user, or removes it. Write method. | |
| save(String user, String json, String version) | version, size | Current user | Replaces the bookmarks of a user with the folders and bookmarks arrays of json, provided they were not modified since version was read (0 if there were none). Write method. |
| exportBookmarks(String user) | content | Current user | Returns the export file of a user, as a JSON string. |
| importBookmarks(String user, String json, String mode, String version) | version, imported, skipped | Current user | Imports an export file in merge or replace mode, provided the bookmarks were not modified since version was read. Write method. |
| admin.getStoreStatus() | available | Tells whether the Solr core can be queried. | |
| admin.exportWiki() | content, exported, skipped | Returns the wiki export file of the current wiki, and the number of users exported and skipped. | |
| admin.startWikiImport(String mode) | users | Checks the wiki export file sent in the file part of the current multipart/form-data request, then imports it in the background in merge or replace mode. Write method. | |
| admin.getWikiImportStatus() | state, progress, importedUsers, skippedUsers, failedUsers, importedBookmarks, skippedBookmarks, failed | Reads the state of the running or last import: none, running or finished. failed is true when it stopped on an unexpected error. |
| error | status | Cause |
|---|---|---|
| forbidden | 403 | The current user may not perform the operation, or the page is excluded or cannot be viewed. |
| invalidToken | 403 | The CSRF token is missing or invalid. |
| methodNotAllowed | 405 | A write method was called outside a POST request. |
| invalid | 400 | A parameter or the JSON is invalid. |
| tooLarge | 400 | The bookmarks would exceed their maximum size. |
| conflict | 409 | The bookmarks were modified since version was read, or a wiki import is already running. |
| storageError | 500 | The Solr core failed. The details are in the server log. |
{{velocity}}
#set ($result = $services.advancedbookmarks.getBookmarks(''))
#if ($result.status == 200)
You have $result.bookmarks.size() bookmarks.
#else
The bookmarks cannot be read: $result.error
#end
{{/velocity}}The script displays, for instance:
You have 7 bookmarks.