Merge pull request #2497 from jmoenig/community-link

Show a link to the community page for current project
pull/89/head
Jens Mönig 2019-10-09 16:41:38 +02:00 zatwierdzone przez GitHub
commit f24a32c06b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 41 dodań i 2 usunięć

Wyświetl plik

@ -47,8 +47,8 @@ function Cloud() {
}
Cloud.prototype.init = function () {
this.urlBasePath = '/api/v1';
this.url = this.determineCloudDomain() + this.urlBasePath;
this.apiBasePath = '/api/v1';
this.url = this.determineCloudDomain() + this.apiBasePath;
this.username = null;
};
@ -1098,3 +1098,17 @@ Cloud.prototype.removeEditorFromCollection = function (
'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
});
}

Wyświetl plik

@ -2637,6 +2637,19 @@ IDE_Morph.prototype.cloudMenu = function () {
'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) {
menu.addLine();
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.prototype.getURL = function (url, callback, responseType) {