From db954cd4b4d0690432f4fd0e9650c7d37154c95d Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Tue, 21 Apr 2015 20:53:40 -0700 Subject: [PATCH] Cleanup some uses of touchdevelop.com in literals; use Cloud.config where appropriate --- ast/apps.ts | 2 +- ast/help.ts | 6 +++--- libnode/runtime.ts | 5 +++++ noderunner/nrunner.ts | 19 ++++++++++++++++--- rt/cloud.ts | 1 + 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/ast/apps.ts b/ast/apps.ts index a20902db..832971e4 100644 --- a/ast/apps.ts +++ b/ast/apps.ts @@ -326,7 +326,7 @@ module TDev.AST.Apps { // these 2 files are not stored in cdn, they are rewritten in the cloud [ "error", "browsers"].forEach(n => instructions.files.push({ path: options.filePrefix + n + ".html", - url: "https://www.touchdevelop.com/app/." + n + "?releaseid=" + options.relId + url: Cloud.getServiceUrl() + "/app/." + n + "?releaseid=" + options.relId })) instructions.meta.isCloud = app.isCloud; diff --git a/ast/help.ts b/ast/help.ts index 0332f8de..6d0a3581 100644 --- a/ast/help.ts +++ b/ast/help.ts @@ -356,12 +356,12 @@ module TDev { public topicLink(id:string) { - return (this.useExternalLinks ? "https://www.touchdevelop.com/docs/" : "#topic:") + MdComments.shrink(id); + return (this.useExternalLinks ? Cloud.getServiceUrl() + "/docs/" : "#topic:") + MdComments.shrink(id); } public appLink(id:string) { - return (this.useExternalLinks ? "https://www.touchdevelop.com/app/" : "") + id + return (this.useExternalLinks ? Cloud.getServiceUrl() + "/app/" : "") + id } static shrink(s:string) @@ -876,7 +876,7 @@ module TDev { false)) continue; - var tdev = "https://www.touchdevelop.com/"; + var tdev = Cloud.getServiceUrl() + "/"; if (allowRepl && ( applySpan(/^\{\#(\w+)\}/g, (m) => "") || applySpan(/^\[([^\[\]]*)\]\s*\(([^ \(\)\s]+)\)/, (m) => { diff --git a/libnode/runtime.ts b/libnode/runtime.ts index 1bc936a2..aeb6a2b3 100644 --- a/libnode/runtime.ts +++ b/libnode/runtime.ts @@ -678,6 +678,11 @@ module TDev.RT.Node { window.navigator = navigator; navigator.userAgent = "NodeJS " + process.version + if (process.env['TD_CLIENT_CONFIG']) { + var obj = JSON.parse(process.env['TD_CLIENT_CONFIG']) + Object.keys(obj).forEach(k => Cloud.config[k] = obj[k]) + } + Util.logSz = 3000; setupGlobalAgent() diff --git a/noderunner/nrunner.ts b/noderunner/nrunner.ts index 04cd5f54..b8b41b1e 100644 --- a/noderunner/nrunner.ts +++ b/noderunner/nrunner.ts @@ -33,6 +33,7 @@ var authKey = ""; var liteStorage = process.env['TDC_LITE_STORAGE'] || ""; var apiEndpoint = process.env['TDC_API_ENDPOINT'] || "https://www.touchdevelop.com/api/"; var accessToken = process.env['TDC_ACCESS_TOKEN'] || ""; +var ccfg = TDev.Cloud.config; class ApiRequest { @@ -772,6 +773,13 @@ function handleQuery(ar:ApiRequest, tcRes:TDev.AST.LoadScriptResult) { renderHelpTopicAsync(TDev.HelpTopic.fromScript(TDev.Script)).done(top => html(top)) break; + case "raw-docs": + renderHelpTopicAsync(TDev.HelpTopic.fromScript(TDev.Script)).done(top => { + hr.writeHead(200, { "Content-Type": "text/plain" }); + hr.end(top, "utf-8") + }) + break; + case "docs-info": TDev.HelpTopic.fromScript(TDev.Script).docInfoAsync().done(resp => ar.ok(resp)) break; @@ -953,7 +961,10 @@ var apiHandlers = { }, "css": (ar:ApiRequest) => { - ar.ok( { css: TDev.CopyRenderer.css }) + ar.ok( { + css: TDev.CopyRenderer.css, + relid: ccfg.relid, + }) }, "oauth": (ar:ApiRequest) => { @@ -1012,6 +1023,7 @@ var apiHandlers = { }) ar.ok({ + relid: ccfg.relid, topics: topics, topicsExt: topicsExt }); @@ -1030,7 +1042,8 @@ var apiHandlers = { ar.ok({ textVersion: TDev.AST.App.currentVersion, releaseid: relId, - tdVersion: process.env['TDC_VERSION'], + relid: ccfg.relid, + tdVersion: ccfg.tdVersion, }); break; @@ -1392,7 +1405,7 @@ function reportBug(ctx: string, err: any) { if (!slave) console.error(TDev.Ticker.bugReportToString(bug)); bug.exceptionConstructor = "NJS " + bug.exceptionConstructor; - bug.tdVersion = process.env['TDC_VERSION'] + bug.tdVersion = ccfg.tdVersion TDev.Util.httpPostRealJsonAsync(apiEndpoint + "bug" + accessToken, bug) .done(() => {}, err => { diff --git a/rt/cloud.ts b/rt/cloud.ts index c76a996d..1b211078 100644 --- a/rt/cloud.ts +++ b/rt/cloud.ts @@ -13,6 +13,7 @@ module TDev.Cloud { tdVersion?: string; releaseid?: string; + relid?: string; releaseLabel?: string; }