Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Removing sign in and publishing #509

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 0 additions & 98 deletions editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ module TDev

public additionalFullScreenButtons(): HTMLElement[] {
var btns = [];
if (ScriptEditorWorldInfo.status == "published" && TheEditor.widgetEnabled("wallScreenshot"))
btns.push(HTML.mkRoundButton("svg:camera,currentColor", lf("screenshot"), Ticks.wallScreenshot, () => this.takeScreenshot()));
if (Browser.serialLog)
btns.push(HTML.mkRoundButton("svg:CommandLine,currentColor", lf("serial"), Ticks.wallSerial, () => this.showSerialView()))
return btns;
Expand All @@ -195,82 +193,12 @@ module TDev
}

public takeScreenshot() {
if (!Script) return;
if (ScriptEditorWorldInfo.status !== "published") {
ModalDialog.info(lf("Oops, your script is not published"),
lf("You need to publish your script in order to upload screenshots."));
return;
}
if (Cloud.anonMode(lf("publishing screenshots"))) return;

var baseId = ScriptEditorWorldInfo.baseId;
RT.ScreenshotManager.toScreenshotURLAsync(this, false)
.done((data: string) => {
if (!data) {
ModalDialog.info(lf("Oops, we could not take the screenshot"),
lf("You are probably using a picture downloaded from the web on the board. Your web browser and the web site prevent cross-origin resource sharing (CORS)."));
return;
}

var contentType = data.match(/^data:(image\/(png|jpeg));base64,/i)[1];
Util.log('content type: ' + contentType);
var base64content = Util.base64EncodeToBase64(data, contentType);
if (base64content && base64content.length > 2000000) {
var m = new ModalDialog();
m.add([
div("wall-dialog-header", lf("Oops, we can't take a screenshot now")),
div("wall-dialog-body", lf("The encoded screenshot is too big.")),
]);
m.show();
} else if (base64content && baseId) {
var previewImage = HTML.mkImg(data);
previewImage.setAttribute('class', 'wall-media');
var m = new ModalDialog();
m.add([
div("wall-dialog-header", lf("wall screenshot")),
div("wall-dialog-body", lf("Publish your screenshot to the cloud so that everybody can enjoy it.")),
div("wall-dialog-buttons",
HTML.mkButton(lf("publish"), () => {
m.dismiss();
HTML.showProgressNotification(lf("uploading screenshot..."));
Cloud.postPrivateApiAsync(baseId + "/screenshots",
{
kind: "screenshot",
contentType: contentType,
content: base64content,
userplatform: Browser.platformCaps
}).done((resp : JsonScreenShot) => {
HTML.showProgressNotification(lf("screenshot uploaded"), true);
Cloud.postCommentAsync(baseId, lf("{0} added a screenshot {1}", ((<any>window).userName || ""), "/" + resp.id))
.done(() => { },() => { });
Browser.Hub.askToEnableNotifications();
}, e => {
HTML.showProgressNotification(lf("screenshot upload failed"), true);
Cloud.handlePostingError(e, lf("post screenshot"));
});
})),
previewImage
]);
m.setScroll();
m.show();
} else {
var m = new ModalDialog();
m.add([
div("wall-dialog-header", lf("Oops, we can't take a screenshot now.")),
div("wall-dialog-body", lf("Unfortunately, we can only take screenshots of full screen boards.")),
]);
m.show();
}
});
}

