kopia lustrzana https://github.com/backface/turtlestitch
Merge pull request #2292 from bromagosa/remix-changes
Changes needed for the remix functionality in our new social sitepull/89/head
commit
0020ce17f7
48
src/cloud.js
48
src/cloud.js
|
@ -413,7 +413,8 @@ Cloud.prototype.saveProject = function (ide, onSuccess, onError) {
|
|||
xml: xml,
|
||||
media: ide.hasChangedMedia ?
|
||||
ide.serializer.mediaXML(ide.projectName) : null,
|
||||
thumbnail: thumbnail
|
||||
thumbnail: thumbnail,
|
||||
remixID: ide.stage.remixID
|
||||
};
|
||||
ide.serializer.isCollectingMedia = false;
|
||||
ide.serializer.flushMedia();
|
||||
|
@ -617,6 +618,32 @@ Cloud.prototype.getProjectVersionMetadata = function (
|
|||
);
|
||||
};
|
||||
|
||||
Cloud.prototype.getRemixes = function (
|
||||
username,
|
||||
page,
|
||||
pageSize,
|
||||
projectName,
|
||||
onSuccess,
|
||||
onError,
|
||||
withThumbnail
|
||||
) {
|
||||
var path = '/projects/' +
|
||||
encodeURIComponent(username) + '/' +
|
||||
encodeURIComponent(projectName) + '/remixes';
|
||||
|
||||
if (page) {
|
||||
path += '?page=' + page + '&pagesize=' + (pageSize || 16);
|
||||
}
|
||||
|
||||
this.request(
|
||||
'GET',
|
||||
path,
|
||||
onSuccess,
|
||||
onError,
|
||||
'Could not fetch remixes for project ' + projectName
|
||||
);
|
||||
};
|
||||
|
||||
Cloud.prototype.deleteProject = function (
|
||||
projectName,
|
||||
username,
|
||||
|
@ -711,25 +738,6 @@ Cloud.prototype.unpublishProject = function (
|
|||
);
|
||||
};
|
||||
|
||||
Cloud.prototype.remixProject = function (
|
||||
projectName,
|
||||
username,
|
||||
onSuccess,
|
||||
onError
|
||||
) {
|
||||
this.withCredentialsRequest(
|
||||
'POST',
|
||||
'/projects/' +
|
||||
encodeURIComponent(username) +
|
||||
'/' +
|
||||
encodeURIComponent(projectName) +
|
||||
'/remix',
|
||||
onSuccess,
|
||||
onError,
|
||||
'Could not remix project'
|
||||
);
|
||||
};
|
||||
|
||||
Cloud.prototype.updateNotes = function (
|
||||
projectName,
|
||||
notes,
|
||||
|
|
|
@ -4381,7 +4381,8 @@ IDE_Morph.prototype.rawOpenCloudDataString = function (str) {
|
|||
this.serializer.openProject(
|
||||
this.serializer.loadProjectModel(
|
||||
model.childNamed('project'),
|
||||
this
|
||||
this,
|
||||
model.attributes.remixID
|
||||
),
|
||||
this
|
||||
);
|
||||
|
@ -4394,7 +4395,8 @@ IDE_Morph.prototype.rawOpenCloudDataString = function (str) {
|
|||
this.serializer.openProject(
|
||||
this.serializer.loadProjectModel(
|
||||
model.childNamed('project'),
|
||||
this
|
||||
this,
|
||||
model.attributes.remixID
|
||||
),
|
||||
this
|
||||
);
|
||||
|
|
|
@ -6336,6 +6336,8 @@ StageMorph.prototype.init = function (globals) {
|
|||
|
||||
this.cachedPenTrailsMorph = null; // optimization, do not persist
|
||||
|
||||
this.remixID = null;
|
||||
|
||||
StageMorph.uber.init.call(this);
|
||||
|
||||
this.acceptsDrops = false;
|
||||
|
|
|
@ -316,7 +316,7 @@ SnapSerializer.prototype.load = function (xmlString, ide) {
|
|||
return this.loadProjectModel(this.parse(xmlString), ide);
|
||||
};
|
||||
|
||||
SnapSerializer.prototype.loadProjectModel = function (xmlNode, ide) {
|
||||
SnapSerializer.prototype.loadProjectModel = function (xmlNode, ide, remixID) {
|
||||
// public - answer a new Project represented by the given XML top node
|
||||
// show a warning if the origin apps differ
|
||||
|
||||
|
@ -331,10 +331,10 @@ SnapSerializer.prototype.loadProjectModel = function (xmlNode, ide) {
|
|||
'\n\nand may be incompatible or fail to load here.'
|
||||
);
|
||||
}
|
||||
return this.rawLoadProjectModel(xmlNode);
|
||||
return this.rawLoadProjectModel(xmlNode, remixID);
|
||||
};
|
||||
|
||||
SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) {
|
||||
SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode, remixID) {
|
||||
// private
|
||||
var myself = this,
|
||||
project = {sprites: {}},
|
||||
|
@ -376,6 +376,7 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) {
|
|||
model.stage = model.project.require('stage');
|
||||
StageMorph.prototype.frameRate = 0;
|
||||
project.stage = new StageMorph(project.globalVariables);
|
||||
project.stage.remixID = remixID;
|
||||
if (Object.prototype.hasOwnProperty.call(
|
||||
model.stage.attributes,
|
||||
'id'
|
||||
|
|
Ładowanie…
Reference in New Issue