From 676235b57828444b02465e01406471ea6fda6941 Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Sat, 14 Oct 2017 00:07:48 -0400 Subject: [PATCH 01/14] Fixing #2479 Description wasn't saving if the project wasn't published. Now, by clicking cancel while the project is unpublished, the description is saved --- Vagrantfile | 2 +- public/editor/scripts/ui/publisher.js | 58 +++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index aa308559e..d56481ba3 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -11,7 +11,7 @@ Vagrant.configure("2") do |config| # VM, but users are encouraged to test this and make adjustments below (or file PRs) # if you find the VM lagging or unresponsive. config.vm.provider "virtualbox" do |v| - v.memory = 1536 + v.memory = 8000 v.cpus = 1 v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"] end diff --git a/public/editor/scripts/ui/publisher.js b/public/editor/scripts/ui/publisher.js index 14d5d3965..a976bd91f 100644 --- a/public/editor/scripts/ui/publisher.js +++ b/public/editor/scripts/ui/publisher.js @@ -29,6 +29,7 @@ function Publisher() { buttons: { publish: $("#publish-button-publish"), update: $("#publish-button-update"), + saveDescription: $("#publish-button-cancel"), /*Added Cancel button*/ unpublish: $("#publish-button-unpublish"), parent: $("#publish-buttons"), indexMessage: $("#no-index") @@ -54,6 +55,7 @@ Publisher.prototype.init = function(bramble) { publisher.handlers = { publish: publisher.publish.bind(publisher, bramble), unpublish: publisher.unpublish.bind(publisher), + setDesc: publisher.setDesc.bind(publisher), unpublishedChangesPrompt: unpublishedChangesPrompt.bind(publisher) }; @@ -78,6 +80,10 @@ Publisher.prototype.init = function(bramble) { publisher.showUnpublishedChangesPrompt(); }); + //saves the description and displays message to user telling them they have made changes + //and suggesting they should publish their project. + dialog.buttons.saveDescription.on("click", publisher.handlers.setDesc); + dialog.buttons.publish.on("click", publisher.handlers.publish); // Were there any files that were updated and not published? @@ -130,6 +136,58 @@ Publisher.prototype.showUnpublishedChangesPrompt = function(callback) { }); }; +//Using parts from "unpublish" in order to sync properly +Publisher.prototype.setDesc = function() { + var publisher = this; + var handlers = publisher.handlers; + var dialog = publisher.dialog; + var buttons = dialog.buttons; + + if (publisher.unpublishing) { + return; + } + + publisher.unpublishing = true; + + SyncState.syncing(); + + var request = publisher.generateRequest("unpublish"); + request.done(function() { + if (request.status !== 200) { + console.error( + "[Thimble] Server was unable to unpublish project, responded with status ", + request.status + ); + return; + } + + buttons.parent.removeClass("hide"); + + publisher.updateDialog(""); + + Project.publishNeedsUpdate(false, function(err) { + if (err) { + console.error( + "[Thimble] Failed to set the publishNeedsUpdate flag after unpublishing with: ", + err + ); + return; + } + Project.setPublishUrl(null); + publisher.needsUpdate = false; + }); + }); + request.fail(function(jqXHR, status, err) { + console.error( + "[Thimble] Failed to send request to unpublish project to the server with: ", + err + ); + }); + request.always(function() { + SyncState.completed(); + }); +}; + Publisher.prototype.publish = function(bramble) { var publisher = this; var dialog = publisher.dialog; From 92f0598938010901e591248437f8b3d2770c7776 Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Tue, 17 Oct 2017 14:33:06 -0400 Subject: [PATCH 02/14] Fixing #2479 2nd try Changed Vagrant settings back to normal. I also simplified the code and made it clearer as to what the code is currently doing. Guidance is needed for ajax request, as well as how to interact with the outside of the Publish dialog, in order to change how the description is saved (instead of clicking cancel, one would have to click outside the dialog). --- Vagrantfile | 2 +- public/editor/scripts/ui/publisher.js | 70 +++++++++++---------------- 2 files changed, 30 insertions(+), 42 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index d56481ba3..aa308559e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -11,7 +11,7 @@ Vagrant.configure("2") do |config| # VM, but users are encouraged to test this and make adjustments below (or file PRs) # if you find the VM lagging or unresponsive. config.vm.provider "virtualbox" do |v| - v.memory = 8000 + v.memory = 1536 v.cpus = 1 v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"] end diff --git a/public/editor/scripts/ui/publisher.js b/public/editor/scripts/ui/publisher.js index a976bd91f..9bed9d43b 100644 --- a/public/editor/scripts/ui/publisher.js +++ b/public/editor/scripts/ui/publisher.js @@ -29,7 +29,7 @@ function Publisher() { buttons: { publish: $("#publish-button-publish"), update: $("#publish-button-update"), - saveDescription: $("#publish-button-cancel"), /*Added Cancel button*/ + saveDescription: $("#publish-button-cancel"), unpublish: $("#publish-button-unpublish"), parent: $("#publish-buttons"), indexMessage: $("#no-index") @@ -55,7 +55,7 @@ Publisher.prototype.init = function(bramble) { publisher.handlers = { publish: publisher.publish.bind(publisher, bramble), unpublish: publisher.unpublish.bind(publisher), - setDesc: publisher.setDesc.bind(publisher), + setDescription: publisher.setDescription.bind(publisher), unpublishedChangesPrompt: unpublishedChangesPrompt.bind(publisher) }; @@ -82,8 +82,10 @@ Publisher.prototype.init = function(bramble) { //saves the description and displays message to user telling them they have made changes //and suggesting they should publish their project. - dialog.buttons.saveDescription.on("click", publisher.handlers.setDesc); - + dialog.buttons.saveDescription.on("click", publisher.handlers.setDescription); + //$("#click-underlay").on("click", publisher.handlers.setDesc); + + dialog.buttons.publish.on("click", publisher.handlers.publish); // Were there any files that were updated and not published? @@ -136,58 +138,44 @@ Publisher.prototype.showUnpublishedChangesPrompt = function(callback) { }); }; -//Using parts from "unpublish" in order to sync properly -Publisher.prototype.setDesc = function() { +//Using generateRequest("unpublish") in order to sync description +//throws error since nothing is being unpublished, however request +//to save description. This is currently a "hack" until further notice +Publisher.prototype.setDescription = function() { var publisher = this; - var handlers = publisher.handlers; - var dialog = publisher.dialog; - var buttons = dialog.buttons; - - if (publisher.unpublishing) { - return; - } - - publisher.unpublishing = true; SyncState.syncing(); - var request = publisher.generateRequest("unpublish"); - request.done(function() { - if (request.status !== 200) { - console.error( - "[Thimble] Server was unable to unpublish project, responded with status ", - request.status - ); - return; - } - - buttons.parent.removeClass("hide"); - - publisher.updateDialog(""); - - Project.publishNeedsUpdate(false, function(err) { - if (err) { - console.error( - "[Thimble] Failed to set the publishNeedsUpdate flag after unpublishing with: ", - err - ); - return; - } - Project.setPublishUrl(null); - publisher.needsUpdate = false; - }); + var request = $.ajax({ + contentType: "application/json", + headers: { + "X-Csrf-Token": publisher.csrfToken, + Accept: "application/json" + }, + type: "PUT", + url: host + "/projects/" + Project.getID() + "/unpublish", + data: JSON.stringify({ + description: publisher.dialog.description.val() || " ", + public: publisher.isProjectPublic, + dateUpdated: new Date().toISOString() + }) }); + + //expected to fail because an unpublished project can't be unpublished + //doing this for now until we can send an ajax request to UPDATE only request.fail(function(jqXHR, status, err) { console.error( "[Thimble] Failed to send request to unpublish project to the server with: ", - err + err, "but description is now updated" ); }); request.always(function() { SyncState.completed(); }); + }; + Publisher.prototype.publish = function(bramble) { var publisher = this; var dialog = publisher.dialog; From 129191a2132af0685d9455724cff4085589c3437 Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Tue, 17 Oct 2017 15:49:24 -0400 Subject: [PATCH 03/14] Merge branch 'master' of https://github.com/mozilla/thimble.mozilla.org into p1 --- README.md | 4 ++-- locales/kab/editor.properties | 1 + locales/kab/server.properties | 11 +++++++++++ locales/nn-NO/editor.properties | 1 + locales/nn-NO/server.properties | 6 +++++- locales/te/server.properties | 1 + locales/zh-CN/editor.properties | 3 +++ locales/zh-CN/server.properties | 26 ++++++++++++++++++-------- package.json | 1 + public/editor/scripts/ui/menus.js | 17 +++++++++-------- views/editor/nav-options.html | 16 ++++++++-------- 11 files changed, 60 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index e5254feb8..868e6cfe0 100644 --- a/README.md +++ b/README.md @@ -76,8 +76,8 @@ The first step is to fork and clone Thimble and navigate to the cloned directory For the first time, you need to install Thimble's dependencies and start all dependent services. To do this, simply run the following commands in succession: ```sh -npm run env npm install +npm run env vagrant up ``` This process can take a while depending on your internet connection speed as it needs to download all dependencies. @@ -123,8 +123,8 @@ Please note: On Windows, use ``copy`` instead of ``cp`` #### Thimble * Fork and clone https://github.com/mozilla/thimble.mozilla.org -* Run ``npm run env`` to create an environment file * Run ``npm install`` to install dependencies +* Run ``npm run env`` to create an environment file * Run ``npm start`` to start the server #### id.webmaker.org diff --git a/locales/kab/editor.properties b/locales/kab/editor.properties index 7c005705e..c641cede4 100644 --- a/locales/kab/editor.properties +++ b/locales/kab/editor.properties @@ -185,6 +185,7 @@ VIDEO_OPTION_DISABLE_AUDIO=Sens ameslaw # Audio Viewer AUDIO_FILE=Afaylu ameslaw AUDIO_OPTIONS=Iɣewwaṛen n umeslaw +AUDIO_OPTION_AUTOPLAY=Bdu taɣuri n imesli-agi s wudem awurman # Binary Viewer # Title for binary file actions that user can take diff --git a/locales/kab/server.properties b/locales/kab/server.properties index 65c9fb316..95ab632e9 100644 --- a/locales/kab/server.properties +++ b/locales/kab/server.properties @@ -27,6 +27,7 @@ signInPromptHomepage=Lær deg å undervise som Mozilla på learning.mozilla.org. pageTitleGetInvolved=Thimble av Mozilla - ver med +pageTitleFeatures=Thimble av Mozilla - funksjonar # Userbar signInPromptHomepage= eller # Reload Preview Page +errorCantLoadPreviewTitle=Å nei, noko gjekk gale! +errorCantLoadPreview=Vi klarte ikkje å laste førehandsvisinga, last om for å prøve på nytt… reloadButtonLabel=Oppdater ############ @@ -33,6 +36,8 @@ reloadButtonLabel=Oppdater # Loading the editor loadingProject=Lastar prosjekt +loadingProjectSupportSuggestion=Om prosketet ikkje lastar, få hjelp her. +reloadThimbleMessage=Oppdater nettlesaren din for å laste inn Thimble på nytt. errorCouldNotStart=Thimble klarte ikkje å starte. errorUnsupportedBrowserIgnore=La meg prøve likevel! tryAgainButtonLabel=Prøv på nytt @@ -273,7 +278,6 @@ sanariaz154Quote=«Alle menneske treng nokon som gjev oss tilbakemelding. Slik f raygervaisContrib1=Lagt til ein JavaScript-konsoll for å hjelpa elevane med å feilsøkje koden sin og å finne feil raygervaisContrib2=Forbetra brukarvennlegheita i Thimble-menyane cgsinghContrib1=La til skildringar på prosjektsoda -peiying16Contrib1=La til støtte for filikon i peiying16Contrib2=Fiksa ein feil (bug) i relatert til JavaScript-instillingane peiying16Contrib3=Støtte for redigering av SVG-filer direkte i redigeraren (editor) omytryniukContrib1=Gjer den innebyde bildevisaren betre diff --git a/locales/te/server.properties b/locales/te/server.properties index 858651ea3..6a6ea3119 100644 --- a/locales/te/server.properties +++ b/locales/te/server.properties @@ -24,6 +24,7 @@ pageTitleGetInvolved=Mozilla వారి Thimble లో పల్గొనం # Userbar # Reload Preview Page +errorCantLoadPreviewTitle=అయ్యో, ఎదో తప్పు జరిగింది! ############ ## Editor ## diff --git a/locales/zh-CN/editor.properties b/locales/zh-CN/editor.properties index 1d887e052..2ef160292 100644 --- a/locales/zh-CN/editor.properties +++ b/locales/zh-CN/editor.properties @@ -202,6 +202,9 @@ BINARY_FILE_DOWNLOAD=下载它 BINARY_FILE_OPEN=在新标签页中打开它 BINARY_FILE_TRY_EDIT=尝试编辑它 +#PDF Viewer +PDF_FILE_TITLE=PDF 文件 + ################ ## EXTENSIONS ## ################ diff --git a/locales/zh-CN/server.properties b/locales/zh-CN/server.properties index 316315bbe..3b4baada7 100644 --- a/locales/zh-CN/server.properties +++ b/locales/zh-CN/server.properties @@ -25,17 +25,22 @@ pageTitleFeatures=Mozilla Thimble - 功能 # Userbar signInPromptHomepage= +# Reload Preview Page +errorCantLoadPreviewTitle=哦!好像出错了! +errorCantLoadPreview=我们无法载入预览,请重新载入页面后再试一次... +reloadButtonLabel=重新载入 + ############ ## Editor ## ############ # Loading the editor -loadingProject=正在加载项目 -loadingProjectSupportSuggestion=如果项目未加载,到这里获取帮助。 +loadingProject=正在载入项目 +loadingProjectSupportSuggestion=如果项目未载入,到这里获取帮助。 reloadThimbleMessage=请重新载入 Thimble 以重试。 errorCouldNotStart=Thimble 无法启动。 -errorLoadingProject=加载您的项目时出错。
请刷新您的浏览器。 -errorLoadingProjectSuggestion=注意,如果您在使用隐私浏览模式,请试试在普通模式中加载。 +errorLoadingProject=载入您的项目时出错。
请刷新您的浏览器。 +errorLoadingProjectSuggestion=注意,如果您在使用隐私浏览模式,请试试在普通模式中载入。 errorUnsupportedBrowser=很抱歉,Thimble 不适用您的浏览器 errorUnsupportedBrowserSuggestion1=Thimble 可以在下列浏览器中正常运行:FirefoxChrome、Internet Explorer 11, Microsoft Edge、Safari (8+) 及 Opera。 errorUnsupportedBrowserIgnore=但我还想试试! @@ -78,7 +83,7 @@ navAllowJS=允许 JavaScript navAllowWS=显示空白 navAutoComplete=自动完成代码 navAutoEncloseTags=自动关闭标签 -navXMLSVG=XML/SVG +navSVGedit=用代码编辑 SVG 图像 navPreview=预览 navViewTutorial=教程 navToggleAutoUpdateTitle=切换自动刷新预览 @@ -228,7 +233,7 @@ deleteProjects=删除项目 ## Features page ## ################### -featuresHeader=绝佳的功能使编写代码
的学习教学更加轻松和有趣 +featuresHeader=绝佳的功能使学习
教授编写代码简单而有趣 featuresCallout=Thimble 是一个可以在浏览器中运行的全功能代码编辑器。它旨在帮助新手编程人员使用 HTML、CSS 和 JavaScript 创建自己的网站和基于 Web 的项目。您需要的一切都在您的指尖,让您(或您的课堂)快速部署和运行。 featuresCalloutDesc=它将代码编辑器、网页服务器、网页浏览器和开发者工具合而为一,而且它还是免费的! @@ -280,7 +285,7 @@ contributeReason3=支持 Mozilla 的使命,为所有人建立开放的互联 contributeReason4=感觉很棒! getInvolvedDescription1=Thimble 是 Mozilla 基金会塞内卡大学开放技术开发中心 联合创建的一个开源项目。自创立以来,来自全世界的贡献者为项目的成功发挥了重要作用。 getInvolvedDescription2=这是一个真正的国际项目,它 已被翻译为 33 种语言(并有超过 100 种语言正在翻译),且 有超过 200 多个国家/地区的学习者。 -noContributionTooSmallTitle=没有贡献微不足道 +noContributionTooSmallTitle=再小的贡献也足以称道 noContributionTooSmallDesc=我们欢迎所有技能水平与职业背景的贡献者。你不必是一个专业程序员,事实上,超过一半贡献者标识自己为学生。你可以从小事开始,比如填报一个问题… noContributionTooSmallReason1=报告缺陷、问题或拼写错误 noContributionTooSmallReason2=请求更改、新功能或新项目 @@ -308,20 +313,25 @@ raygervaisQuote=“在向 Thimble 的过程中我了解了现代的 JavaScript hkiratContrib1=已创建一个自定义界面来编辑 A 帧标签的参数 hkiratContrib2=代码完成已是可选设置 hkiratContrib3=研究合作编辑的技术方法 +hkiratQuote=“在 Thimble 的工作经历很有意义。他们的代码写得很好,导师也非常热心。如果你想开始在开源领域做点事,这个项目不错,贡献的过程中我还知道了很多开源的最佳实践。“ cgsinghContrib1=已添加描述到项目页面 cgsinghContrib2=自动闭合标签已成为可选设置 cgsinghContrib3=修复一个发布按钮的长期可用性问题 -peiying16Contrib1=已添加文件图标支持 +cgsinghQuote=“最开始来 Thimble 的时候我还挺担心的。但我开始做贡献后,一切逐渐变得还算满意。在我通常不愿接触的领域 — Web 开发上我学到了很多。做开源开发时,我从不觉得孤单。把这么多天才的想法聚集起来,让像 Thimble 这样伟大的产品才诞生了。“ +peiying16Contrib1fix=在文件列表中添加文件图标对应关系 peiying16Contrib2=修复 JavaScript 设置相关的问题 peiying16Contrib3=支持在编辑器中编辑 SVG 文件 peiying16Quote=“我爱 Thimble,我也喜欢与 Thimble 团队修复 bug。” th30Contrib1=已更新菜单过渡效果 th30Contrib2=确保文件在编辑器中正确突出显示 +th30Quote=“Thimble 的工作的确是进入开源领域具有挑战性和爆炸性的途径。它真的让我有机会能跟许多才华横溢的人合作共事,在这工作,犯错误不过是改进自我的宝贵机会。坚持是关键,还一定要对宝贵的改进机会做出反应!” omytryniukContrib1=改进内置的图像查看器界面 omytryniukContrib2=已增加数个界面改进和修复一些前端样式和功能的问题 omytryniukContrib3=已更新 Thimble 项目中的节点依赖关系 +omytryniukQuote=“对我来说,使用Thimble不仅能获得宝贵的编程经验,还能有强烈的成就感,并且你参与设计的产品会在世界各地使用。我写的程序能够造福数百万人,意识到这一点使我在Thimble的工作充满动力。项目团队友好、积极的氛围是令我享受在Thimble这个开放源代码平台工作的另一原因。” timmoyContrib1=已修复与预览面板上的自动刷新设置相关的错误 — 它现在会记住浏览器刷新时的设置 timmoyContrib2=已添加功能,可以为项目中的图像添加滤镜 +timmoyQuote=“来到Thimble之前,我独自或者跟团队一起编写相对小规模的程序。而现在,我写的代码分布于300多人一起工作的成百上千个文件之中,这确实让我大开眼界,令我认识到竟能如此“与他人合作”。我发现适应这里的环境需要经历学习曲线,但在这里总有友好的人帮助我入门,克服一路重重障碍。仅数月之后,我就有能力为社群做出超出自己预期的贡献了。开放源代码的持续发展会让我们一起创造无限可能!” ############ ## Shared ## diff --git a/package.json b/package.json index d6d9be905..f03bb958f 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,7 @@ "devDependencies": { "eslint": "^4.6.1", "eslint-plugin-prettier": "^2.2.0", + "is-reachable":"^2.3.3", "prettier": "^1.6.1", "shx": "^0.2.2", "stylelint": "^8.1.1", diff --git a/public/editor/scripts/ui/menus.js b/public/editor/scripts/ui/menus.js index 88dec7f1e..6246f2ad7 100644 --- a/public/editor/scripts/ui/menus.js +++ b/public/editor/scripts/ui/menus.js @@ -163,7 +163,7 @@ function setupOptionsMenu(bramble) { setWordWrapUI(value); }); } - $("#line-wrap-toggle").click(function() { + $("#editor-option-wraptext").click(function() { // Toggle current value setWordWrap(!bramble.getWordWrap()); var mode = !bramble.getWordWrap() ? "Enabled" : "Disabled"; @@ -191,7 +191,7 @@ function setupOptionsMenu(bramble) { } // Enable/Disable JavaScript in Preview - $("#allow-scripts-toggle").click(function() { + $("#editor-option-allowjs").click(function() { // Toggle current value var $allowScriptsToggle = $("#allow-scripts-toggle"); var toggle = !$allowScriptsToggle.hasClass("switch-enabled"); @@ -223,8 +223,9 @@ function setupOptionsMenu(bramble) { } else { $("#allow-whitespace-toggle").removeClass("switch-enabled"); } + // Enable/Disable Whitespace Indicator - $("#allow-whitespace-toggle").click(function() { + $("#editor-option-allowws").click(function() { // Toggle current value var $allowWhitespaceToggle = $("#allow-whitespace-toggle"); var toggle = !$allowWhitespaceToggle.hasClass("switch-enabled"); @@ -246,8 +247,9 @@ function setupOptionsMenu(bramble) { } else { $("#autocomplete-toggle").removeClass("switch-enabled"); } + // Enable/Disable Autocomplete - $("#autocomplete-toggle").click(function() { + $("#editor-option-autocomplete").click(function() { // Toggle current value var $autocompleteToggle = $("#autocomplete-toggle"); var toggle = !$autocompleteToggle.hasClass("switch-enabled"); @@ -264,7 +266,7 @@ function setupOptionsMenu(bramble) { }); //Edit SVG as XML - $("#edit-SVG-toggle").click(function() { + $("#editor-option-svgedit").click(function() { // Toggle current value var $editSVGToggle = $("#edit-SVG-toggle"); var toggle = !$editSVGToggle.hasClass("switch-enabled"); @@ -288,7 +290,7 @@ function setupOptionsMenu(bramble) { $("#auto-tags-toggle").removeClass("switch-enabled"); } - $("#auto-tags-toggle").click(function() { + $("#editor-option-autoenclosetags").click(function() { var $autoTagsToggle = $("#auto-tags-toggle"); var autoCloseTagsEnabled = $autoTagsToggle.hasClass("switch-enabled"); @@ -376,8 +378,7 @@ function setupOptionsMenu(bramble) { }); } } - $("#theme-light").click(toggleTheme); - $("#theme-dark").click(toggleTheme); + $("#editor-option-colortheme").click(toggleTheme); // If the user explicitly set the light-theme last time, use that // otherwise default to using the dark-theme. diff --git a/views/editor/nav-options.html b/views/editor/nav-options.html index 0720e5f50..7687c6fc8 100644 --- a/views/editor/nav-options.html +++ b/views/editor/nav-options.html @@ -112,14 +112,14 @@