public notifyStopAsync() : Promise
{
TheEditor.stopPlayTime();
this.currentRt.editorObj = undefined;
if (ScriptEditorWorldInfo &&
ScriptEditorWorldInfo.status !== "published")
this.takeScreenshotMaybe();
return super.notifyStopAsync().then(v => {
if (TheEditor.stepTutorial) TheEditor.stepTutorial.notify("runStop");
if (this.currentRt.headlessPluginMode &&
Expand Down Expand Up @@ -312,32 +240,6 @@ module TDev
// Update edit mode. (When live mode, updateEditMode is called in SideEditorHost.notifyStopAsync())
if (!this.currentRt.liveMode())
LayoutMgr.instance.updateEditMode(this.currentRt);

// take screenshots periodically
var takePoll = () => {
if (this.takeScreenshotMaybe())
Util.setTimeout(TheEditor.hasLastScreenshot() ? 5000 : 3000, takePoll);
}
if (ScriptEditorWorldInfo &&
ScriptEditorWorldInfo.status !== "published")
Util.setTimeout(2000, takePoll);
}

private takeScreenshotMaybe(): boolean {
if (Cloud.isRestricted()) return false;
if (this.currentRt && !this.currentRt.isStopped()) {
if (!TheEditor.hasLastScreenshot() || Math.random() < 0.4) {
if (Browser.screenshots && Browser.isHosted)
TDev.RT.ScreenshotManager.toScreenshotURLAsync(this.currentRt.host, true)
.done(url => TheEditor.setLastScreenshotDataUri(url));
else {
var canvas = this.toScreenshotCanvas();
TheEditor.setLastScreenshotCanvas(canvas);
}
return true;
}
}
return false;
}

public notifyBreakpointHit(bp: string) {
Expand Down
157 changes: 1 addition & 156 deletions editor/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,139 +288,6 @@ module TDev.Browser {
description: lf("All options turned on"),
editorMode: editorModes['pro']
},
'minecraft': {
name: "Minecraft",
description: lf("Learn to code with Minecraft"),
logoArtId: 'eopyzwpm',
tutorialsTopic: 'minecrafttutorials',
scriptSearch: '#minecraft',
scriptTemplates: ['blankminecraft', 'blankcreeper'],
noAnimations: true,
editorMode: {
id: 'minecraft',
name: lf("minecraft"),
descr: lf("Drag and drop blocks, simplified interface, great for beginners!"),
astMode: 2,
artId: 'brfljsds',
widgets: {
// edit
addNewButton: true,
undoButton: true,
changeSkillLevel: true,
async: true,
// refactoring
updateButton: true,
promoteRefactoring: true,
fixItButton: true,
splitScreen: false,
splitScreenOnLoad: true,
// searchArtRefactoring: true,
// calcSearchArt: true,
scriptProperties: true,
scriptPropertiesIcons: true,
// statements
copyPaste: true,
selectStatements: true,
stringConcatProperty: true,
show: true,
"return": true,
gotoNavigation: true,
// sections
dataSection: true,
// artSection: true,
librariesSection: true,
// ui
wallScreenshot: true,
wallHeart: true,
startTutorialButton: true,
nextTutorialsList: true,
// hub
hubTutorials: true,
// hubShowcase : true,
publicationComments: true,
translateComments: true,

whileConditionDefault: "true",
whileBodyDefault: "skip; minecraft->pause(20);",
forConditionDefault: "5",
ifConditionDefault: "true",

scriptSocialLinks: true,
scriptAddToChannel: true,
}
}
},
'rpi': {
name: "Raspberry Pi",
description: lf("Learn to code with Raspberry Pi"),
logoArtId: 'eopyzwpm',
tutorialsTopic: 'minecraftpitutorials',
scriptTemplates: ['blankminecraftpi'],
noAnimations: true,
lowMemory: true,
editorMode: editorModes['block'],
},
'arduino': {
name: "Arduino",
description: lf("Program Arduino boards"),
logoArtId: 'kzajxznr',
wallpaperArtId: 'kzajxznr',
tutorialsTopic: 'arduinotutorials',
scriptSearch: '#arduino',
scriptTemplates: ['blankarduino', 'blankesplore'],
intelliProfileId: 'kbmkc',
editorMode: editorModes['classic'],
},
'engduino': {
name: "Engduino",
description: lf("Programming the Engduino"),
logoArtId: 'qmjzqlkc',
wallpaperArtId: 'qmjzqlkc',
scriptSearch: '#engduino',
scriptTemplates: ['blankengduino'],
intelliProfileId: 'kbmkc',
editorMode: editorModes['classic'],
},
'microbit': {
name: 'BBC micro:bit',
description: ' ',
scriptSearch: '#microbit',
scriptTemplates: ['blankmicrobit'],
intelliProfileId: 'upfje',
editorMode: {
id: 'microbit',
name: 'Micro Bit',
descr: lf("Micro Bit mode!"),
astMode: 2,
widgets: {
hubTutorials: true,
addNewButton: true,
undoButton: true,
promoteRefactoring: true,
copyPaste: true,
comment: true,
dataSection: true,
gotoNavigation: true,
splitScreenOnLoad: true,
updateButton: true,
forceMainAsAction: true,
singleReturnValue: true,
integerNumbers: true,
codeSearch: true,
librariesSection: true,
scriptPropertiesSettings: true,
editorRunOnLoad: true,
whileConditionDefault: "true",
whileBodyDefault: "skip; basic->pause(20);",
forConditionDefault: "5",
"return": true,
"break": true,
scriptPrintScript: true,
scriptPrintTopic: true,
tutorialGoToPreviousStep: true,
}
},
},
'restricted': {
name: "Restricted",
description: lf("Opinionated restricted mode"),
Expand Down Expand Up @@ -1564,7 +1431,7 @@ module TDev.Browser {
extends Screen {
constructor() {
super()
this.topContainer = div(null, this.logo, this.meBox, this.notificationBox);
this.topContainer = div(null, this.logo, this.notificationBox);
this.topBox = div(null, this.topContainer);
this.eol = document.createElement("a");
this.eol.className = "eol";
Expand All @@ -1575,7 +1442,6 @@ module TDev.Browser {
private mainContent = div("hubContent");
private logo = div("hubLogo", SVG.getTopLogo());
private bglogo = div("hubBgLogo", HTML.mkImg("svg:touchDevelop,currentColor", '', '', true));
private meBox = div("hubMe");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't that where the "read only" banner would go?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have the banner accross the screen.

private eol: HTMLAnchorElement;
private notificationBox = div("notificationBox");
private topBox: HTMLElement;
Expand Down Expand Up @@ -2812,14 +2678,6 @@ module TDev.Browser {
sects["tutorials"] = { title: lf("tutorials") };
if (widgets.hubLearn)
sects["learn"] = { title: lf("learn") };
if (widgets.hubChannels)
sects["channels"] = { title: lf("channels") };
if (widgets.hubShowcase)
sects["showcase"] = { title: lf("showcase") };
if (widgets.hubTopAndNew)
sects["top"] = { title: lf("top & new") };
if (widgets.hubMyArt)
sects["myart"] = { title: lf("my art") };

if (SizeMgr.portraitMode) {
this.vertical = true;
Expand Down Expand Up @@ -2849,7 +2707,6 @@ module TDev.Browser {
var sectWidth = (name:string):number => sectWidths['default']

this.logo.style.display = "";
this.meBox.style.display = "";

// h=26em

Expand Down Expand Up @@ -2959,18 +2816,6 @@ module TDev.Browser {
}

this.mainContent.setChildren(divs);

if (Cloud.getUserId()) {
var uid = this.browser().getUserInfoById("me", "me");
this.meBox.setChildren([uid.mkSmallBox()]);
this.browser().addNotificationCounter(this.notificationBox);
} else {
var loginBtn = HTML.mkButtonElt("wall-button login-button", SVG.getLoginButton())
this.meBox.setChildren(loginBtn.withClick(() => {
Login.show();
}))
this.notificationBox.setChildren([]);
}
}

private docTopics:any[];
Expand Down
14 changes: 1 addition & 13 deletions editor/recordProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,6 @@ module TDev
}, {
name: "local",
tick: Ticks.recordPersLocal
}, {
name: "replicated",
tick: Ticks.recordPersCloud
}];

static servicePersistenceLabels = [{
Expand All @@ -269,22 +266,13 @@ module TDev
}, {
name: "server-local",
tick: Ticks.recordPersLocal
}, {
name: "fully replicated",
tick: Ticks.recordPersCloud
} /*, {
name: "partially replicated",
tick: Ticks.recordPersPartial
} */];
}];
static cloudlibraryVarPersistenceLabels = [{
name: "temporary",
tick: Ticks.recordPersTemporary
}, {
name: "server-local",
tick: Ticks.recordPersLocal
}, {
name: "replicated",
tick: Ticks.recordPersCloud
}];


Expand Down
Loading