Wiki functions
- Applies to:
- All MindTouch Versions
- Role required:
- Draft Contributor
The following functions and variables are part the DekiScript and Expert runtime environment.
wiki.api(source, nilOnError) : xml
Get an XML document from the API using the current user's credentials.
Name | Type | Description |
---|---|---|
source | uri | XML source uri |
nilOnError | bool | (optional) return nil when an error occurs |
Sample (functions used: web.pre, xml.format, uri.build, site.api)
DekiScript |
---|
web.pre(xml.format(wiki.api(uri.build(site.api, ['pages', 'popular'], {limit:1})), nil)); |
Output |
---|
<pages.popular count="1" href="https://expert-help.nice.com/@api/deki/pages/popular"> <page id="1" guid="00000000000000000000000000000000" draft.state="active" href="https://expert-help.nice.com/@api/deki/pages/1?redirects=0" deleted="false"> <uri.ui>https://expert-help.nice.com/</uri.ui> <title>Home</title> <path seo="true" type="fixed"> </path> <namespace>main</namespace> <date.created>2016-10-21T23:32:16Z</date.created> <language>en-US</language> <metrics> <metric.views>497417</metric.views> </metrics> </page> </pages.popular> |
wiki.appendpath(path, title) : str
Append a title to a page path.
Name | Type | Description |
---|---|---|
path | str | wiki page path |
title | any | single page title or list of titles to append |
wiki.contributors(path, max, recent, exclude) : xml
Show most active contributors for the site or a page.
Name | Type | Description |
---|---|---|
path | str | (optional) wiki page path (default: nil) |
max | num | (optional) max results (default: 10) |
recent | bool | (optional) order by most recent (default: false) |
exclude | str | (optional) exclude inactive users (one of: none, inactive, all; default: none) |
wiki.create(label, path, template, button, title, args) : xml
Insert a link or button to create a new page.
Name | Type | Description |
---|---|---|
label | str | (optional) label for edit link or button (default: "New page") |
path | str | (optional) path to parent page for new page (default: current page) |
template | str | (optional) template to use to populate new page (default: system default) |
button | bool | (optional) show as button (default: true) |
title | str | (optional) new title for page (default: "Page Title") |
args | map | (optional) request arguments to pass to new page (default: nil) |
wiki.directory(query) : xml
Show directory of pages matching the search query.
Name | Type | Description |
---|---|---|
query | str | (optional) search query (default: all pages in main namespace) |
wiki.edit(label, path, section, button, template, args) : xml
Insert a link or button to open the editor.
Name | Type | Description |
---|---|---|
label | str | (optional) label for edit link or button (default: "Edit page") |
path | str | (optional) path of page to edit (default: current page) |
section | str | (optional) name of section to edit (default: edit entire page) |
button | bool | (optional) show as button (default: true) |
template | str | (optional) template to use to populate new page (default: system default) |
args | map | (optional) request arguments to pass to page (default: nil) |
wiki.getfile(fileid) : map
Get file object for a given file id.
Name | Type | Description |
---|---|---|
fileid | num | file id |
wiki.getpage(page, redirect) : map
Get page object at wiki page path or id.
Name | Type | Description |
---|---|---|
page | any | wiki page path or id |
redirect | bool | (optional) follow redirects (default: true) |
wiki.getsearch(query, max, sortBy, constraint, offset) : list
Get list of found page and file objects.
Name | Type | Description |
---|---|---|
query | str | search query |
max | num | (optional) max results (default: 10) |
sortBy | str | (optional) sort field (one of "score", "title", "date", "size", "wordcount", "rating.score", "rating.count"; use "-title" for reverse order; default: "score") |
constraint | str | (optional) additional search constraint (default: "") |
offset | num | (optional) number of results to skip (default: 0) |
The wiki.getsearch DekiScript function can significantly slow load on the embedded page or site. Usage of this call should be limited to lower-traffic, internal only pages and should not be included in templates.
wiki.gettag(tag) : map
Get specified tag.
Name | Type | Description |
---|---|---|
tag | str | tag name |
wiki.getuser(user) : map
Get user object by user name or id.
Name | Type | Description |
---|---|---|
user | any | user name or id |
wiki.inclusions(templates) : list
Get list of pages that form the current inclusion chain. The first item is the outermost page that is being loaded. The last item is the current page, unless the current page is a template and templates are excluded (see parameters below).
Name | Type | Description |
---|---|---|
templates | bool | (optional) list template pages as well (default: true) |
wiki.language(path) : str
Get the effective language for a page given the page language, user language, and site language.
Name | Type | Description |
---|---|---|
path | str | (optional) wiki page path |
wiki.link(page, text, title, target, redirect) : xml
Insert a hyperlink to a page.
Name | Type | Description |
---|---|---|
page | any | wiki page path or id |
text | any | (optional) link contents; can be text, an image, or another document (default: page title) |
title | str | (optional) link hover title (default: none) |
target | str | (optional) link target (default: none) |
redirect | bool | (optional) follow redirects (default: true) |
wiki.localize(resourceName, resourceParameters) : xml
Retrieve a localized resource string.
Name | Type | Description |
---|---|---|
resourceName | str | wiki resource name |
resourceParameters | list | (optional) wiki resource parameters (default: nil) |
wiki.page(path, section, revision, show, heading, nilIfMissing) : xml
Include an entire or part of another wiki page. Wiki.page will not include page styles--only content.
Expert includes a great feature which prevents an "infinite page" recursion scenario. When using a wiki.page call, Expert will detect if a recursive loop is found (i.e., when a page transcludes itself). If this scenario is detected script execution is then suspended to prevent page timeouts. This condition will affect functionality within the transcluded content including DekiScript and global variables; under this scenario these content types will not be rendered.
Name | Type | Description |
---|---|---|
path | str | wiki page path |
section | str | (optional) section to include on wiki page (default: full page) |
revision | num | (optional) page revision to use: 0 is the head revision, > 0 stands for a specific revision (for example 1 is the first revision), < 0 is revision relative to head revision (for example -1 is the previous revision) (default: head revision) |
show | bool | (optional) show page/section title of included page (default: false) *requires heading parameter below to be explicitly set |
heading | num | (optional) set page/section title heading and adjust all sub-headings accordingly; the adjustment is applied even when the page/section heading is not shown (range: 0-5, where 0 is 'Title' style, 1 is 'Heading 1', and so forth; default: keep original headings) |
nilIfMissing | bool | (optional) return nil if page/section is not found (default: return link to missing page/section) |
Embed a page into a page
wiki.page("/Path/of/Page/To/Include"); // Get the path from the URL of the page you want to include
Embed a page section into a page
wiki.page("/Path/of/Page/To/Include", "Name of Section"); // Get the path from the URL of the page you want to include
wiki.pageexists(path) : bool
Check if the given wiki page exists.
Name | Type | Description |
---|---|---|
path | str | wiki page path |
wiki.pagepermissions(page, user) : map
Get the effective permissions for a user and page.
Name | Type | Description |
---|---|---|
page | any | (optional) wiki page path or id (default: current page) |
user | any | (optional) user name or id (default: current user) |
Output a list of available user permissions
var perms = wiki.pagepermissions(); web.pre(perms);
Output a message if the user has Admin permission.
var perms = wiki.pagepermissions(); if (perms.admin) { "Welcome Administrator, we're glad you're here to manage the site" };
wiki.popular(max) : xml
Show list of popular pages
Name | Type | Description |
---|---|---|
max | num | (optional) max number of pages (default: 10) |
wiki.recentchangestimestamp(path, pages, tags, comments, files) : str
Compute a timestamp based on recent changes in a page hierarchy.
Name | Type | Description |
---|---|---|
path | str | (optional) wiki page path |
pages | bool | (optional) include page changes (default: true) |
tags | bool | (optional) include tag changes (default: true) |
comments | bool | (optional) include comment changes (default: true) |
files | bool | (optional) include file changes (default: true) |
wiki.search(query, max, sortBy, constraint, offset) : xml
Find wiki pages and files.
Name | Type | Description |
---|---|---|
query | str | search query |
max | num | (optional) max results (default: 10) |
sortBy | str | (optional) sort field (one of "score", "title", "date", "size", "wordcount", "rating.score", "rating.count"; use "-title" for reverse order; default: "score") |
constraint | str | (optional) additional search constraint (default: "") |
offset | num | (optional) number of results to skip (default: 0) |
wiki.template(path, args, target, conflict) : xml
Invoke a template page.
Name | Type | Description |
---|---|---|
path | str | template path |
args | any | (optional) template arguments (default: nil) |
target | str | (optional) alternative body target (default: nil) |
conflict | str | (optional) conflict resolution if target already exists (one of "ignore", "replace", or "append"; default: "ignore") |
wiki.text(path, section, revision, nilIfMissing) : str
Retrieve the text contents for an entire or part of another wiki page.
Name | Type | Description |
---|---|---|
path | str | wiki page path |
section | str | (optional) section to include on wiki page (default: nil) |
revision | num | (optional) page revision to use: 0 is the head revision, > 0 stands for a specific revision (for example 1 is the first revision), < 0 is revision relative to head revision (for example -1 is the previous revision) (default: head revision) |
nilIfMissing | bool | (optional) return nil if page/section is not found (default: return name of missing page/section) |
wiki.toc(path, depth) : xml
Show the table of contents of a wiki page.
Name | Type | Description |
---|---|---|
path | str | (optional) wiki page path |
depth | num | (optional) heading depth for table of contents (default: all) |
wiki.tree(path, depth, reverse) : xml
Show hierarchy of pages starting at a wiki page.
This DekiScript call can significantly slow load on the embedded page or site. Usage of this call should be limited to Admin only pages and should not be included in templates.
Name | Type | Description |
---|---|---|
path | str | (optional) wiki page path |
depth | num | (optional) nesting depth for retrieving child pages (default: all) |
reverse | bool | (optional) reverse order of child pages |
wiki.uri(path, query) : str
Retrieve the full uri of a given wiki page.
Name | Type | Description |
---|---|---|
path | str | wiki page path |
query | str | (optional) query |
wiki.version() : map
Get the current version number.