
 page.pl -- Provide the SWISH application as Prolog HTML component
page.pl -- Provide the SWISH application as Prolog HTML component
This library provides the SWISH page and its elements as Prolog HTML
grammer rules. This allows for server-side generated pages to include
swish or parts of swish easily into a page.
 swish_reply(+Options, +Request) swish_reply(+Options, +Request)
- HTTP handler to reply the default SWISH page. Processes the
following parameters:
- code(Code)
- Use Code as initial code. Code is either an HTTP url or
- url(URL)
- Download code from URL. As code(URL), but makes the browser
download the source rather than the server.
- background(Code)
- Similar to Code, but not displayed in the editor.
- examples(Code)
- Provide examples. Each example starts with ?- at the beginning
of a line.
- q(Query)
- Use Query as the initial query.
- show_beware(Boolean)
- Control showing the beware limited edition warning.
- preserve_state(Boolean)
- If true, save state on unload and restore old state on load.
 
 add_show_beware(+Options0, -Option) is det[private] add_show_beware(+Options0, -Option) is det[private]
- Add show_beware(false)when called with code, query or examples.
These are dedicated calls that do not justify this message.
 add_preserve_state(+Options0, -Option) is det[private] add_preserve_state(+Options0, -Option) is det[private]
- Add preserve_state(false)when called with code.
 source_option(+Request, +Options0, -Options)[private] source_option(+Request, +Options0, -Options)[private]
- If the data was requested as '/Alias/File', reply using file
Alias(File).
 source_file(+Request, -File, +Options) is semidet[private] source_file(+Request, -File, +Options) is semidet[private]
- File is the file associated with a SWISH request. A file is
associated if path_info is provided. If the file does not
exist, an HTTP 404 exception is returned. Options:
- alias(-Alias)
- Get the swish_config:source_alias/2 Alias name that
was used to find File.
 
 source_metadata(+Path, +Code, -Meta:dict) is det[private] source_metadata(+Path, +Code, -Meta:dict) is det[private]
- Obtain meta information about a local source file. Defined meta
info is:
- last_modified:Time
- Last modified stamp of the file. Always present.
- loaded:true
- Present of the file is a loaded source file
- modified_since_loaded:true
- Present if the file loaded, has been edited, but not
yet reloaded.
 
 swish_reply_resource(+Request) is semidet swish_reply_resource(+Request) is semidet
- Serve /swish/Resource files. In recent Bootstrap versions, the
path to `fonts/` is generated that should refer to
node_modules/bootstrap/dist/fonts. This could be a bug in
Bootstrap or in teh CSS cleaning. For now, we hack around the
issue here.
 swish_page(+Options)// swish_page(+Options)//
- Generate the entire SWISH default page.
 swish_navbar(+Options)// swish_navbar(+Options)//
- Generate the swish navigation bar.
 swish_title(+Options)// is det[private] swish_title(+Options)// is det[private]
- Emit the HTML header options dealing with the title and shortcut
icons. This can be hooked using title//1.
 swish_logos(+Options)// is det[private] swish_logos(+Options)// is det[private]
- Emit the navbar branding logos at the top-left. Can be hooked
using swish_logos//1.
-  swish_config:logo(+Options)// is semidet[multifile]
- Hook to include the top-left logos. The default calls
pengine_logo//1 and swish_logo//1. The implementation should
emit zero or more <a> elements. See
config_available/branding.plfor an example.
 pengine_logo(+Options)// is det pengine_logo(+Options)// is det
 swish_logo(+Options)// is det swish_logo(+Options)// is det
- Emit an <a> element that provides a link to Pengines and SWISH
on this server. These may be called from swish_config:logo//1 to
include the default logos.
 swish_content(+Options)// swish_content(+Options)//
- Generate the SWISH editor, Prolog output area and query editor.
Options processed:
- source(HREF)
- Load initial source from HREF
- chat_count(Count)
- Indicate the presense of Count chat messages
 
 swish_options(+Options)//[private] swish_options(+Options)//[private]
- Emit additional options. This is similar to config, but the
config object is big and stable for a particular SWISH server.
The options are set per session.
 source(+Type, +Options)//[private] source(+Type, +Options)//[private]
- Associate the source with the SWISH page. The source itself is
stored in the textarea from which CodeMirror is created.
Options:
- code(+String)
- Initial code of the source editor
- file(+File)
- If present and code(String)is present, also associate the
editor with the given file. See storage.pl.
- url(+URL)
- as file(File), but used if the data is loaded from an
alias/file path.
- title(+Title)
- Defines the title used for the tab.
 
 background(+Options)//[private] background(+Options)//[private]
- Associate the background program (if any). The background
program is not displayed in the editor, but is sent to the
pengine for execution.
 notebooks(+Type, +Options)//[private] notebooks(+Type, +Options)//[private]
- We have opened a notebook. Embed the notebook data in the
left-pane tab area.
 download_source(+HREF, -Source, +Options) is det[private] download_source(+HREF, -Source, +Options) is det[private]
- Download source from a URL. Options processed:
- timeout(+Seconds)
- Max time to wait for reading the source. Default
is 10 seconds.
- max_length(+Chars)
- Maximum lenght of the content. Default is 1 million.
- encoding(+Encoding)
- Encoding used to interpret the text. Default is UTF-8.
 
- bug
- - : Should try to interpret the encoding from the HTTP
header.
 
 document_type(-Type, +Options) is det[private] document_type(-Type, +Options) is det[private]
- Determine the type of document.
- Arguments:
- 
| Type | - is one of swinborpl |  
 
 
 swish_resources// swish_resources//
- Include SWISH CSS and JavaScript. This does not use
html_require//1 because we need to include the JS using
RequireJS, which requires a non-standard script element.
 swish_rest_reply(+Method, +Request, +Options) is det[private] swish_rest_reply(+Method, +Request, +Options) is det[private]
- Handle non-GET requests. Such requests may be used to modify
source code.
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.
 swish_css(Arg1, Arg2) swish_css(Arg1, Arg2)
 swish_js(Arg1, Arg2) swish_js(Arg1, Arg2)