kopia lustrzana https://github.com/backface/turtlestitch
Merge pull request #2497 from jmoenig/community-link
Show a link to the community page for current projectpull/89/head
commit
f24a32c06b
18
src/cloud.js
18
src/cloud.js
|
@ -47,8 +47,8 @@ function Cloud() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Cloud.prototype.init = function () {
|
Cloud.prototype.init = function () {
|
||||||
this.urlBasePath = '/api/v1';
|
this.apiBasePath = '/api/v1';
|
||||||
this.url = this.determineCloudDomain() + this.urlBasePath;
|
this.url = this.determineCloudDomain() + this.apiBasePath;
|
||||||
this.username = null;
|
this.username = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1098,3 +1098,17 @@ Cloud.prototype.removeEditorFromCollection = function (
|
||||||
'Could not remove editor from collection'
|
'Could not remove editor from collection'
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Paths to front-end pages
|
||||||
|
/*
|
||||||
|
This list of paths is incomplete, we will add them as necessary.
|
||||||
|
Important: a path is a string *without* a domain.
|
||||||
|
These paths are not prefixed by `apiBasePath`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Cloud.prototype.showProjectPath = function (username, projectname) {
|
||||||
|
return '/project?' + this.encodeDict({
|
||||||
|
user: username,
|
||||||
|
project: projectname
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
25
src/gui.js
25
src/gui.js
|
@ -2637,6 +2637,19 @@ IDE_Morph.prototype.cloudMenu = function () {
|
||||||
'changeCloudPassword'
|
'changeCloudPassword'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (this.hasCloudProject()) {
|
||||||
|
menu.addLine();
|
||||||
|
menu.addItem(
|
||||||
|
'open in community site',
|
||||||
|
function () {
|
||||||
|
var dict = myself.urlParameters();
|
||||||
|
window.open(
|
||||||
|
myself.cloud.showProjectPath(dict.Username, dict.ProjectName),
|
||||||
|
'_blank'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
if (shiftClicked) {
|
if (shiftClicked) {
|
||||||
menu.addLine();
|
menu.addLine();
|
||||||
menu.addItem(
|
menu.addItem(
|
||||||
|
@ -5891,6 +5904,18 @@ IDE_Morph.prototype.setCloudURL = function () {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IDE_Morph.prototype.urlParameters = function () {
|
||||||
|
var parameters = location.hash.slice(location.hash.indexOf(':') + 1);
|
||||||
|
|
||||||
|
return this.cloud.parseDict(parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
IDE_Morph.prototype.hasCloudProject = function () {
|
||||||
|
var params = this.urlParameters();
|
||||||
|
|
||||||
|
return params.hasOwnProperty('Username') && params.hasOwnProperty('ProjectName');
|
||||||
|
}
|
||||||
|
|
||||||
// IDE_Morph HTTP data fetching
|
// IDE_Morph HTTP data fetching
|
||||||
|
|
||||||
IDE_Morph.prototype.getURL = function (url, callback, responseType) {
|
IDE_Morph.prototype.getURL = function (url, callback, responseType) {
|
||||||
|
|
Ładowanie…
Reference in New Issue