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
[ "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;

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

@ -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) => "<a name='" + quote(m[1]) + "'></a>") ||
applySpan(/^\[([^\[\]]*)\]\s*\(([^ \(\)\s]+)\)/, (m) => {

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

@ -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()

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

@ -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(<TDev.CssResponse> { css: TDev.CopyRenderer.css })
ar.ok(<TDev.CssResponse> {
css: TDev.CopyRenderer.css,
relid: ccfg.relid,
})
},
"oauth": (ar:ApiRequest) => {
@ -1012,6 +1023,7 @@ var apiHandlers = {
})
ar.ok(<TDev.DocTopicsResponse>{
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 => {

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

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