Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
server:web [2010/02/21 20:37] – digitalman | server:web [2020/11/18 06:19] – web_root_dir ecbbs | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Web Server ====== | ====== Web Server ====== | ||
+ | |||
+ | The Synchronet Web Server serves static (e.g. files) and dynamic content to HTTP clients (e.g. web browsers). | ||
===== Introduction ===== | ===== Introduction ===== | ||
Line 9: | Line 11: | ||
It also, through Server-Side JavaScript (SSJS), allows dynamic pages to be | It also, through Server-Side JavaScript (SSJS), allows dynamic pages to be | ||
created which can access BBS data directly. | created which can access BBS data directly. | ||
+ | |||
+ | For more information on the webv4 implementation, | ||
- | ===== Web Server | + | ===== Configuration ===== |
- | Most of the web server configuration is in your [[Startup INI]] file (usually | + | |
- | ctrl/ | + | |
+ | ==== Startup INI [Web] Section Keys ==== | ||
- | ==== [Web] Section Keys ==== | + | The '' |
=== RootDirectory === | === RootDirectory === | ||
Line 25: | Line 28: | ||
'' | '' | ||
- | ::!:: Older versions of Synchronet had this value default to '' | + | **NOTE**: Older versions of Synchronet had this value default to '' |
=== ErrorDirectory === | === ErrorDirectory === | ||
Default value: '' | Default value: '' | ||
- | The directory relative to [# | + | The directory relative to [[# |
message files are located. | message files are located. | ||
numeric HTTP error code they will represent and may be either '' | numeric HTTP error code they will represent and may be either '' | ||
Line 48: | Line 51: | ||
=== Authorization === | === Authorization === | ||
- | Default value: '' | + | Default value: '' |
A comma-separated list of authentication mechanisms in order of preference. | A comma-separated list of authentication mechanisms in order of preference. | ||
Line 112: | Line 115: | ||
Default value: '' | Default value: '' | ||
- | The | separated list of options to enable. | + | The '' |
- | options, the web server also supports the following: | + | |
+ | '' | ||
- | * '' | ||
Log all received data to the console log, as well as various | Log all received data to the console log, as well as various | ||
extra bits related to receiving data. | extra bits related to receiving data. | ||
- | * | + | '' |
- | Log all transmitted data except the reply body itself, as well | + | |
- | as various extra bits of information related to transmitted | + | |
- | data. | + | |
- | VIRTUAL_HOSTS | + | |
- | Supports name-based virtual hosts. | + | |
- | host names, you can have each host name return unique content | + | |
- | depending on which hostname is used. ie: if | + | |
- | freebsd.synchro.net and nix.synchro.net both resolved to your | + | |
- | system, you could have FreeBSD-specific pages on one, and | + | |
- | general *nix stuff on the other. | + | |
- | A virtual host is added by simply putting the desired content | + | |
- | into a sub-directory of RootDirectory with the desired hostname | + | |
- | ie: web/ | + | |
- | the request host name (very old browsers, or some automated | + | |
- | tools) they will be served out of document root. | + | |
- | It is therefore a good idea to put links to your various | + | |
- | virtual hosts in an index.html page in RootDirectory something | + | |
- | like this: | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | </ | + | |
- | < | + | |
- | Your browser is either too old to support | + | |
- | name-based virtual hosts, or you have visited a | + | |
- | virtual hosts that is not yet configured. | + | |
- | following are hosted here:< | + | |
- | <a href=" | + | |
- | </ | + | |
- | <a href=" | + | |
- | </ | + | |
- | </ | + | |
- | NO_CGI | + | |
- | Disable CGI script execution. | + | |
- | HTTP_LOGGING | + | |
- | Enable logging to a Common Logfile Format log as described in | + | |
- | the HttpLogFile section. | + | |
- | programs (like Webalizer: http:// | + | |
- | NO_JAVASCRIPT | + | |
- | Disable SSJS execution. | + | |
+ | Log all transmitted data except the reply body itself, as well | ||
+ | as various extra bits of information related to transmitted | ||
+ | data. | ||
- | 2.2. Other web-related | + | '' |
- | ------------------------------------------ | + | |
- | In addition to the [Web] keys in the initialization | + | Supports name-based virtual hosts. If your system has multiple |
+ | host names, you can have each host name return unique content | ||
+ | depending on which hostname is used. ie: if | ||
+ | '' | ||
+ | system, you could have FreeBSD-specific pages on one, and | ||
+ | general *nix stuff on the other. | ||
+ | |||
+ | A virtual host is added by simply putting the desired content | ||
+ | into a sub-directory of [[# | ||
+ | ie: '' | ||
+ | the request host name (very old browsers, or some automated | ||
+ | tools) they will be served out of document root. | ||
+ | It is therefore a good idea to put links to your various | ||
+ | virtual hosts in an '' | ||
+ | like this: | ||
+ | <code html> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | Your browser is either too old to support | ||
+ | name-based virtual hosts, or you have visited a | ||
+ | virtual hosts that is not yet configured. | ||
+ | following are hosted here:< | ||
+ | <a href=" | ||
+ | <a href=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | Disable CGI script execution. | ||
+ | |||
+ | '' | ||
+ | |||
+ | Enable logging to a Common Logfile Format log as described in | ||
+ | the HttpLogFile section. | ||
+ | programs (like Webalizer: http:// | ||
+ | |||
+ | '' | ||
+ | |||
+ | Disable SSJS execution. | ||
+ | |||
+ | '' | ||
+ | |||
+ | Enable TLS support. | ||
+ | |||
+ | '' | ||
+ | |||
+ | Indicates that all URLs availabe via http are also available via https and redirects clients who want a TLS session to the https location. | ||
+ | |||
+ | ==== Other configuration files ==== | ||
+ | |||
+ | In addition to the '' | ||
also uses some other configuration files: | also uses some other configuration files: | ||
- | | + | === ctrl/ |
- | Contains the file extension to mime-type mapping. | + | Contains the file extension to mime-type mapping. |
- | is in the format " | + | is in the format " |
- | The extensions are case-insensitive and do not include the ' | + | The extensions are case-insensitive and do not include the ' |
- | ctrl/ | + | |
- | Contains the URLs to the icons used by the default 404.ssjs | + | |
- | script for each file type/ | + | |
- | Example: " | + | |
- | DIRECTORY which is used for directories and DefaultIcon which | + | |
- | is used for extensions which don't exist in the list. | + | |
- | ctrl/ | + | |
- | Contains 2 sections, [CGI] and [JavaScript], | + | |
- | extensions and their associated content-creation handlers are | + | |
- | specified. The [CGI] section is for natively-executed CGI handlers | + | |
- | (e.g. "pl = perl" indicates " | + | |
- | files). The [JavaScript] section is used for JS-executed content | + | |
- | handlers (e.g. "xjs = xjs_handler.js" | + | |
- | ctrl/ | + | |
- | Contains a list of system environment variables to pass to CGI | + | |
- | processes. | + | |
- | value, over-ridden value, and prepended or appended text. | + | |
+ | === ctrl/ | ||
+ | Contains the URLs to the icons used by the default 404.ssjs | ||
+ | script for each file type/ | ||
+ | Example: " | ||
+ | DIRECTORY which is used for directories and DefaultIcon which | ||
+ | is used for extensions which don't exist in the list. | ||
- | 2.3. webctrl.ini per-directory configuration file | + | === ctrl/ |
- | ------------------------------------------------ | + | |
- | Each directory may have a webctrl.ini file which overrides certain settings for | + | |
- | the directory it's in and all child directorys. | + | |
- | either globally, or in a per-filename group. | + | |
- | the group name such as [*.html]. | + | |
- | AccessRequirements: | + | This file contains 2 sections where a list of file |
- | Specifices an ARS string which all users must match to be able to access | + | extensions and their associated content-creation handlers |
- | files in this directory. | + | specified: |
- | Realm: | + | |
- | Sets the realm that is displayed to the user for the HTTP login. | + | |
- | Default is the BBS name. | + | |
- | DigestRealm: | + | |
- | Sets the realm that is displayed to the user for the HTTP login when | + | |
- | Digest authentication is being used. Default is the Realm value. | + | |
- | Authorization: | + | |
- | A comma-separated | + | |
- | preference. | + | |
- | browser currently appears to use Digest if Basic is listed first. | + | |
- | Supported values | + | |
- | users password is never sent over the wire. | + | |
- | ErrorDirectory: | + | |
- | Specifies a different directory to check for error pages. | + | |
- | page is not found, will still check the global error directory. | + | |
- | CGIDirectory: | + | |
- | Specify an alternate CGI directory to check for CGI files. | + | |
- | PathInfoIndex: | + | |
- | Specifies that the index files can be ran for unlocated pages in the | + | |
- | current directory. | + | |
- | For example, to require a login, but allow *any* user to access files in a | + | == [CGI] == |
- | directory, but only a sysop to access *.log files, the following could be used: | + | |
+ | The [CGI] section is for natively-executed CGI handlers | ||
+ | (e.g. "pl = perl" indicates " | ||
+ | |||
+ | == [JavaScript] == | ||
+ | |||
+ | The [JavaScript] section is used for JS-executed content | ||
+ | handlers (e.g. "xjs = xjs_handler.js" | ||
+ | |||
+ | === ctrl/ | ||
+ | Contains a list of system environment variables to pass to CGI | ||
+ | processes. | ||
+ | value, over-ridden value, and prepended or appended text. | ||
+ | |||
+ | |||
+ | ==== webctrl.ini per-directory configuration file ==== | ||
+ | Each directory under the [[# | ||
+ | the directory it's in and all child directories. | ||
+ | either globally, in a per-filename group, or, in version 3.17 or greater, a per-directory-name group. | ||
+ | Using the * and ? wildcards as the group name such as '' | ||
+ | |||
+ | === AccessRequirements === | ||
+ | Specifices an ARS string which all users must match to be able to access | ||
+ | files in this directory. | ||
+ | |||
+ | For example, to require a login, but allow **any** user to access files in a | ||
+ | directory, but only a sysop to access | ||
+ | <file webctrl.ini> | ||
AccessRequirements=level 0 | AccessRequirements=level 0 | ||
[*.log] | [*.log] | ||
- | AccessRequirements=level90 | + | AccessRequirements=level 90 |
+ | [*.git] | ||
+ | AccessRequirements=level 90 | ||
+ | </ | ||
+ | |||
+ | === Realm === | ||
+ | Sets the realm that is displayed to the user for the HTTP login. | ||
+ | Default is the BBS name. | ||
+ | |||
+ | === DigestRealm === | ||
+ | Sets the realm that is displayed to the user for the HTTP login when | ||
+ | Digest authentication is being used. Default is the [[#Realm]] value. | ||
+ | |||
+ | === Authorization === | ||
+ | A comma-separated list of authentication mechanisms in order of | ||
+ | preference. | ||
+ | browser currently appears to use Digest if Basic is listed first. | ||
+ | Supported values are '' | ||
+ | users password is never sent over the wire. | ||
+ | |||
+ | === ErrorDirectory === | ||
+ | Specifies a different directory to check for error pages. | ||
+ | page is not found, will still check the global error directory. | ||
+ | |||
+ | === CGIDirectory === | ||
+ | Specify an alternate CGI directory to check for CGI files. | ||
+ | |||
+ | === PathInfoIndex === | ||
+ | Specifies that the index files can be ran for unlocated pages in the | ||
+ | current directory. | ||
+ | |||
+ | === FastCGISocket === | ||
+ | Specifies the socket and port of a FastCGI listener in the < | ||
+ | <file webctrl.ini> | ||
+ | [*.php] | ||
+ | FastCGISocket=127.0.0.1: | ||
+ | </ | ||
+ | |||
+ | Added on November 1st, 2015 to CVS (in 3.17a). | ||
+ | |||
+ | See [[howto: | ||
+ | |||
+ | === Rewrite* === | ||
+ | Specifies a Javascript snippet which can modify the http_request.request_string. | ||
+ | |||
+ | Added on November 3rd, 2015 to CVS (in 3.17a). | ||
+ | |||
+ | === JSPreExec === | ||
+ | A JavaScript snippet which is executed in the same context as Rewrite* lines, but before any Rewrites are executed. | ||
+ | Added on November 3rd, 2015 to CVS (in 3.17a). | ||
- | 3.0 JavaScript | + | ===== JavaScript Objects |
- | --------------------------------- | + | |
In addition to the standard JavaScript objects, the web server provides the | In addition to the standard JavaScript objects, the web server provides the | ||
following: | following: | ||
+ | ==== http_request object ==== | ||
- | 3.1 http_request object | ||
- | ----------------------- | ||
The http_request object contains information from the client that was included | The http_request object contains information from the client that was included | ||
during this request. | during this request. | ||
- | path_info | + | === path_info |
- | | + | Contains extra path information that was included with the |
- | | + | request AFTER the URI which identified this script. |
- | | + | example, if the request was for |
- | | + | '' |
- | method | + | would contain the string "/ |
- | | + | |
- | | + | === method |
- | virtual_path | + | Contains the HTTP method used to run the script. |
- | | + | writing, the available methods are " |
- | | + | " |
- | query | + | |
- | | + | === virtual_path |
- | | + | The virtual path that this URI was reached by. This is the |
- | | + | portion of the URI from the end of the host to the end of the |
- | | + | filename. |
- | query_string | + | |
- | | + | === query === |
- | post_data | + | This object contains the values of any form data which was |
- | header | + | submitted with the request. |
- | cookie | + | name/value pairs. |
- | | + | for this is that it is legal and often useful |
- | | + | form fields with the same name. |
- | real_path | + | |
- | ars | + | === query_string |
- | request_string | + | If a query string was included, this is the raw, unparsed query |
- | host - The value of the host header for this request. | + | string. |
- | vhost | + | |
- | http_ver | + | === post_data |
- | remote_ip | + | As with query_string but for data which was POSTed. |
- | remote_host | + | |
- | | + | === header |
+ | An associative array of header name/value pairs. | ||
+ | |||
+ | === cookie | ||
+ | Much like the query object, this object contains key/value pairs | ||
+ | of set cookies. | ||
+ | multiple values for the same key can be set for cookies. | ||
+ | |||
+ | === real_path | ||
+ | The real OS' | ||
+ | |||
+ | === ars === | ||
+ | The ARS string which applies to this request. | ||
+ | |||
+ | === request_string | ||
+ | |||
+ | The raw request string sent by the client. | ||
+ | |||
+ | === host === | ||
+ | The value of the host header for this request. | ||
+ | === vhost === | ||
+ | The virtual host serving this request. | ||
+ | === http_ver | ||
+ | The HTTP version used for this request as a string. | ||
+ | |||
+ | === remote_ip | ||
+ | The IP address of the client. | ||
+ | |||
+ | === remote_host | ||
+ | |||
+ | If the web server does host lookups (disabled by default), this | ||
+ | is the remote hostname. | ||
+ | |||
+ | |||
+ | ==== http_reply object ==== | ||
- | 3.2 http_reply object | ||
- | --------------------- | ||
The http_reply object is used to pass information about the reply back to the | The http_reply object is used to pass information about the reply back to the | ||
Synchronet web server. | Synchronet web server. | ||
- | status | + | === status |
- | header | + | |
- | only pre-defined one is " | + | |
- | " | + | |
- | fast - This optional property can be set to " | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
+ | HTTP status string. | ||
- | 3.3 Extra global methods | + | === header === |
- | ------------------------ | + | An associative array of headers to include with the reply. The |
- | The web server also adds new global methods. These are: | + | only pre-defined one is " |
- | set_cookie(string key, | + | === fast === |
+ | This optional property can be set to " | ||
+ | directly to the client for HTTP/1.0 connections. | ||
+ | keep-alives from working but generally appears faster to the | ||
+ | client. | ||
+ | required for HTTP/1.1. | ||
+ | |||
+ | |||
+ | ==== Extra global methods ==== | ||
+ | |||
+ | The web server also adds a new global JavaScript method that requests that the specified cookie be set: | ||
+ | |||
+ | | ||
| | ||
[, time_t expires | [, time_t expires | ||
Line 299: | Line 395: | ||
[, string path | [, string path | ||
[, bool secure ]]]]) | [, bool secure ]]]]) | ||
- | | ||
- | 4.0 The SSJS Template System | + | ==== Extra global variables ==== |
- | ---------------------------- | + | |
+ | === web_root_dir === | ||
+ | The path to the web server' | ||
+ | |||
+ | See also: the RootDirectory key under [Web] in [[config: | ||
+ | |||
+ | |||
+ | ===== The SSJS Template System | ||
The default web pages use a SSJS Template engine which also allows for Theme | The default web pages use a SSJS Template engine which also allows for Theme | ||
support. | support. | ||
- | [Note: | + | [Note: |
- | nested.] | + | |
- | 4.1 The SSJS Template Scheme | + | ==== The SSJS Template Scheme |
- | ---------------------------- | + | |
Each page consists of four parts: | Each page consists of four parts: | ||
- | | + | === The Header |
- | This file contains the basic requirements for the HTML page. | + | |
- | The opening HTML, doctype, title, CSS file link, etc. The | + | |
- | header file includes the open body, System Name, and User | + | |
- | greeting plus the initial page layout table start. | + | |
- | of the layout is continued in the next files. | + | |
- | Top Navigation (../ | + | This file contains the basic requirements for the HTML page. |
- | ../ | + | The opening HTML, doctype, title, CSS file link, etc. The |
- | The topnav.inc | + | header file includes |
- | The links are dynamically generated by topnav_html.ssjs so both | + | greeting plus the initial page layout table start. The rest |
- | files need to be addressed when modifying or creating themes. | + | of the layout is continued |
- | In the case of the default layout, topnav.inc has a left and right | + | |
- | | + | |
- | | + | |
- | you like. | + | |
- | The topnav_html.ssjs file may seem daunting at first, but it is | + | |
- | pretty straight forward. | + | |
- | check the current page location and sets up the breadcrumbs based | + | |
- | on what you want it to say. | + | |
- | For example: | + | |
- | You want to add a Links page called links.html | + | |
- | directory. You would add a check for the path to links.html | + | |
- | as: | + | |
- | if(http_request.virtual_path=="/ | + | |
- | template.topnav.push({html: | + | |
- | Some Links</ | + | |
- | Left Side Navigation (../ | + | === Top Navigation |
- | ../ | + | |
- | This starts the main table layout in the default layout and also | + | |
- | provides two other things -- the main navigation links and a brief | + | |
- | nodelisting that displays when users are online via telnet. | + | |
- | The links are dynamically created as in the Top Navigation | + | |
- | above with the exception of the two static links. | + | |
- | Main Content (various files) | + | |
- | This is where the layout of the main content is created. | + | ../web/lib/topnav_html.ssjs |
- | to look at the various files in ../ | + | |
- | ../web/templates/default/ | + | |
- | various functions of the Web side of Synchronet. | + | |
- | each of the special codes contained in those files do will follow. | + | |
- | Footer (../ | + | The '' |
- | This file contains the closing HTML and whatever bottom information | + | The links are dynamically generated by '' |
- | you would like. In the case of the default layout, | + | files need to be addressed when modifying or creating themes. |
- | Web Server/ | + | In the case of the default layout, |
- | privacy statements or anything | + | graphic |
- | be displayed at the bottom of each page. | + | background image is handled by CSS. |
+ | you like. | ||
+ | The '' | ||
+ | pretty straight forward. | ||
+ | check the current page location and sets up the breadcrumbs based | ||
+ | on what you want it to say. | ||
+ | |||
+ | For example: | ||
+ | You want to add a Links page called links.html in the main | ||
+ | directory. | ||
+ | as: | ||
+ | |||
+ | <code javascript> | ||
+ | if(http_request.virtual_path=="/ | ||
+ | template.topnav.push({html: | ||
+ | </ | ||
+ | | ||
+ | === Left Side Navigation === | ||
+ | |||
+ | ../ | ||
+ | ../ | ||
+ | ../ | ||
+ | |||
+ | This starts the main table layout in the default layout and also | ||
+ | provides two other things -- the main navigation links and a brief | ||
+ | nodelisting that displays when users are online via telnet. | ||
+ | The links are dynamically created as in the Top Navigation example | ||
+ | above with the exception of the two static links. | ||
+ | |||
+ | === Main Content (various files) === | ||
+ | |||
+ | This is where the layout of the main content is created. | ||
+ | to look at the various files in '' | ||
+ | '' | ||
+ | various functions of the Web side of Synchronet. | ||
+ | each of the special codes contained in those files do will follow. | ||
+ | |||
+ | === Footer === | ||
+ | | ||
+ | ../ | ||
+ | | ||
+ | This file contains the closing HTML and whatever bottom information | ||
+ | you would like. In the case of the default layout, the | ||
+ | Web Server/ | ||
+ | privacy statements or anything else can be placed here and they will | ||
+ | be displayed at the bottom of each page. | ||
+ | |||
+ | |||
+ | ==== SSJS Theme Support ==== | ||
- | 4.2 SSJS Theme Support | ||
- | ---------------------- | ||
Theme Layouts can be added to Synchronet by creating them and placing the | Theme Layouts can be added to Synchronet by creating them and placing the | ||
*.inc files in their own directory under ../ | *.inc files in their own directory under ../ | ||
Line 373: | Line 491: | ||
Themes are activated by editing the ../ | Themes are activated by editing the ../ | ||
This file contains: | This file contains: | ||
+ | <code javascript> | ||
+ | /* Set default theme name */ | ||
+ | var DefaultTheme=" | ||
- | /* Set default theme name */ | + | /* Edit this bit to add/ |
- | var DefaultTheme=" | + | Themes[" |
- | + | Themes[" | |
- | | + | Themes[" |
- | Themes[" | + | Themes[" |
- | Themes[" | + | </ |
- | Themes[" | + | |
- | Themes[" | + | |
Themes are added by editing below the Default Theme such as: | Themes are added by editing below the Default Theme such as: | ||
- | + | <code javascript> | |
- | Themes[" | + | Themes[" |
- | Themes[" | + | Themes[" |
- | Themes[" | + | Themes[" |
- | Themes[" | + | Themes[" |
+ | </ | ||
To change the Default Theme, change: | To change the Default Theme, change: | ||
- | | + | <code javascript> |
+ | var DefaultTheme=" | ||
+ | </ | ||
to: | to: | ||
+ | <code javascript> | ||
+ | var DefaultTheme=" | ||
+ | </ | ||
- | var DefaultTheme=" | + | ==== Special Codes Used in the SSJS Template System ==== |
- | 4.3 Special Codes Used in the SSJS Template System | ||
- | -------------------------------------------------- | ||
By looking at at the message related files located in templates/ | By looking at at the message related files located in templates/ | ||
it can be seen that some special codes are used to display dynamically created | it can be seen that some special codes are used to display dynamically created | ||
Line 409: | Line 529: | ||
For example the groups.inc: | For example the groups.inc: | ||
+ | <code html> | ||
<!-- Main Content --> | <!-- Main Content --> | ||
| | ||
- | | + | <td class=" |
<table class=" | <table class=" | ||
Line 420: | Line 540: | ||
<< | << | ||
<tr> | <tr> | ||
- | | + | |
- | <a class=" | + | <a class=" |
- | %%groups: | + | %%groups: |
- | <td class=" | + | <td class=" |
- | @@JS: | + | @@JS: |
</tr> | </tr> | ||
<<END REPEAT groups>> | <<END REPEAT groups>> | ||
Line 431: | Line 551: | ||
<!-- end Main Content --> | <!-- end Main Content --> | ||
+ | </ | ||
While the table layout can be changed or even eliminated, the information | While the table layout can be changed or even eliminated, the information | ||
Line 436: | Line 557: | ||
To remove the table yet keep the correct infomation, the resulting groups.inc | To remove the table yet keep the correct infomation, the resulting groups.inc | ||
would be changed to (while maintaining the main table layout in this case) to: | would be changed to (while maintaining the main table layout in this case) to: | ||
+ | <code html> | ||
<!-- Main Content --> | <!-- Main Content --> | ||
| | ||
<td class=" | <td class=" | ||
- | << | + | |
<a class=" | <a class=" | ||
%%groups: | %%groups: | ||
@@JS: | @@JS: | ||
- | <<END REPEAT groups>> | + | |
- | <br /> | + | |
- | <!-- end Main Content --> | + | |
+ | </code> | ||
This principle applies to all the .inc files in msgs respectively. | This principle applies to all the .inc files in msgs respectively. | ||
+ | ==== The SSJS Template Library ==== | ||
- | 4.4 The SSJS Template Library | + | '' |
- | ------------------------------- | + | |
- | %%name%% is replaced with the HTML encoded value of template.name | + | i.e.; Spaces are replaced with: '' |
- | i.e.; Spaces are replaced with: this& | + | '' |
- | ^^name^^ is replaced with the URI encoded value of template.name | + | i.e.; Spaces are replaced with: |
- | + | ||
- | i.e.; Spaces are replaced with: this%20is%20URI | + | |
| | ||
- | @@name@@ is replaced with the value if template.name | + | '' |
No changes or encoding is performed. | No changes or encoding is performed. | ||
- | @@name: | + | '' |
(^^ and %% are also supported) | (^^ and %% are also supported) | ||
- | @@JS: | + | '' |
(^^ and %% are also supported) | (^^ and %% are also supported) | ||
+ | <code javascript> | ||
<< | << | ||
- | | + | |
<<END REPEAT name>> | <<END REPEAT name>> | ||
+ | </ | ||
- | Iterates over the array/ | + | Iterates over the array/ |
- | the value of template.name.sname. | + | the value of '' |
(^^ and %% are also supported) | (^^ and %% are also supported) | ||
- | 4.5 SSJS Message Configuration | + | ==== SSJS Message Configuration |
- | ------------------------------ | + | |
- | Configuration settings for the SSJS Messaging system is located in the | + | |
- | ../ | + | |
+ | Configuration settings for the SSJS Messaging system is located in the | ||
+ | '' | ||
+ | <code javascript> | ||
max_messages=20; | max_messages=20; | ||
max_pages=30; | max_pages=30; | ||
Line 502: | Line 624: | ||
show_messages_spacer_html="& | show_messages_spacer_html="& | ||
anon_only_message=" | anon_only_message=" | ||
- | anon_allowed_message='< | + | anon_allowed_message='< |
- | Post message anonymously'; | + | anon_reply_message='< |
- | anon_reply_message='< | + | |
- | Post message anonymously'; | + | |
private_only_message=" | private_only_message=" | ||
- | private_allowed_message='< | + | private_allowed_message='< |
- | Mark message as private'; | + | private_reply_message='< |
- | private_reply_message='< | + | </ |
- | Mark message as private'; | + | |
- | Each of these are configurable. NOTE: Lines ending in " | + | Each of these are configurable. |
- | below is part of the line above. | + | |
- | it too be removed. | + | |
See the actual file for the defaults currently in use. | See the actual file for the defaults currently in use. | ||
- | 4.6 Embedded Javascript | + | ==== Embedded Javascript |
- | ----------------------- | + | |
- | The *.inc files can (and do in the default layout) have embedded JavaScript | + | The '' |
which is parsed by the JavaScript engine. | which is parsed by the JavaScript engine. | ||
number of embedded JavaScript in the *.inc files slow down overall processing | number of embedded JavaScript in the *.inc files slow down overall processing | ||
of pages. | of pages. | ||
- | Anything contained within @@JS: @@ is processed by the Server-side JavaScript | + | Anything contained within |
engine. | engine. | ||
For example, it can check if the user is Guest or an actual user with this line: | For example, it can check if the user is Guest or an actual user with this line: | ||
- | @@JS: | + | <code javascript> |
- | '< | + | @@JS: |
+ | else '< | ||
+ | </ | ||
| | ||
What this does is display links specific for Registered Users only to them | What this does is display links specific for Registered Users only to them | ||
- | and not Guest. | + | and not Guest. |
Note, it also can be used to display HTML based on location as in the | Note, it also can be used to display HTML based on location as in the | ||
node listing stuff. In this case, it checks for whether or not a user is | node listing stuff. In this case, it checks for whether or not a user is | ||
Line 541: | Line 659: | ||
the Left side node listing. | the Left side node listing. | ||
- | IMPORTANT! | + | IMPORTANT! |
will be errors in parsing. | will be errors in parsing. | ||
- | + | ==== global_defs.ssjs | |
- | 4.7 global_defs.ssjs | + | |
- | -------------------- | + | |
This version of the Web Layout now includes a new file called | This version of the Web Layout now includes a new file called | ||
- | global_defs.ssjs. | + | '' |
be used for creating global definitions that span all pages of a site. | be used for creating global definitions that span all pages of a site. | ||
For example: | For example: | ||
+ | <code javascript> | ||
template.user_alias=user.alias; | template.user_alias=user.alias; | ||
+ | </ | ||
- | Now @@user_alias@@ can be in any *.inc template files and it will display the | + | Now '' |
user's alias. | user's alias. | ||
- | Care should be excersied | + | Care should be exercised |
of predefined definitions may slow down overall page rendering as the file is | of predefined definitions may slow down overall page rendering as the file is | ||
loaded on every page. It would be better to just put a few popular | loaded on every page. It would be better to just put a few popular | ||
Line 566: | Line 684: | ||
- | 5.0 XJS files | + | ===== XJS files ===== |
- | ------------- | + | |
- | XJS files, handled by exec/ | + | XJS files, handled by '' |
an easier method of generating SSJS files. | an easier method of generating SSJS files. | ||
commands embedded in them using special tags much like PHP. XJS files are | commands embedded in them using special tags much like PHP. XJS files are | ||
- | translated on-the-fly to .ssjs files using the same name with .ssjs appended. | + | translated on-the-fly to .ssjs files using the same name with '' |
- | For example, a file named test.xjs will, when ran, generate a test.xjs.ssjs | + | For example, a file named test.xjs will, when ran, generate a '' |
file. | file. | ||
- | 5.1 XJS syntax | + | ==== XJS syntax |
- | -------------- | + | |
In an XJS file, everything not within a special xjs tag is send to the remote | In an XJS file, everything not within a special xjs tag is send to the remote | ||
host unmodified, and everything inside the xjs tag is interpreted as JS | host unmodified, and everything inside the xjs tag is interpreted as JS | ||
Line 583: | Line 701: | ||
either "<? | either "<? | ||
+ | <code html> | ||
< | < | ||
< | < | ||
Line 589: | Line 708: | ||
</ | </ | ||
</ | </ | ||
+ | </ | ||
This would send the following web page to the remote system: | This would send the following web page to the remote system: | ||
+ | <code html> | ||
< | < | ||
< | < | ||
Line 597: | Line 718: | ||
</ | </ | ||
</ | </ | ||
+ | </ | ||
Looping constructs are permitted, however, not using brackets can result in | Looping constructs are permitted, however, not using brackets can result in | ||
Line 603: | Line 725: | ||
The following example displays the numbers from one to 10. | The following example displays the numbers from one to 10. | ||
+ | <code html> | ||
< | < | ||
< | < | ||
Line 613: | Line 736: | ||
</ | </ | ||
</ | </ | ||
+ | </ | ||
+ | |||
+ | ==== XJS-specific global methods and properties ==== | ||
+ | |||
+ | The following JavaScript methods and properties are available to XJS files only. | ||
+ | === xjs_load(filename) === | ||
+ | Runs the specified xjs file at the current position. | ||
+ | are NOT visible to '' | ||
+ | relative to the including file (or absolute.) | ||
- | 5.2 XJS-specific global methods and properties | + | === cwd === |
- | ---------------------------------------------- | + | Contains the path that the current xjs script was loaded from and which |
- | The following JS commands are available to XJS files only. | + | parameters to '' |
- | xjs_load(filename) | + | the value of '' |
- | Runs the specified xjs file at the current position. | + | check for files. |
- | are NOT visible to xjs_load()ed pages. | + | |
- | relative to the including file (or absolute.) | + | |
- | cwd | + | |
- | Contains the path that the current xjs script was loaded from and which | + | |
- | parameters to xjs_load() are assumed to be relative to. If you change | + | |
- | the value of cwd, it will change the location where xjs_load() will | + | |
- | check for files. | + | |
+ | {{indexmenu_n> | ||