Skip to content

Commit 690e7cd

Browse files
NS GET parameter can set default namespace, index.csp file extension in lowercase fix
1 parent 6963657 commit 690e7cd

File tree

7 files changed

+34
-8
lines changed

7 files changed

+34
-8
lines changed

CONTRIBUTING.md renamed to DEVELOPMENT.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ Contributing
1616
2. If there is no errors, then run <code>grunt export</code> task;
1717
3. Find build/CWTWebSource.xml file and import it to the studio.
1818
3. By making changes in studio files (*.cls, *.mac) just copy source code into appropriate files in repository.
19-
4. If you commented line as the first step says, DO NOT FORGET to uncomment it.
19+
4. If you commented line as the first step says, DO NOT FORGET to uncomment it.
20+
21+
## Applications Integration
22+
If you want to integrate WebTerminal with your application, follow the next tips & tricks:
23+
* An <code>NS</code> parameter of GET request can set default namespace. For example, URL <code>../WebTerminal/index.csp?NS=USER</code> will open terminal in USER namespace.
24+
* In order to use IFrame to insert terminal on page, you may need to add <code>sandbox="allow-same-origin allow-scripts"</code> attribute to IFrame tag to enable storage and scripts which are required.
25+
* To get latest version of terminal, you can parse [latestVersion](http://intersystems-ru.github.io/webterminal/latestVersion) file which is always available on WEB and then request XML to import from <code>http://intersystems-ru.github.io/webterminal/files/WebTerminal-<b>{FILE PART}</b>.xml</code>.

Gruntfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ module.exports = function(grunt) {
1111
FAVICON_ICO: fs.readFileSync("build/webSource/favicon.ico").toString("base64"),
1212
INDEX_CSP: fs.readFileSync("build/webSource/index.html").toString("utf-8")
1313
.replace("é", "&eacute;")
14-
.replace("createTerminal(", "createTerminal('#(%session.CSPSessionCookie)#'"),
14+
.replace("createTerminal(", "createTerminal('#(%session.CSPSessionCookie)#'," +
15+
"'#(%request.Get(\"NS\"))#'"),
1516
TERMINAL_JS: fs.readFileSync("build/webSource/js/terminal.js").toString("utf-8")
1617
.replace(/[\x1B]/g, function(s) { return "\\x" + s.charCodeAt(0).toString(16) })
1718
};

classes/%WebTerminal.Engine.cls

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,13 @@ Method RequireAuthorization() As %Status
796796
set authKey = ..Read(, .status, ..#authorizationTimeout) // wait for package
797797
set ok = $$$NOTOK
798798

799+
set namespace = ""
800+
set pos = $FIND(authKey, "#")
801+
if pos '= 0 {
802+
set namespace = $EXTRACT(authKey, pos, *)
803+
set authKey = $EXTRACT(authKey, 1, pos-2)
804+
}
805+
799806
/*
800807
* Find given CSPSessionCookie in session list. If found, grant access.
801808
*/
@@ -817,6 +824,12 @@ Method RequireAuthorization() As %Status
817824
do ..SendData("!", ..ConstClientLoginInfo)
818825
}
819826

827+
if (namespace '= "") {
828+
try {
829+
zn namespace
830+
} catch (e) { }
831+
}
832+
820833
set ok = loginStatus
821834
QUIT
822835

export/exportTemplate.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</CSPBase64>
1818

1919

20-
<CSP name="index.CSP" application="/csp/sys/webterminal/"><![CDATA[
20+
<CSP name="index.csp" application="/csp/sys/webterminal/"><![CDATA[
2121
<!-- @echo INDEX_CSP -->]]></CSP>
2222

2323

webSource/js/CacheWebTerminalServer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ CacheWebTerminalServer.prototype.send = function (string) {
135135
*/
136136
CacheWebTerminalServer.prototype.onConnect = function () {
137137

138-
var key;
138+
var key, ns;
139139

140140
this.CONTROLLER.TERMINAL.output.print(this._lc.get(2) + "\r\n");
141141
if (key = this.CONTROLLER.TERMINAL.SETUP["authKey"]) {
142-
this.send(key);
142+
this.send(key + ((ns = this.CONTROLLER.TERMINAL.SETUP.defaultNamespace) ? "#" + ns : ""));
143143
}
144144

145145
};

webSource/js/Globals.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,16 @@ var AJAX = new function() {
6565
* Initialization function. Exported after build.
6666
*
6767
* @param {string} authKey
68+
* @param {string} namespace
6869
*/
69-
this.createTerminal = function (authKey) {
70+
this.createTerminal = function (authKey, namespace) {
71+
72+
console.log(namespace);
7073

7174
return new Terminal({
7275
container: document.body,
73-
authKey: authKey || null
76+
authKey: authKey || null,
77+
defaultNamespace: namespace
7478
});
7579

7680
};

webSource/js/Terminal.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
*
4040
* @param setting {{
4141
* controller: TerminalController,
42-
* [container]: HTMLElement
42+
* [container]: HTMLElement,
43+
* defaultNamespace: string
4344
* }}
4445
*/
4546
var Terminal = function (setting) {
@@ -92,6 +93,7 @@ var Terminal = function (setting) {
9293
this.autocomplete = new TerminalAutocomplete();
9394

9495
this.SETUP = {
96+
defaultNamespace: setting["defaultNamespace"] || "",
9597
controller: setting["controller"] || new TerminalController(this),
9698
container: setting["container"] || document.body,
9799
authKey: setting["authKey"] || null

0 commit comments

Comments
 (0)