{{ gettext("snippetMenuTitle") }}

    -
  • +
  • {{ gettext("navTextSize") }}
  • -
  • +
  • {{ gettext("navColorTheme") }}
    @@ -133,42 +133,42 @@

    {{ gettext("snippetMenuTitle") }}

-
  • +
  • {{ gettext("navWrapText") }}
  • -
  • +
  • {{ gettext("navAllowJS") }}
  • -
  • +
  • {{ gettext("navAllowWS") }}
  • -
  • +
  • {{ gettext("navAutoEncloseTags") }}
  • -
  • +
  • {{ gettext("navAutoComplete") }}
  • -
  • +
  • {{ gettext("navSVGedit") }}
    From 9f58b2b4220774a783679722339f70cb2fb94779 Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Tue, 17 Oct 2017 15:51:21 -0400 Subject: [PATCH 04/14] Fixing #2479 WIP commented out Cancel button, added non-working click-underlay logic (commented out, may help with review) --- public/editor/scripts/ui/publisher.js | 12 ++++++++---- public/editor/stylesheets/editor.less | 6 +++++- public/editor/stylesheets/publish.less | 15 +-------------- views/editor/publish.html | 2 +- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/public/editor/scripts/ui/publisher.js b/public/editor/scripts/ui/publisher.js index 9bed9d43b..f314fb35e 100644 --- a/public/editor/scripts/ui/publisher.js +++ b/public/editor/scripts/ui/publisher.js @@ -29,7 +29,6 @@ function Publisher() { buttons: { publish: $("#publish-button-publish"), update: $("#publish-button-update"), - saveDescription: $("#publish-button-cancel"), unpublish: $("#publish-button-unpublish"), parent: $("#publish-buttons"), indexMessage: $("#no-index") @@ -43,6 +42,9 @@ function Publisher() { }; this.dialogEl = $("#publish-dialog"); this.button = $("#navbar-publish-button"); + + //1 - This does not seem to work... + //this.underlay = $("#click-underlay"); } Publisher.prototype.init = function(bramble) { @@ -50,6 +52,7 @@ Publisher.prototype.init = function(bramble) { var dialog = publisher.dialog; var publishUrl = Project.getPublishUrl(); + publisher.isProjectPublic = true; publisher.needsUpdate = false; publisher.handlers = { @@ -82,9 +85,10 @@ Publisher.prototype.init = function(bramble) { //saves the description and displays message to user telling them they have made changes //and suggesting they should publish their project. - dialog.buttons.saveDescription.on("click", publisher.handlers.setDescription); - //$("#click-underlay").on("click", publisher.handlers.setDesc); - + + //2 - THIS DOES NOT WORK - how can we implement setDescription by + //clicking the underlay? + //publisher.underlay.on("click", publisher.handlers.setDescription); dialog.buttons.publish.on("click", publisher.handlers.publish); diff --git a/public/editor/stylesheets/editor.less b/public/editor/stylesheets/editor.less index 6ae028ece..cabe1ea65 100755 --- a/public/editor/stylesheets/editor.less +++ b/public/editor/stylesheets/editor.less @@ -536,6 +536,11 @@ body { padding: 20px 100px 20px 20px; position: relative; color: rgba(0, 0, 0, 0.6); + cursor: pointer; + } + + #editor-option-textsize { + cursor: default; } li + li { @@ -564,7 +569,6 @@ body { height: 30px; width: 60px; top: 16px; - cursor: pointer; &.switch-enabled { .toggle-backing { diff --git a/public/editor/stylesheets/publish.less b/public/editor/stylesheets/publish.less index 7b448cce9..3474fbeb7 100644 --- a/public/editor/stylesheets/publish.less +++ b/public/editor/stylesheets/publish.less @@ -150,20 +150,7 @@ font-weight: 600; } } - - #publish-button-cancel { - background-color: #b0b0b0; - .publish-button; - .grey-button; - - &:hover { - background-color: #bcbcbc; - } - - &:active { - background-color: #9b9b9b; - } - } + } #publish-details { diff --git a/views/editor/publish.html b/views/editor/publish.html index 357d4d3a5..d9fa100c9 100644 --- a/views/editor/publish.html +++ b/views/editor/publish.html @@ -37,7 +37,7 @@

    {{ gettext("publishHeader") }}

    {% set learnMoreURL = "https://github.com/mozilla/thimble.mozilla.org/wiki/Using-Thimble-FAQ#why-do-i-need-an-indexhtml-file-when-publishing-my-project" %}
    {{ gettext("noIndexFound") | instantiate | safe }}
    -
    {{ gettext("publishCancelBtn") }}
    +
    {{ gettext("publishBtn") }}
    From cae4f1d8937f517cfaff834b978a5c3cf5b5c380 Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Tue, 17 Oct 2017 17:21:06 -0400 Subject: [PATCH 05/14] Fixing #2479 Cancel button has been removed from UI. To save the description, all a user needs to do is click outside the dialog box. This works whether the project is published or unpublished. --- public/editor/scripts/ui/index.js | 4 ++++ public/editor/scripts/ui/publisher.js | 28 +++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/public/editor/scripts/ui/index.js b/public/editor/scripts/ui/index.js index fc2e7eaec..4b03a0c51 100644 --- a/public/editor/scripts/ui/index.js +++ b/public/editor/scripts/ui/index.js @@ -443,6 +443,10 @@ function init(bramble, csrfToken, appUrl) { _escKeyHandler.stop(); _escKeyHandler = null; + + //Calling function in public/editor/ui/publisher.js + //When user clicks outside the dialog box, description is saved + publisher.handlers.setDescription(); } function showPublishDialog() { publishDialogUnderlay = new Underlay("#publish-dialog", hidePublishDialog); diff --git a/public/editor/scripts/ui/publisher.js b/public/editor/scripts/ui/publisher.js index f314fb35e..d22897006 100644 --- a/public/editor/scripts/ui/publisher.js +++ b/public/editor/scripts/ui/publisher.js @@ -42,9 +42,6 @@ function Publisher() { }; this.dialogEl = $("#publish-dialog"); this.button = $("#navbar-publish-button"); - - //1 - This does not seem to work... - //this.underlay = $("#click-underlay"); } Publisher.prototype.init = function(bramble) { @@ -83,13 +80,6 @@ Publisher.prototype.init = function(bramble) { publisher.showUnpublishedChangesPrompt(); }); - //saves the description and displays message to user telling them they have made changes - //and suggesting they should publish their project. - - //2 - THIS DOES NOT WORK - how can we implement setDescription by - //clicking the underlay? - //publisher.underlay.on("click", publisher.handlers.setDescription); - dialog.buttons.publish.on("click", publisher.handlers.publish); // Were there any files that were updated and not published? @@ -143,10 +133,17 @@ Publisher.prototype.showUnpublishedChangesPrompt = function(callback) { }; //Using generateRequest("unpublish") in order to sync description -//throws error since nothing is being unpublished, however request -//to save description. This is currently a "hack" until further notice +//throws error since nothing is being unpublished, however this works +//to save description. This is currently a "hack", a more elegant +//solution may be implemented after Publisher.prototype.setDescription = function() { var publisher = this; + + //We don't want to unpublish something that is published + var action = "unpublish"; + if(Project.getPublishUrl()){ + var action = "publish"; + } SyncState.syncing(); @@ -157,7 +154,7 @@ Publisher.prototype.setDescription = function() { Accept: "application/json" }, type: "PUT", - url: host + "/projects/" + Project.getID() + "/unpublish", + url: host + "/projects/" + Project.getID() + "/" + action, data: JSON.stringify({ description: publisher.dialog.description.val() || " ", public: publisher.isProjectPublic, @@ -165,11 +162,11 @@ Publisher.prototype.setDescription = function() { }) }); - //expected to fail because an unpublished project can't be unpublished + //publishing/unpublishing an already published/unpublished project is expected to fail //doing this for now until we can send an ajax request to UPDATE only request.fail(function(jqXHR, status, err) { console.error( - "[Thimble] Failed to send request to unpublish project to the server with: ", + "[Thimble] Failed to send request to", action, "project to the server with: ", err, "but description is now updated" ); }); @@ -333,6 +330,7 @@ Publisher.prototype.unpublish = function() { request.always(function() { SyncState.completed(); publisher.unpublishing = false; + publickCheck = false; setState(true); }); }; From b9235528a65b250493eb7c08239e29f767d81b78 Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Wed, 18 Oct 2017 17:03:05 -0400 Subject: [PATCH 06/14] Fixing #2479 Spacing --- public/editor/scripts/ui/publisher.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/public/editor/scripts/ui/publisher.js b/public/editor/scripts/ui/publisher.js index d22897006..d3a42d734 100644 --- a/public/editor/scripts/ui/publisher.js +++ b/public/editor/scripts/ui/publisher.js @@ -49,7 +49,6 @@ Publisher.prototype.init = function(bramble) { var dialog = publisher.dialog; var publishUrl = Project.getPublishUrl(); - publisher.isProjectPublic = true; publisher.needsUpdate = false; publisher.handlers = { @@ -138,10 +137,9 @@ Publisher.prototype.showUnpublishedChangesPrompt = function(callback) { //solution may be implemented after Publisher.prototype.setDescription = function() { var publisher = this; - - //We don't want to unpublish something that is published var action = "unpublish"; - if(Project.getPublishUrl()){ + + if( Project.getPublishUrl() ){ var action = "publish"; } @@ -166,17 +164,18 @@ Publisher.prototype.setDescription = function() { //doing this for now until we can send an ajax request to UPDATE only request.fail(function(jqXHR, status, err) { console.error( - "[Thimble] Failed to send request to", action, "project to the server with: ", - err, "but description is now updated" + "[Thimble] Failed to send request to", + action, + "project to the server with: ", + err, + "but description is now updated" ); }); request.always(function() { SyncState.completed(); - }); - + }); }; - Publisher.prototype.publish = function(bramble) { var publisher = this; var dialog = publisher.dialog; From 4de70ee382636a7503a28e53c362c029f093d038 Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Wed, 18 Oct 2017 17:07:34 -0400 Subject: [PATCH 07/14] Fix #2479 Fixing spacing issues --- public/editor/scripts/ui/publisher.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/editor/scripts/ui/publisher.js b/public/editor/scripts/ui/publisher.js index d3a42d734..ad593a18c 100644 --- a/public/editor/scripts/ui/publisher.js +++ b/public/editor/scripts/ui/publisher.js @@ -139,7 +139,7 @@ Publisher.prototype.setDescription = function() { var publisher = this; var action = "unpublish"; - if( Project.getPublishUrl() ){ + if (Project.getPublishUrl()) { var action = "publish"; } @@ -164,16 +164,16 @@ Publisher.prototype.setDescription = function() { //doing this for now until we can send an ajax request to UPDATE only request.fail(function(jqXHR, status, err) { console.error( - "[Thimble] Failed to send request to", - action, + "[Thimble] Failed to send request to", + action, "project to the server with: ", - err, + err, "but description is now updated" ); }); request.always(function() { SyncState.completed(); - }); + }); }; Publisher.prototype.publish = function(bramble) { From 6f3072384b0e334d98684032f89b1e31dbb6da27 Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Wed, 18 Oct 2017 17:14:05 -0400 Subject: [PATCH 08/14] Fixing #2479 Code cleanup --- public/editor/scripts/ui/publisher.js | 1 - public/editor/stylesheets/publish.less | 1 - 2 files changed, 2 deletions(-) diff --git a/public/editor/scripts/ui/publisher.js b/public/editor/scripts/ui/publisher.js index ad593a18c..0766996d6 100644 --- a/public/editor/scripts/ui/publisher.js +++ b/public/editor/scripts/ui/publisher.js @@ -138,7 +138,6 @@ Publisher.prototype.showUnpublishedChangesPrompt = function(callback) { Publisher.prototype.setDescription = function() { var publisher = this; var action = "unpublish"; - if (Project.getPublishUrl()) { var action = "publish"; } diff --git a/public/editor/stylesheets/publish.less b/public/editor/stylesheets/publish.less index 3474fbeb7..406feb1a5 100644 --- a/public/editor/stylesheets/publish.less +++ b/public/editor/stylesheets/publish.less @@ -150,7 +150,6 @@ font-weight: 600; } } - } #publish-details { From 10b87862cb7952b277ec74e8e97fc0541ed64a53 Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Fri, 20 Oct 2017 15:40:17 -0400 Subject: [PATCH 09/14] Fixing #2479 WIP --- public/editor/scripts/ui/index.js | 2 +- public/editor/scripts/ui/publisher.js | 38 +++++++++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/public/editor/scripts/ui/index.js b/public/editor/scripts/ui/index.js index 4b03a0c51..2480e3230 100644 --- a/public/editor/scripts/ui/index.js +++ b/public/editor/scripts/ui/index.js @@ -446,7 +446,7 @@ function init(bramble, csrfToken, appUrl) { //Calling function in public/editor/ui/publisher.js //When user clicks outside the dialog box, description is saved - publisher.handlers.setDescription(); + publisher.handlers.saveDescription(); } function showPublishDialog() { publishDialogUnderlay = new Underlay("#publish-dialog", hidePublishDialog); diff --git a/public/editor/scripts/ui/publisher.js b/public/editor/scripts/ui/publisher.js index 0766996d6..149d858e6 100644 --- a/public/editor/scripts/ui/publisher.js +++ b/public/editor/scripts/ui/publisher.js @@ -5,6 +5,7 @@ var strings = require("strings"); var Project = require("../project"); var FileSystemSync = require("../filesystem-sync"); var SyncState = require("../filesystem-sync/state"); +var Metadata = require("../project/metadata.js"); var host; @@ -54,7 +55,7 @@ Publisher.prototype.init = function(bramble) { publisher.handlers = { publish: publisher.publish.bind(publisher, bramble), unpublish: publisher.unpublish.bind(publisher), - setDescription: publisher.setDescription.bind(publisher), + saveDescription: publisher.saveDescription.bind(publisher), unpublishedChangesPrompt: unpublishedChangesPrompt.bind(publisher) }; @@ -131,12 +132,8 @@ Publisher.prototype.showUnpublishedChangesPrompt = function(callback) { }); }; -//Using generateRequest("unpublish") in order to sync description -//throws error since nothing is being unpublished, however this works -//to save description. This is currently a "hack", a more elegant -//solution may be implemented after -Publisher.prototype.setDescription = function() { - var publisher = this; +Publisher.prototype.saveDescription = function() { + /*var publisher = this; var action = "unpublish"; if (Project.getPublishUrl()) { var action = "publish"; @@ -172,6 +169,32 @@ Publisher.prototype.setDescription = function() { }); request.always(function() { SyncState.completed(); + });*/ + + const publisher = this; + const oldDescription = Project.getDescription(); + const description = publisher.dialog.description.val(); + + if(oldDescription === description) { + return; + } + + Project.setDescription(description); + + const data = { + title: Project.getTitle(), + description, + dateUpdated: new Date().toISOString() + }; + + Metadata.update({ + update: true, + csrfToken: publisher.csrfToken, + host: Project.getHost(), + id: Project.getID(), + data + }, error => { + console.error("[Thimble] Failed to update project description with: ", error); }); }; @@ -328,7 +351,6 @@ Publisher.prototype.unpublish = function() { request.always(function() { SyncState.completed(); publisher.unpublishing = false; - publickCheck = false; setState(true); }); }; From db1a1ee29332876752805e367b43a856fbe1c592 Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Fri, 20 Oct 2017 16:30:03 -0400 Subject: [PATCH 10/14] Fixing #2479 WIP Spacing --- public/editor/scripts/ui/publisher.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/public/editor/scripts/ui/publisher.js b/public/editor/scripts/ui/publisher.js index 149d858e6..75a015d4f 100644 --- a/public/editor/scripts/ui/publisher.js +++ b/public/editor/scripts/ui/publisher.js @@ -175,7 +175,7 @@ Publisher.prototype.saveDescription = function() { const oldDescription = Project.getDescription(); const description = publisher.dialog.description.val(); - if(oldDescription === description) { + if (oldDescription === description) { return; } @@ -188,14 +188,17 @@ Publisher.prototype.saveDescription = function() { }; Metadata.update({ + update: true, csrfToken: publisher.csrfToken, host: Project.getHost(), id: Project.getID(), data - }, error => { - console.error("[Thimble] Failed to update project description with: ", error); - }); + + }, + error => { + console.error("[Thimble] Failed to update project description with: ", error); + }); }; Publisher.prototype.publish = function(bramble) { From fbf8384872bd9b0cfa4909127f8c0540ec6659a9 Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Fri, 20 Oct 2017 16:39:19 -0400 Subject: [PATCH 11/14] Fixing #2479 --- public/editor/scripts/ui/publisher.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/public/editor/scripts/ui/publisher.js b/public/editor/scripts/ui/publisher.js index 75a015d4f..f33af4d06 100644 --- a/public/editor/scripts/ui/publisher.js +++ b/public/editor/scripts/ui/publisher.js @@ -187,18 +187,19 @@ Publisher.prototype.saveDescription = function() { dateUpdated: new Date().toISOString() }; - Metadata.update({ - - update: true, - csrfToken: publisher.csrfToken, - host: Project.getHost(), - id: Project.getID(), - data - - }, + Metadata.update( + { + update: true, + csrfToken: publisher.csrfToken, + host: Project.getHost(), + id: Project.getID(), + data + }, error => { - console.error("[Thimble] Failed to update project description with: ", error); - }); + console.error("[Thimble] Failed to update project description with: ", + error + ); + }); }; Publisher.prototype.publish = function(bramble) { From 2b0ce8a8b9658e4718e25345306ccb79dc432ca7 Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Fri, 20 Oct 2017 16:44:36 -0400 Subject: [PATCH 12/14] Fixing #2479 Travis CI spacing --- public/editor/scripts/ui/publisher.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/editor/scripts/ui/publisher.js b/public/editor/scripts/ui/publisher.js index f33af4d06..e31cf6274 100644 --- a/public/editor/scripts/ui/publisher.js +++ b/public/editor/scripts/ui/publisher.js @@ -196,10 +196,12 @@ Publisher.prototype.saveDescription = function() { data }, error => { - console.error("[Thimble] Failed to update project description with: ", + + console.error("[Thimble] Failed to update project description with: ", error ); - }); + } + ); }; Publisher.prototype.publish = function(bramble) { From b9a8f69b838e1a7ecfd4bcbdb2591a0342ebce77 Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Fri, 20 Oct 2017 16:50:13 -0400 Subject: [PATCH 13/14] Fixing #2479 - Travis CI --- public/editor/scripts/ui/publisher.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/public/editor/scripts/ui/publisher.js b/public/editor/scripts/ui/publisher.js index e31cf6274..245adc018 100644 --- a/public/editor/scripts/ui/publisher.js +++ b/public/editor/scripts/ui/publisher.js @@ -196,8 +196,7 @@ Publisher.prototype.saveDescription = function() { data }, error => { - - console.error("[Thimble] Failed to update project description with: ", + console.error("[Thimble] Failed to update project description with: ", error ); } From 91b7f57236432f9bd09689291d22f0e03c751c2c Mon Sep 17 00:00:00 2001 From: jmrodriguesgoncalves Date: Fri, 20 Oct 2017 16:55:34 -0400 Subject: [PATCH 14/14] Fixing #2479 - Travis CI --- public/editor/scripts/ui/publisher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/editor/scripts/ui/publisher.js b/public/editor/scripts/ui/publisher.js index 245adc018..0a5ffb14f 100644 --- a/public/editor/scripts/ui/publisher.js +++ b/public/editor/scripts/ui/publisher.js @@ -196,7 +196,7 @@ Publisher.prototype.saveDescription = function() { data }, error => { - console.error("[Thimble] Failed to update project description with: ", + console.error("[Thimble] Failed to update project description with: ", error ); }