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,
|
xml: xml,
|
||||||
media: ide.hasChangedMedia ?
|
media: ide.hasChangedMedia ?
|
||||||
ide.serializer.mediaXML(ide.projectName) : null,
|
ide.serializer.mediaXML(ide.projectName) : null,
|
||||||
thumbnail: thumbnail
|
thumbnail: thumbnail,
|
||||||
|
remixID: ide.stage.remixID
|
||||||
};
|
};
|
||||||
ide.serializer.isCollectingMedia = false;
|
ide.serializer.isCollectingMedia = false;
|
||||||
ide.serializer.flushMedia();
|
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 (
|
Cloud.prototype.deleteProject = function (
|
||||||
projectName,
|
projectName,
|
||||||
username,
|
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 (
|
Cloud.prototype.updateNotes = function (
|
||||||
projectName,
|
projectName,
|
||||||
notes,
|
notes,
|
||||||
|
|
|
@ -4381,7 +4381,8 @@ IDE_Morph.prototype.rawOpenCloudDataString = function (str) {
|
||||||
this.serializer.openProject(
|
this.serializer.openProject(
|
||||||
this.serializer.loadProjectModel(
|
this.serializer.loadProjectModel(
|
||||||
model.childNamed('project'),
|
model.childNamed('project'),
|
||||||
this
|
this,
|
||||||
|
model.attributes.remixID
|
||||||
),
|
),
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
|
@ -4394,7 +4395,8 @@ IDE_Morph.prototype.rawOpenCloudDataString = function (str) {
|
||||||
this.serializer.openProject(
|
this.serializer.openProject(
|
||||||
this.serializer.loadProjectModel(
|
this.serializer.loadProjectModel(
|
||||||
model.childNamed('project'),
|
model.childNamed('project'),
|
||||||
this
|
this,
|
||||||
|
model.attributes.remixID
|
||||||
),
|
),
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
|
|
|
@ -6336,6 +6336,8 @@ StageMorph.prototype.init = function (globals) {
|
||||||
|
|
||||||
this.cachedPenTrailsMorph = null; // optimization, do not persist
|
this.cachedPenTrailsMorph = null; // optimization, do not persist
|
||||||
|
|
||||||
|
this.remixID = null;
|
||||||
|
|
||||||
StageMorph.uber.init.call(this);
|
StageMorph.uber.init.call(this);
|
||||||
|
|
||||||
this.acceptsDrops = false;
|
this.acceptsDrops = false;
|
||||||
|
|
|
@ -316,7 +316,7 @@ SnapSerializer.prototype.load = function (xmlString, ide) {
|
||||||
return this.loadProjectModel(this.parse(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
|
// public - answer a new Project represented by the given XML top node
|
||||||
// show a warning if the origin apps differ
|
// 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.'
|
'\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
|
// private
|
||||||
var myself = this,
|
var myself = this,
|
||||||
project = {sprites: {}},
|
project = {sprites: {}},
|
||||||
|
@ -376,6 +376,7 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) {
|
||||||
model.stage = model.project.require('stage');
|
model.stage = model.project.require('stage');
|
||||||
StageMorph.prototype.frameRate = 0;
|
StageMorph.prototype.frameRate = 0;
|
||||||
project.stage = new StageMorph(project.globalVariables);
|
project.stage = new StageMorph(project.globalVariables);
|
||||||
|
project.stage.remixID = remixID;
|
||||||
if (Object.prototype.hasOwnProperty.call(
|
if (Object.prototype.hasOwnProperty.call(
|
||||||
model.stage.attributes,
|
model.stage.attributes,
|
||||||
'id'
|
'id'
|
||||||
|
|
Ładowanie…
Reference in New Issue