Web functions
- Applies to:
- All MindTouch Versions
- Role required:
- Draft Contributor
These web functions are part the DekiScript and Expert runtime environment
web.checkstyle(style) : str
Check contents of style attribute for possible XSS vulnerabilities.
Name | Type | Description |
---|---|---|
style | str | style contents to check |
web.checkuri(uri) : str
Check URI for possible JavaScript code.
Name | Type | Description |
---|---|---|
uri | str | uri to check |
web.format(source, ttl, nilIfMissing) : xml
Convert text into html using a simple formatter.
Name | Type | Description |
---|---|---|
source | str | (optional) HTML source text or source uri (default: none) |
ttl | num | (optional) caching duration in seconds (range: 60 - 86400; default: 300) |
nilIfMissing | bool | (optional) return nil if source could not be loaded (default: text with error message) |
wed.format does not support including a port in the source.
web.html(source, xpath, namespaces, ttl, nilIfMissing) : xml
Convert text to HTML. The text value can optionally be retrieved from a web-service.
Name | Type | Description |
---|---|---|
source | str | (optional) HTML source text or source uri (default: none) |
xpath | str | (optional) xpath to value (default: none) |
namespaces | map | (optional) namespaces (default: none) |
ttl | num | (optional) caching duration in seconds (range: 60 - 86400; default: 300) |
nilIfMissing | bool | (optional) return nil if source could not be loaded (default: text with error message) |
var html = 'This is a link to <a href="http://www.mindtouch.com">MindTouch</a>'; web.html(html);
web.image(uri, width, height, text) : xml
Insert an image.
Name | Type | Description |
---|---|---|
uri | str | image uri |
width | num | (optional) image width |
height | num | (optional) image height |
text | str | (optional) image alternative text |
web.json(source, ttl, nilIfMissing) : any
Get a JSON value from a web-service.
Name | Type | Description |
---|---|---|
source | str | (optional) source text or source uri (default: none) |
ttl | num | (optional) caching duration in seconds (range: 60 - 86400; default: 300) |
nilIfMissing | bool | (optional) return nil if source could not be loaded (default: text with error message) |
web.link(uri, text, title, target) : xml
Insert a hyperlink.
Name | Type | Description |
---|---|---|
uri | str | link uri |
text | any | (optional) link contents; can be text, an image, or another document (default: link uri) |
title | str | (optional) link hover title (default: none) |
target | str | (optional) link target (default: none) |
web.link("http://www.mindtouch.com","link to MindTouch","Hover Over","_blank");
web.list(source, xpath, namespaces, xml, ttl, nilIfMissing) : list
Get list of values from an XML document or web-service.
Name | Type | Description |
---|---|---|
source | str | XML source text or source uri |
xpath | str | xpath to list of values |
namespaces | map | (optional) namespaces (default: none) |
xml | bool | (optional) capture enclosing XML element (default: false) |
ttl | num | (optional) caching duration in seconds (range: 60 - 86400; default: 300) |
nilIfMissing | bool | (optional) return nil if source could not be loaded (default: text with error message) |
web.pre(text) : xml
Insert pre-formatted text.
Name | Type | Description |
---|---|---|
text | any | text to insert |
web.pre(page.tags);
web.size(size) : str
Convert numeric size to text.
Name | Type | Description |
---|---|---|
size | num | (optional) value to convert (0.75 = "75%", 0.999 = "100%", 1.0 = "1px" |
web.style(name, value) : str
Create text for a 'style' attribute.
Name | Type | Description |
---|---|---|
name | str | style name |
value | str | (optional) style value; if missing no style is emitted (default: nil) |
web.text(source, xpath, namespaces, xml, ttl, nilIfMissing) : str
Get a text value from a web-service.
Name | Type | Description |
---|---|---|
source | str | (optional) source text or source uri (default: none) |
xpath | str | (optional) xpath to value (default: none) |
namespaces | map | (optional) namespaces (default: none) |
xml | bool | (optional) capture enclosing XML element (default: false) |
ttl | num | (optional) caching duration in seconds (range: 60 - 86400; default: 300) |
nilIfMissing | bool | (optional) return nil if source could not be loaded (default: text with error message) |
web.toggle(content, title, heading, speed, hidden) : xml
Embed a clickable title that toggles the provided document content.
Name | Type | Description |
---|---|---|
content | xml | content to toggle |
title | str | (optional) title to display for toggle (default: "Show") |
heading | num | (optional) heading level for title (default: 3) |
speed | str | (optional) content toggle speed (one of "slow", "normal", "fast" or milliseconds number; default: instantaneous) |
hidden | bool | (optional) hide content initially (default: true) |
web.xml(source, xpath, namespaces, ttl, nilIfMissing) : xml
Get an XML document from a web-service.
Name | Type | Description |
---|---|---|
source | str | XML source text or source uri |
xpath | str | (optional) xpath to value (default: none) |
namespaces | map | (optional) namespaces (default: none) |
ttl | num | (optional) caching duration in seconds (range: 60 - 86400; default: 300) |
nilIfMissing | bool | (optional) return nil if source could not be loaded (default: text with error message) |