Cleanup some uses of touchdevelop.com in literals; use Cloud.config where appropriate

This commit is contained in:
Michal Moskal 2015-04-21 20:53:40 -07:00
Родитель 7c177a70d0
Коммит db954cd4b4
5 изменённых файлов: 26 добавлений и 7 удалений

Просмотреть файл

@ -326,7 +326,7 @@ module TDev.AST.Apps {
// these 2 files are not stored in cdn, they are rewritten in the cloud // these 2 files are not stored in cdn, they are rewritten in the cloud
[ "error", "browsers"].forEach(n => instructions.files.push({ [ "error", "browsers"].forEach(n => instructions.files.push({
path: options.filePrefix + n + ".html", 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; instructions.meta.isCloud = app.isCloud;

Просмотреть файл

@ -356,12 +356,12 @@ module TDev {
public topicLink(id:string) 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) public appLink(id:string)
{ {
return (this.useExternalLinks ? "https://www.touchdevelop.com/app/" : "") + id return (this.useExternalLinks ? Cloud.getServiceUrl() + "/app/" : "") + id
} }
static shrink(s:string) static shrink(s:string)
@ -876,7 +876,7 @@ module TDev {
false)) false))
continue; continue;
var tdev = "https://www.touchdevelop.com/"; var tdev = Cloud.getServiceUrl() + "/";
if (allowRepl && ( if (allowRepl && (
applySpan(/^\{\#(\w+)\}/g, (m) => "<a name='" + quote(m[1]) + "'></a>") || applySpan(/^\{\#(\w+)\}/g, (m) => "<a name='" + quote(m[1]) + "'></a>") ||
applySpan(/^\[([^\[\]]*)\]\s*\(([^ \(\)\s]+)\)/, (m) => { applySpan(/^\[([^\[\]]*)\]\s*\(([^ \(\)\s]+)\)/, (m) => {

Просмотреть файл

@ -678,6 +678,11 @@ module TDev.RT.Node {
window.navigator = navigator; window.navigator = navigator;
navigator.userAgent = "NodeJS " + process.version 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; Util.logSz = 3000;
setupGlobalAgent() setupGlobalAgent()

Просмотреть файл

@ -33,6 +33,7 @@ var authKey = "";
var liteStorage = process.env['TDC_LITE_STORAGE'] || ""; var liteStorage = process.env['TDC_LITE_STORAGE'] || "";
var apiEndpoint = process.env['TDC_API_ENDPOINT'] || "https://www.touchdevelop.com/api/"; var apiEndpoint = process.env['TDC_API_ENDPOINT'] || "https://www.touchdevelop.com/api/";
var accessToken = process.env['TDC_ACCESS_TOKEN'] || ""; var accessToken = process.env['TDC_ACCESS_TOKEN'] || "";
var ccfg = TDev.Cloud.config;
class ApiRequest class ApiRequest
{ {
@ -772,6 +773,13 @@ function handleQuery(ar:ApiRequest, tcRes:TDev.AST.LoadScriptResult) {
renderHelpTopicAsync(TDev.HelpTopic.fromScript(TDev.Script)).done(top => html(top)) renderHelpTopicAsync(TDev.HelpTopic.fromScript(TDev.Script)).done(top => html(top))
break; 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": case "docs-info":
TDev.HelpTopic.fromScript(TDev.Script).docInfoAsync().done(resp => ar.ok(resp)) TDev.HelpTopic.fromScript(TDev.Script).docInfoAsync().done(resp => ar.ok(resp))
break; break;
@ -953,7 +961,10 @@ var apiHandlers = {
}, },
"css": (ar:ApiRequest) => { "css": (ar:ApiRequest) => {
ar.ok(<TDev.CssResponse> { css: TDev.CopyRenderer.css }) ar.ok(<TDev.CssResponse> {
css: TDev.CopyRenderer.css,
relid: ccfg.relid,
})
}, },
"oauth": (ar:ApiRequest) => { "oauth": (ar:ApiRequest) => {
@ -1012,6 +1023,7 @@ var apiHandlers = {
}) })
ar.ok(<TDev.DocTopicsResponse>{ ar.ok(<TDev.DocTopicsResponse>{
relid: ccfg.relid,
topics: topics, topics: topics,
topicsExt: topicsExt topicsExt: topicsExt
}); });
@ -1030,7 +1042,8 @@ var apiHandlers = {
ar.ok({ ar.ok({
textVersion: TDev.AST.App.currentVersion, textVersion: TDev.AST.App.currentVersion,
releaseid: relId, releaseid: relId,
tdVersion: process.env['TDC_VERSION'], relid: ccfg.relid,
tdVersion: ccfg.tdVersion,
}); });
break; break;
@ -1392,7 +1405,7 @@ function reportBug(ctx: string, err: any) {
if (!slave) if (!slave)
console.error(TDev.Ticker.bugReportToString(bug)); console.error(TDev.Ticker.bugReportToString(bug));
bug.exceptionConstructor = "NJS " + bug.exceptionConstructor; bug.exceptionConstructor = "NJS " + bug.exceptionConstructor;
bug.tdVersion = process.env['TDC_VERSION'] bug.tdVersion = ccfg.tdVersion
TDev.Util.httpPostRealJsonAsync(apiEndpoint + "bug" + accessToken, bug) TDev.Util.httpPostRealJsonAsync(apiEndpoint + "bug" + accessToken, bug)
.done(() => {}, err => { .done(() => {}, err => {

Просмотреть файл

@ -13,6 +13,7 @@ module TDev.Cloud {
tdVersion?: string; tdVersion?: string;
releaseid?: string; releaseid?: string;
relid?: string;
releaseLabel?: string; releaseLabel?: string;
} }