Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
server:web [2010/02/21 20:56] – digitalman | server:web [2023/12/23 02:14] (current) – [Configure] Update SCFG screenshot digital man | ||
---|---|---|---|
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 5: | Line 7: | ||
The Synchronet Web Server is a mostly HTTP 1.1 compliant web server capable of | The Synchronet Web Server is a mostly HTTP 1.1 compliant web server capable of | ||
handing basic web servicing tasks. | handing basic web servicing tasks. | ||
- | general-purpose web server one would come to expect | + | general-purpose web server one would come to expect, including |
It also, through Server-Side JavaScript (SSJS), allows dynamic pages to be | It also, through Server-Side JavaScript (SSJS), allows dynamic pages to be | ||
Line 11: | Line 13: | ||
- | ===== Web Server Configuration | + | ===== Configure |
- | ==== Startup INI [Web] Section Keys ==== | + | The Synchronet |
- | The '' | + | <file> |
+ | ╔══════════════════════════════════════════════════════════════════╗ | ||
+ | ║ Web Server | ||
+ | ╠══════════════════════════════════════════════════════════════════╣ | ||
+ | ║ │Enabled | ||
+ | ║ │Log Level | ||
+ | ║ │HTTP Interfaces | ||
+ | ║ │HTTP Port | ||
+ | ║ │HTTPS Support | ||
+ | ║ │HTTPS Interfaces | ||
+ | ║ │HTTPS Port 443 ║ | ||
+ | ║ │SSJS File Extension | ||
+ | ║ │Index Filenames | ||
+ | ║ │Content Root Directory | ||
+ | ║ │Error Sub-directory | ||
+ | ║ │Strict Transport Security | ||
+ | ║ │Virtual Host Support | ||
+ | ║ │Access Logging | ||
+ | ║ │Max Clients | ||
+ | ║ │Max Inactivity | ||
+ | ║ │Filebase Index Script | ||
+ | ║ │Filebase VPath Prefix | ||
+ | ║ │Filebase VPath for VHosts | ||
+ | ║ │Authentication Methods | ||
+ | ║ │Output Buffer Drain Timeout | ||
+ | ║ │Lookup Client Hostname | ||
+ | ║ │CGI Support | ||
+ | ║ │CGI Directory | ||
+ | ║ │CGI File Extensions | ||
+ | ║ │CGI Default Content-Type | ||
+ | ║ │CGI Max Inactivity | ||
+ | ║ │JavaScript Settings... | ||
+ | ║ │Failed Login Attempts... | ||
+ | ╚══════════════════════════════════════════════════════════════════╝ | ||
+ | </ | ||
+ | |||
+ | ... or via [[monitor: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ... or via manual edit of the '' | ||
+ | |||
+ | ==== sbbs.ini ==== | ||
+ | |||
+ | The '' | ||
+ | |||
+ | ^ Key ^ Default | ||
+ | | AutoStart | ||
+ | | HostName | ||
+ | | LogLevel | ||
+ | | TLSErrorLevel | ||
+ | | Interface | ||
+ | | TLSInterface | ||
+ | | Port | '' | ||
+ | | TLSPort | ||
+ | | BindRetryCount | ||
+ | | BindRetryDelay | ||
+ | | MaxClients | ||
+ | | MaxInactivity | ||
+ | | MaxCgiInactivity | ||
+ | | SemFileCheckFrequency | ||
+ | | IndexFileNames | ||
+ | | RootDirectory | ||
+ | | ErrorDirectory | ||
+ | | CGIDirectory | ||
+ | | DefaultCGIContent | ||
+ | | CGIExtensions | ||
+ | | JavaScriptExtension | ||
+ | | Authentication | ||
+ | | HttpLogFile | ||
+ | | FileIndexScript | ||
+ | | FileVPathPrefix | ||
+ | | FileVPathForVHosts | ||
+ | | OutbufDrainTimeout | ||
+ | | TempDirectory | ||
+ | | Options | ||
+ | |||
+ | === Options === | ||
+ | |||
+ | The '' | ||
+ | |||
+ | Default value: **'' | ||
+ | |||
+ | In addition to the [[config: | ||
+ | |||
+ | == DEBUG_RX == | ||
+ | |||
+ | Log all received data to the console log, as well as various | ||
+ | extra bits related to receiving data. | ||
+ | |||
+ | == DEBUG_TX == | ||
+ | |||
+ | Log all transmitted data except the reply body itself, as well | ||
+ | as various extra bits of information related to transmitted | ||
+ | data. | ||
+ | |||
+ | == DEBUG_SSJS == | ||
+ | |||
+ | Log server-side JavaScript execution details. | ||
+ | |||
+ | == 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 | ||
+ | '' | ||
+ | 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=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | == NO_CGI == | ||
+ | |||
+ | Disable CGI/FastCGI 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. | ||
+ | |||
+ | == ALLOW_TLS == | ||
+ | |||
+ | Enable TLS/SSL support. | ||
+ | |||
+ | == HSTS_SAFE == | ||
+ | |||
+ | Indicates that all URLs available via http are also available via https and redirects clients who want a TLS session to the https location. | ||
+ | |||
+ | ==== Reference ==== | ||
+ | |||
+ | Web Server configuration settings reference: | ||
+ | |||
=== RootDirectory === | === RootDirectory === | ||
Line 24: | Line 184: | ||
'' | '' | ||
- | ::!:: 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 47: | Line 207: | ||
=== 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 107: | Line 267: | ||
(if enabled, see next item), date, and '' | (if enabled, see next item), date, and '' | ||
- | === Options | + | === FileVPathPrefix |
+ | Default value: "" | ||
- | Default | + | Suggested |
- | The | separated list of options | + | A virtual sub-directory |
- | options, the web server also supports the following: | + | |
- | '' | + | === FileVPathForVHosts === |
- | Log all received data to the console log, as well as various | + | Default value: |
- | extra bits related to receiving data. | + | |
- | '' | + | By default, virtual hosts will not have the virtual file path (if enabled). Set this to '' |
- | Log all transmitted data except | + | |
- | as various extra bits of information related to transmitted | + | |
- | data. | + | |
- | '' | + | === FileIndexScript === |
- | Supports name-based virtual hosts. | + | Default value: "" |
- | 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 | + | Suggested value: '' |
- | 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=" | + | |
- | </ | + | |
- | </ | + | |
- | + | ||
- | '' | + | |
- | 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. | + | |
+ | A Server-side JavaScript (SSJS) file to execute and provide HTML/CSS indexes to file libraries and directories accessed via virtual file paths. | ||
==== Other configuration files ==== | ==== Other configuration files ==== | ||
- | In addition to the [Web] keys in the [[Startup INI]] file, the web server | + | In addition to the '' |
also uses some other configuration files: | also uses some other configuration files: | ||
Line 189: | Line 309: | ||
specified: | specified: | ||
- | == CGI == | + | == [CGI] == |
The [CGI] section is for natively-executed CGI handlers | The [CGI] section is for natively-executed CGI handlers | ||
- | (e.g. "pl = perl" indicates " | + | (e.g. "pl = perl" indicates " |
- | files). | + | |
- | == JavaScript == | + | == [JavaScript] == |
The [JavaScript] section is used for JS-executed content | The [JavaScript] section is used for JS-executed content | ||
Line 206: | Line 325: | ||
- | ==== webctrl.ini | + | ==== webctrl.ini ==== |
Each directory under the [[# | Each directory under the [[# | ||
the directory it's in and all child directories. | the directory it's in and all child directories. | ||
- | either globally, | + | either globally, in a per-filename group, or, in version 3.17 or greater, a per-directory-name group. |
- | the group name such as '' | + | Using the * and ? wildcards as the group name such as '' |
=== AccessRequirements === | === AccessRequirements === | ||
- | Specifices | + | Specifies |
files in this directory. | 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 | ||
+ | [*.log] | ||
+ | AccessRequirements=level 90 | ||
+ | [*.git] | ||
+ | AccessRequirements=level 90 | ||
+ | </ | ||
=== Realm === | === Realm === | ||
Line 242: | Line 372: | ||
current directory. | current directory. | ||
- | For example, to require a login, but allow **any** user to access files in a | + | === FastCGISocket === |
- | directory, but only a sysop to access | + | Specifies the socket address of a FastCGI listener in either < |
- | | + | <file webctrl.ini> |
- | [*.log] | + | [*.php] |
- | | + | FastCGISocket=127.0.0.1:9000 |
+ | </ | ||
+ | |||
+ | See [[howto: | ||
+ | |||
+ | === Rewrite* === | ||
+ | Specifies a Javascript snippet which can modify the http_request.request_string. | ||
+ | |||
+ | <file webctrl.ini> | ||
+ | RewriteDetail=var n=http_request.request_string.replace(/ | ||
+ | </ | ||
+ | |||
+ | If the expression returns " | ||
+ | an internal redirect. | ||
+ | |||
+ | Added on November 3rd, 2015 to CVS (in 3.17a). ([[https:// | ||
+ | |||
+ | === 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). | ||
- | ==== 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 === | + | ==== 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 | Contains extra path information that was included with the | ||
request AFTER the URI which identified this script. | request AFTER the URI which identified this script. | ||
Line 265: | Line 414: | ||
would contain the string "/ | would contain the string "/ | ||
- | == method == | + | === method |
Contains the HTTP method used to run the script. | Contains the HTTP method used to run the script. | ||
writing, the available methods are " | writing, the available methods are " | ||
" | " | ||
- | == virtual_path == | + | === virtual_path |
The virtual path that this URI was reached by. This is the | 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 | portion of the URI from the end of the host to the end of the | ||
filename. | filename. | ||
- | == query == | + | === query === |
This object contains the values of any form data which was | This object contains the values of any form data which was | ||
submitted with the request. | submitted with the request. | ||
Line 282: | Line 431: | ||
form fields with the same name. | form fields with the same name. | ||
- | == query_string == | + | === query_string |
If a query string was included, this is the raw, unparsed query | If a query string was included, this is the raw, unparsed query | ||
string. | string. | ||
- | == post_data == | + | === post_data |
As with query_string but for data which was POSTed. | As with query_string but for data which was POSTed. | ||
- | == header == | + | === header |
An associative array of header name/value pairs. | An associative array of header name/value pairs. | ||
- | == cookie == | + | === cookie |
Much like the query object, this object contains key/value pairs | Much like the query object, this object contains key/value pairs | ||
of set cookies. | of set cookies. | ||
multiple values for the same key can be set for cookies. | multiple values for the same key can be set for cookies. | ||
- | == real_path == | + | === real_path |
- | The real OSs complete path to this script. | + | The real OS' |
- | == ars == | + | === ars === |
The ARS string which applies to this request. | The ARS string which applies to this request. | ||
- | == request_string == | + | === request_string |
The raw request string sent by the client. | The raw request string sent by the client. | ||
- | == host == | + | === host === |
The value of the host header for this request. | The value of the host header for this request. | ||
- | == vhost == | + | === vhost === |
The virtual host serving this request. | The virtual host serving this request. | ||
- | == http_ver == | + | === http_ver |
The HTTP version used for this request as a string. | The HTTP version used for this request as a string. | ||
- | == remote_ip == | + | === remote_ip |
The IP address of the client. | The IP address of the client. | ||
- | == remote_host == | + | === remote_host |
If the web server does host lookups (disabled by default), this | If the web server does host lookups (disabled by default), this | ||
is the remote hostname. | is the remote hostname. | ||
+ | === scheme === | ||
- | === http_reply object === | + | " |
+ | ==== http_reply object | ||
Line 331: | Line 480: | ||
Synchronet web server. | Synchronet web server. | ||
- | == status == | + | === status |
HTTP status string. | HTTP status string. | ||
- | == header == | + | === header |
An associative array of headers to include with the reply. | An associative array of headers to include with the reply. | ||
only pre-defined one is " | only pre-defined one is " | ||
- | == fast == | + | === fast === |
This optional property can be set to " | This optional property can be set to " | ||
directly to the client for HTTP/1.0 connections. | directly to the client for HTTP/1.0 connections. | ||
Line 347: | Line 496: | ||
- | === Extra global methods === | + | ==== Extra global methods |
- | The web server also adds new global JavaScript | + | The web server also adds a new global JavaScript |
set_cookie(string key, | set_cookie(string key, | ||
Line 357: | Line 506: | ||
[, string path | [, string path | ||
[, bool secure ]]]]) | [, bool secure ]]]]) | ||
- | | ||
- | ==== The SSJS Template System | + | ==== Extra global variables |
- | The default web pages use a SSJS Template engine which also allows for Theme | + | |
- | support. | + | |
- | [Note: | + | === web_root_dir === |
- | nested.] | + | The path to the web server' |
+ | See also: the RootDirectory key under [Web] in [[config: | ||
- | === The SSJS Template Scheme | + | ===== XJS files ===== |
- | Each page consists of four parts: | + | XJS files, handled by '' |
- | + | ||
- | == 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 == | + | |
- | + | ||
- | ../ | + | |
- | + | ||
- | The topnav.inc file contains the basic design of the " | + | |
- | The links are dynamically generated by topnav_html.ssjs so both | + | |
- | files need to be addressed when modifying or creating themes. | + | |
- | In the case of the default layout, topnav.inc has a left and right | + | |
- | graphic and a middle section that the dynamic content goes. The | + | |
- | background image is handled by CSS. You can change this to anything | + | |
- | 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 in the main | + | |
- | directory. | + | |
- | as: | + | |
- | if(http_request.virtual_path=="/ | + | |
- | template.topnav.push({html: | + | |
- | Some Links</ | + | |
- | + | ||
- | == 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 === | + | |
- | + | ||
- | + | ||
- | Theme Layouts can be added to Synchronet by creating them and placing the | + | |
- | *.inc files in their own directory under ../ | + | |
- | + | ||
- | Themes are activated by editing the ../ | + | |
- | This file contains: | + | |
- | + | ||
- | /* Set default theme name */ | + | |
- | var DefaultTheme=" | + | |
- | + | ||
- | /* Edit this bit to add/ | + | |
- | Themes[" | + | |
- | Themes[" | + | |
- | Themes[" | + | |
- | Themes[" | + | |
- | + | ||
- | Themes are added by editing below the Default Theme such as: | + | |
- | + | ||
- | Themes[" | + | |
- | Themes[" | + | |
- | Themes[" | + | |
- | Themes[" | + | |
- | + | ||
- | To change the Default Theme, change: | + | |
- | + | ||
- | var DefaultTheme=" | + | |
- | + | ||
- | to: | + | |
- | + | ||
- | var DefaultTheme=" | + | |
- | + | ||
- | + | ||
- | 4.3 Special Codes Used in the SSJS Template System | + | |
- | -------------------------------------------------- | + | |
- | 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 | + | |
- | content. It is very important to maintain the information EXACTLY as seen in | + | |
- | each file or else the messaging system will fail. While how it is displayed | + | |
- | can be changed, the correct information will only be dispayed by following the | + | |
- | format in the *.inc files. | + | |
- | + | ||
- | For example the groups.inc: | + | |
- | + | ||
- | <!-- Main Content --> | + | |
- | + | ||
- | <td class=" | + | |
- | + | ||
- | <table class=" | + | |
- | < | + | |
- | <th class=" | + | |
- | </ | + | |
- | << | + | |
- | < | + | |
- | <td class=" | + | |
- | <a class=" | + | |
- | %%groups: | + | |
- | <td class=" | + | |
- | @@JS: | + | |
- | </ | + | |
- | <<END REPEAT groups>> | + | |
- | </ | + | |
- | <br /> | + | |
- | + | ||
- | <!-- end Main Content --> | + | |
- | + | ||
- | While the table layout can be changed or even eliminated, the information | + | |
- | within the << | + | |
- | 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: | + | |
- | + | ||
- | <!-- Main Content --> | + | |
- | + | ||
- | <td class=" | + | |
- | + | ||
- | << | + | |
- | <a class=" | + | |
- | %%groups: | + | |
- | @@JS: | + | |
- | <<END REPEAT groups>> | + | |
- | + | ||
- | <br /> | + | |
- | + | ||
- | <!-- end Main Content --> | + | |
- | + | ||
- | This principle applies to all the .inc files in msgs respectively. | + | |
- | + | ||
- | + | ||
- | 4.4 The SSJS Template Library | + | |
- | ------------------------------- | + | |
- | + | ||
- | %%name%% is replaced with the HTML encoded value of template.name | + | |
- | + | ||
- | i.e.; Spaces are replaced with: this& | + | |
- | + | ||
- | ^^name^^ is replaced with the URI encoded value of template.name | + | |
- | + | ||
- | i.e.; Spaces are replaced with: this%20is%20URI | + | |
- | + | ||
- | @@name@@ is replaced with the value if template.name | + | |
- | + | ||
- | No changes or encoding is performed. | + | |
- | + | ||
- | @@name: | + | |
- | (^^ and %% are also supported) | + | |
- | + | ||
- | @@JS: | + | |
- | (^^ and %% are also supported) | + | |
- | + | ||
- | << | + | |
- | @@name: | + | |
- | <<END REPEAT name>> | + | |
- | + | ||
- | Iterates over the array/ | + | |
- | the value of template.name.sname. | + | |
- | (^^ and %% are also supported) | + | |
- | + | ||
- | + | ||
- | 4.5 SSJS Message Configuration | + | |
- | ------------------------------ | + | |
- | Configuration settings for the SSJS Messaging system is located in the | + | |
- | ../ | + | |
- | + | ||
- | max_messages=20; | + | |
- | max_pages=30; | + | |
- | next_msg_html=" | + | |
- | prev_msg_html=" | + | |
- | next_page_html=" | + | |
- | prev_page_html=" | + | |
- | showall_subs_enable_html=" | + | |
- | showall_subs_disable_html=" | + | |
- | show_messages_all_html=" | + | |
- | show_messages_yours_html=" | + | |
- | show_messages_your_unread_html=" | + | |
- | show_messages_spacer_html="& | + | |
- | anon_only_message=" | + | |
- | anon_allowed_message='< | + | |
- | Post message anonymously'; | + | |
- | anon_reply_message='< | + | |
- | Post message anonymously'; | + | |
- | private_only_message=" | + | |
- | private_allowed_message='< | + | |
- | Mark message as private'; | + | |
- | private_reply_message='< | + | |
- | Mark message as private'; | + | |
- | + | ||
- | 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. | + | |
- | + | ||
- | 4.6 Embedded Javascript | + | |
- | ----------------------- | + | |
- | + | ||
- | The *.inc files can (and do in the default layout) have embedded JavaScript | + | |
- | which is parsed by the JavaScript engine. | + | |
- | number of embedded JavaScript in the *.inc files slow down overall processing | + | |
- | of pages. | + | |
- | + | ||
- | Anything contained within @@JS: @@ is processed by the Server-side JavaScript | + | |
- | engine. | + | |
- | + | ||
- | For example, it can check if the user is Guest or an actual user with this line: | + | |
- | + | ||
- | @@JS: | + | |
- | '< | + | |
- | + | ||
- | What this does is display links specific for Registered Users only to them | + | |
- | and not Guest. | + | |
- | 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 | + | |
- | online, or if the user is anywhere but the Who's Online page before displaying | + | |
- | the Left side node listing. | + | |
- | + | ||
- | IMPORTANT! | + | |
- | will be errors in parsing. | + | |
- | + | ||
- | + | ||
- | 4.7 global_defs.ssjs | + | |
- | -------------------- | + | |
- | + | ||
- | 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. | + | |
- | For example: | + | |
- | + | ||
- | template.user_alias=user.alias; | + | |
- | + | ||
- | Now @@user_alias@@ can be in any *.inc template files and it will display the | + | |
- | user's alias. | + | |
- | + | ||
- | Care should be excersied when using this file as loading it up with hundreds | + | |
- | 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 | + | |
- | definitions that are truly global rather many definitions. | + | |
- | inefficient to have thirty of forty message definitions being loaded when a | + | |
- | user is looking at the statistics page. | + | |
- | + | ||
- | + | ||
- | 5.0 XJS files | + | |
- | ------------- | + | |
- | XJS files, handled by exec/ | + | |
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 654: | Line 532: | ||
either "<? | either "<? | ||
+ | <code html> | ||
< | < | ||
< | < | ||
Line 660: | Line 539: | ||
</ | </ | ||
</ | </ | ||
+ | </ | ||
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 668: | Line 549: | ||
</ | </ | ||
</ | </ | ||
+ | </ | ||
Looping constructs are permitted, however, not using brackets can result in | Looping constructs are permitted, however, not using brackets can result in | ||
Line 674: | Line 556: | ||
The following example displays the numbers from one to 10. | The following example displays the numbers from one to 10. | ||
+ | <code html> | ||
< | < | ||
< | < | ||
Line 684: | Line 567: | ||
</ | </ | ||
</ | </ | ||
+ | </ | ||
+ | |||
+ | ==== 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> | ||