From f6ece2d63e5fb4cdce89c57b19d347565a88459d Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Mon, 10 Mar 2014 12:16:08 +0100 Subject: [PATCH 01/24] Created a modal version of Version History --- app/templates/editor/level/edit.jade | 4 ++- app/templates/editor/level/versions.jade | 15 ++++++++++ app/templates/kinds/versions.jade | 33 ++++++++++++--------- app/views/editor/level/edit.coffee | 7 +++++ app/views/editor/level/versions_view.coffee | 9 ++++++ 5 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 app/templates/editor/level/versions.jade create mode 100644 app/views/editor/level/versions_view.coffee diff --git a/app/templates/editor/level/edit.jade b/app/templates/editor/level/edit.jade index 7d2c7ac66..ef788fe3e 100644 --- a/app/templates/editor/level/edit.jade +++ b/app/templates/editor/level/edit.jade @@ -38,9 +38,11 @@ block outer_content li.dropdown a.dropdown-toggle(href='#', data-toggle='dropdown') - | Help + | More b.caret ul.dropdown-menu + li#version-history-button + a(href='#') Version History li a(href='https://github.com/codecombat/codecombat/wiki/Artisan-Home') Wiki li diff --git a/app/templates/editor/level/versions.jade b/app/templates/editor/level/versions.jade new file mode 100644 index 000000000..652a6b7c5 --- /dev/null +++ b/app/templates/editor/level/versions.jade @@ -0,0 +1,15 @@ +extends /templates/modal/modal_base +include /templates/kinds/versions + +prepend modal-header + - var closeButton = true + +block modal-header-content + h3 Version History + +block modal-body-content + if dataList + +version-history-body() + +block modal-footer-content + button.close.btn(data-dismiss="modal", data-i18n="common.cancel") Cancel \ No newline at end of file diff --git a/app/templates/kinds/versions.jade b/app/templates/kinds/versions.jade index 274e91513..a7db6039f 100755 --- a/app/templates/kinds/versions.jade +++ b/app/templates/kinds/versions.jade @@ -1,19 +1,24 @@ extends /templates/base +mixin version-history-title() + h3(data-i18n="general.version_history_for") Version History for: #{dataList[0]} + +mixin version-history-body() + table.table + tr + th(data-i18n="general.name") Name + th(data-i18n="general.version") Version + th(data-i18n="general.commit_msg") Commit Message + for data in dataList + tr + td + a(href="/editor/#{page}/#{data.slug || data._id}") + | #{data.name} + td #{data.version.major}.#{data.version.minor} + td #{data.commitMessage} + block content if dataList - h3(data-i18n="general.version_history_for") Version History for: "#{dataList[0].name}" + +version-history-title() - table.table - tr - th(data-i18n="general.name") Name - th(data-i18n="general.version") Version - th(data-i18n="general.commit_msg") Commit Message - - for data in dataList - tr - td - a(href="/editor/#{page}/#{data.slug || data._id}") - | #{data.name} - td #{data.version.major}.#{data.version.minor} - td #{data.commitMessage} + +version-history-body() \ No newline at end of file diff --git a/app/views/editor/level/edit.coffee b/app/views/editor/level/edit.coffee index 962db3fac..4f1ceee85 100644 --- a/app/views/editor/level/edit.coffee +++ b/app/views/editor/level/edit.coffee @@ -12,6 +12,7 @@ ComponentsTabView = require './components_tab_view' SystemsTabView = require './systems_tab_view' LevelSaveView = require './save_view' LevelForkView = require './fork_view' +VersionHistoryView = require './versions_view' module.exports = class EditorLevelView extends View id: "editor-level-view" @@ -23,6 +24,7 @@ module.exports = class EditorLevelView extends View 'click #play-button': 'onPlayLevel' 'click #commit-level-start-button': 'startCommittingLevel' 'click #fork-level-start-button': 'startForkingLevel' + 'click #version-history-button': 'showVersionHistory' constructor: (options, @levelID) -> super options @@ -102,3 +104,8 @@ module.exports = class EditorLevelView extends View levelForkView = new LevelForkView level: @level @openModalView levelForkView Backbone.Mediator.publish 'level:view-switched', e + + showVersionHistory: (e) -> + versionHistoryView = new VersionHistoryView level:@level, @levelID + @openModalView versionHistoryView + Backbone.Mediator.publish 'level:view-switched', e \ No newline at end of file diff --git a/app/views/editor/level/versions_view.coffee b/app/views/editor/level/versions_view.coffee new file mode 100644 index 000000000..4fb2b3690 --- /dev/null +++ b/app/views/editor/level/versions_view.coffee @@ -0,0 +1,9 @@ +SuperVersionsView = require './versions' +template = require 'templates/editor/level/versions' + +module.exports = class ModalVersionsView extends SuperVersionsView + id: 'version-history-modal' + template: template + + constructor: (options, @ID) -> + super options, ID \ No newline at end of file From 06ae06fa340078fa249047e7384447726b391b1c Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Mon, 10 Mar 2014 19:08:53 +0100 Subject: [PATCH 02/24] Used mix-ins to combine Modal and VersionView --- app/templates/editor/level/versions.jade | 6 +---- app/views/editor/level/versions_view.coffee | 27 ++++++++++++++++++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/app/templates/editor/level/versions.jade b/app/templates/editor/level/versions.jade index 652a6b7c5..87748e109 100644 --- a/app/templates/editor/level/versions.jade +++ b/app/templates/editor/level/versions.jade @@ -1,9 +1,6 @@ extends /templates/modal/modal_base include /templates/kinds/versions -prepend modal-header - - var closeButton = true - block modal-header-content h3 Version History @@ -11,5 +8,4 @@ block modal-body-content if dataList +version-history-body() -block modal-footer-content - button.close.btn(data-dismiss="modal", data-i18n="common.cancel") Cancel \ No newline at end of file +block modal-footer-content \ No newline at end of file diff --git a/app/views/editor/level/versions_view.coffee b/app/views/editor/level/versions_view.coffee index 4fb2b3690..39af46ae4 100644 --- a/app/views/editor/level/versions_view.coffee +++ b/app/views/editor/level/versions_view.coffee @@ -1,9 +1,30 @@ -SuperVersionsView = require './versions' +VersionsView = require 'views/kinds/VersionsView' +ModalView = require 'views/kinds/ModalView' template = require 'templates/editor/level/versions' -module.exports = class ModalVersionsView extends SuperVersionsView +module.exports = class ModalVersionsView extends VersionsView id: 'version-history-modal' + url: "/db/level/" + page: "level" template: template + className: "modal fade" + closeButton: true + closesOnClickOutside: true + modalWidthPercent: null + + shortcuts: + 'esc': 'hide' + constructor: (options, @ID) -> - super options, ID \ No newline at end of file + super options, ID, require 'models/Level' + _.extend @, ModalView + ModalView.prototype.constructor options + + getRenderData: (context={}) -> + context = super(context) + context.closeButton = true + context + + hide: -> + @$el.removeClass('fade').modal "hide" \ No newline at end of file From 29901787f73a01e4cc64a1a6fa7d43e89d839d05 Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Mon, 10 Mar 2014 19:11:37 +0100 Subject: [PATCH 03/24] Added i18n for Version History --- app/locale/en.coffee | 1 + app/locale/nl.coffee | 1 + app/templates/editor/level/versions.jade | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/locale/en.coffee b/app/locale/en.coffee index 2afc376cd..c4dd578e4 100644 --- a/app/locale/en.coffee +++ b/app/locale/en.coffee @@ -264,6 +264,7 @@ module.exports = nativeDescription: "English", englishDescription: "English", tr body: "Body" version: "Version" commit_msg: "Commit Message" + version_history: "Version History" version_history_for: "Version History for: " results: "Results" description: "Description" diff --git a/app/locale/nl.coffee b/app/locale/nl.coffee index 929741d23..831161810 100644 --- a/app/locale/nl.coffee +++ b/app/locale/nl.coffee @@ -264,6 +264,7 @@ module.exports = nativeDescription: "Nederlands", englishDescription: "Dutch", t body: "Inhoud" version: "Versie" commit_msg: "Commit Bericht" + version_history: "Versie geschiedenis" version_history_for: "Versie geschiedenis voor: " results: "Resultaten" description: "Beschrijving" diff --git a/app/templates/editor/level/versions.jade b/app/templates/editor/level/versions.jade index 87748e109..b40c7b6f0 100644 --- a/app/templates/editor/level/versions.jade +++ b/app/templates/editor/level/versions.jade @@ -2,7 +2,7 @@ extends /templates/modal/modal_base include /templates/kinds/versions block modal-header-content - h3 Version History + h3(data-i18n="general.version_history") Version History block modal-body-content if dataList From 68b10d9023f2b7e86d427ce2505400d0978350c5 Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Mon, 10 Mar 2014 20:06:36 +0100 Subject: [PATCH 04/24] History now shows a loading bar upon opening --- app/views/editor/level/versions_view.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/editor/level/versions_view.coffee b/app/views/editor/level/versions_view.coffee index 39af46ae4..7f5cc2afd 100644 --- a/app/views/editor/level/versions_view.coffee +++ b/app/views/editor/level/versions_view.coffee @@ -7,6 +7,7 @@ module.exports = class ModalVersionsView extends VersionsView url: "/db/level/" page: "level" template: template + startsLoading: true className: "modal fade" closeButton: true From 8e989ec08f7e17141d74328fe6739657e456583f Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Mon, 10 Mar 2014 23:17:19 +0100 Subject: [PATCH 05/24] Got the level history view set up as before, but better --- app/templates/editor/level/versions.jade | 11 -------- app/templates/kinds/versions.jade | 24 ---------------- app/templates/modal/versions.jade | 25 +++++++++++++++++ app/views/editor/article/versions.coffee | 9 ------ app/views/editor/article/versions_view.coffee | 9 ++++++ app/views/editor/level/versions.coffee | 9 ------ app/views/editor/level/versions_view.coffee | 28 ++----------------- .../versions_modal.coffee} | 11 ++++---- 8 files changed, 43 insertions(+), 83 deletions(-) delete mode 100644 app/templates/editor/level/versions.jade delete mode 100755 app/templates/kinds/versions.jade create mode 100755 app/templates/modal/versions.jade delete mode 100644 app/views/editor/article/versions.coffee create mode 100644 app/views/editor/article/versions_view.coffee delete mode 100644 app/views/editor/level/versions.coffee rename app/views/{kinds/VersionsView.coffee => modal/versions_modal.coffee} (81%) diff --git a/app/templates/editor/level/versions.jade b/app/templates/editor/level/versions.jade deleted file mode 100644 index b40c7b6f0..000000000 --- a/app/templates/editor/level/versions.jade +++ /dev/null @@ -1,11 +0,0 @@ -extends /templates/modal/modal_base -include /templates/kinds/versions - -block modal-header-content - h3(data-i18n="general.version_history") Version History - -block modal-body-content - if dataList - +version-history-body() - -block modal-footer-content \ No newline at end of file diff --git a/app/templates/kinds/versions.jade b/app/templates/kinds/versions.jade deleted file mode 100755 index a7db6039f..000000000 --- a/app/templates/kinds/versions.jade +++ /dev/null @@ -1,24 +0,0 @@ -extends /templates/base - -mixin version-history-title() - h3(data-i18n="general.version_history_for") Version History for: #{dataList[0]} - -mixin version-history-body() - table.table - tr - th(data-i18n="general.name") Name - th(data-i18n="general.version") Version - th(data-i18n="general.commit_msg") Commit Message - for data in dataList - tr - td - a(href="/editor/#{page}/#{data.slug || data._id}") - | #{data.name} - td #{data.version.major}.#{data.version.minor} - td #{data.commitMessage} - -block content - if dataList - +version-history-title() - - +version-history-body() \ No newline at end of file diff --git a/app/templates/modal/versions.jade b/app/templates/modal/versions.jade new file mode 100755 index 000000000..d91fb1e8e --- /dev/null +++ b/app/templates/modal/versions.jade @@ -0,0 +1,25 @@ +extends /templates/modal/modal_base + +block modal-header-content + if dataList + - console.log(dataList[0].name) + h3 + span(data-i18n="general.version_history_for") Version History for: + |"#{dataList[0].name}" + +block modal-body-content + if dataList + table.table + tr + th(data-i18n="general.name") Name + th(data-i18n="general.version") Version + th(data-i18n="general.commit_msg") Commit Message + for data in dataList + tr + td + a(href="/editor/#{page}/#{data.slug || data._id}") + | #{data.name} + td #{data.version.major}.#{data.version.minor} + td #{data.commitMessage} + +block modal-footer-content \ No newline at end of file diff --git a/app/views/editor/article/versions.coffee b/app/views/editor/article/versions.coffee deleted file mode 100644 index 2c3ac5d47..000000000 --- a/app/views/editor/article/versions.coffee +++ /dev/null @@ -1,9 +0,0 @@ -VersionsView = require 'views/kinds/VersionsView' - -module.exports = class SuperVersionsView extends VersionsView - id: "editor-article-versions-view" - url: "/db/article/" - page: "article" - - constructor: (options, @ID) -> - super options, ID, require 'models/Article' \ No newline at end of file diff --git a/app/views/editor/article/versions_view.coffee b/app/views/editor/article/versions_view.coffee new file mode 100644 index 000000000..59b8b1f9c --- /dev/null +++ b/app/views/editor/article/versions_view.coffee @@ -0,0 +1,9 @@ +VersionsModalView = require 'views/modal/versions_modal' + +module.exports = class ArticleVersionsView extends VersionsModalView + id: 'version-history-modal' + url: "/db/article/" + page: "article" + + constructor: (options, @ID) -> + super options, ID, require 'models/Article' \ No newline at end of file diff --git a/app/views/editor/level/versions.coffee b/app/views/editor/level/versions.coffee deleted file mode 100644 index 88d8c990d..000000000 --- a/app/views/editor/level/versions.coffee +++ /dev/null @@ -1,9 +0,0 @@ -VersionsView = require 'views/kinds/VersionsView' - -module.exports = class SuperVersionsView extends VersionsView - id: "editor-level-versions-view" - url: "/db/level/" - page: "level" - - constructor: (options, @ID) -> - super options, ID, require 'models/Level' \ No newline at end of file diff --git a/app/views/editor/level/versions_view.coffee b/app/views/editor/level/versions_view.coffee index 7f5cc2afd..90245bc67 100644 --- a/app/views/editor/level/versions_view.coffee +++ b/app/views/editor/level/versions_view.coffee @@ -1,31 +1,9 @@ -VersionsView = require 'views/kinds/VersionsView' -ModalView = require 'views/kinds/ModalView' -template = require 'templates/editor/level/versions' +VersionsModalView = require 'views/modal/versions_modal' -module.exports = class ModalVersionsView extends VersionsView +module.exports = class LevelVersionsView extends VersionsModalView id: 'version-history-modal' url: "/db/level/" page: "level" - template: template - startsLoading: true - - className: "modal fade" - closeButton: true - closesOnClickOutside: true - modalWidthPercent: null - - shortcuts: - 'esc': 'hide' constructor: (options, @ID) -> - super options, ID, require 'models/Level' - _.extend @, ModalView - ModalView.prototype.constructor options - - getRenderData: (context={}) -> - context = super(context) - context.closeButton = true - context - - hide: -> - @$el.removeClass('fade').modal "hide" \ No newline at end of file + super options, ID, require 'models/Level' \ No newline at end of file diff --git a/app/views/kinds/VersionsView.coffee b/app/views/modal/versions_modal.coffee similarity index 81% rename from app/views/kinds/VersionsView.coffee rename to app/views/modal/versions_modal.coffee index e686d6129..8845c577a 100755 --- a/app/views/kinds/VersionsView.coffee +++ b/app/views/modal/versions_modal.coffee @@ -1,5 +1,5 @@ -View = require 'views/kinds/RootView' -template = require 'templates/kinds/versions' +ModalView = require 'views/kinds/ModalView' +template = require 'templates/modal/versions' tableTemplate = require 'templates/kinds/table' class VersionsViewCollection extends Backbone.Collection @@ -10,14 +10,14 @@ class VersionsViewCollection extends Backbone.Collection @url = url + levelID + '/versions' @model = model -module.exports = class SuperVersionsView extends View +module.exports = class VersionsModalView extends ModalView template: template startsLoading: true # needs to be overwritten by child id: "" - url = "" - page = "" + url: "" + page: "" constructor: (options, @ID, @model) -> super options @@ -38,4 +38,5 @@ module.exports = class SuperVersionsView extends View context = super(context) context.page = @page context.dataList = (m.attributes for m in @collection.models) if @collection + console.debug context context From af73e5a594564bda34fe0e1956bb18939257cf32 Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Mon, 10 Mar 2014 23:29:34 +0100 Subject: [PATCH 06/24] Added a versions modal for every type --- app/templates/modal/versions.jade | 1 - app/views/editor/article/versions_view.coffee | 2 +- .../component/{versions.coffee => versions_view.coffee} | 4 ++-- app/views/editor/level/versions_view.coffee | 2 +- app/views/editor/thang/versions.coffee | 4 ++-- 5 files changed, 6 insertions(+), 7 deletions(-) rename app/views/editor/component/{versions.coffee => versions_view.coffee} (58%) diff --git a/app/templates/modal/versions.jade b/app/templates/modal/versions.jade index d91fb1e8e..1e10c056b 100755 --- a/app/templates/modal/versions.jade +++ b/app/templates/modal/versions.jade @@ -2,7 +2,6 @@ extends /templates/modal/modal_base block modal-header-content if dataList - - console.log(dataList[0].name) h3 span(data-i18n="general.version_history_for") Version History for: |"#{dataList[0].name}" diff --git a/app/views/editor/article/versions_view.coffee b/app/views/editor/article/versions_view.coffee index 59b8b1f9c..63b040366 100644 --- a/app/views/editor/article/versions_view.coffee +++ b/app/views/editor/article/versions_view.coffee @@ -1,7 +1,7 @@ VersionsModalView = require 'views/modal/versions_modal' module.exports = class ArticleVersionsView extends VersionsModalView - id: 'version-history-modal' + id: "editor-article-versions-view" url: "/db/article/" page: "article" diff --git a/app/views/editor/component/versions.coffee b/app/views/editor/component/versions_view.coffee similarity index 58% rename from app/views/editor/component/versions.coffee rename to app/views/editor/component/versions_view.coffee index 7305c29c5..1edaad280 100755 --- a/app/views/editor/component/versions.coffee +++ b/app/views/editor/component/versions_view.coffee @@ -1,6 +1,6 @@ -VersionsView = require 'views/kinds/VersionsView' +VersionsModalView = require 'views/modal/versions_modal' -module.exports = class SuperVersionsView extends VersionsView +module.exports = class ComponentVersionsView extends VersionsModalView id: "editor-component-versions-view" url: "/db/level.component/" page: "component" diff --git a/app/views/editor/level/versions_view.coffee b/app/views/editor/level/versions_view.coffee index 90245bc67..09aa5925e 100644 --- a/app/views/editor/level/versions_view.coffee +++ b/app/views/editor/level/versions_view.coffee @@ -1,7 +1,7 @@ VersionsModalView = require 'views/modal/versions_modal' module.exports = class LevelVersionsView extends VersionsModalView - id: 'version-history-modal' + id: "editor-level-versions-view" url: "/db/level/" page: "level" diff --git a/app/views/editor/thang/versions.coffee b/app/views/editor/thang/versions.coffee index a52f3d1cf..59c30296f 100755 --- a/app/views/editor/thang/versions.coffee +++ b/app/views/editor/thang/versions.coffee @@ -1,6 +1,6 @@ -VersionsView = require 'views/kinds/VersionsView' +VersionsModalView = require 'views/modal/versions_modal' -module.exports = class SuperVersionsView extends VersionsView +module.exports = class ThangVersionsView extends VersionsModalView id: "editor-thang-versions-view" url: "/db/thang.type/" page: "thang" From 8709cdc472b22ef0ff39efbdc505d17651d7444f Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Tue, 11 Mar 2014 19:33:27 +0100 Subject: [PATCH 07/24] Finished Article History --- app/locale/en.coffee | 2 +- app/locale/nl.coffee | 2 +- app/templates/editor/article/edit.jade | 1 + app/templates/editor/level/edit.jade | 2 +- app/views/editor/article/edit.coffee | 7 +++++++ app/views/modal/versions_modal.coffee | 1 - 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/locale/en.coffee b/app/locale/en.coffee index c4dd578e4..3411adbe0 100644 --- a/app/locale/en.coffee +++ b/app/locale/en.coffee @@ -264,7 +264,7 @@ module.exports = nativeDescription: "English", englishDescription: "English", tr body: "Body" version: "Version" commit_msg: "Commit Message" - version_history: "Version History" + history: "History" version_history_for: "Version History for: " results: "Results" description: "Description" diff --git a/app/locale/nl.coffee b/app/locale/nl.coffee index 831161810..420be4b34 100644 --- a/app/locale/nl.coffee +++ b/app/locale/nl.coffee @@ -264,7 +264,7 @@ module.exports = nativeDescription: "Nederlands", englishDescription: "Dutch", t body: "Inhoud" version: "Versie" commit_msg: "Commit Bericht" - version_history: "Versie geschiedenis" + history: "Geschiedenis" version_history_for: "Versie geschiedenis voor: " results: "Resultaten" description: "Beschrijving" diff --git a/app/templates/editor/article/edit.jade b/app/templates/editor/article/edit.jade index 7c6a7136a..c2446537b 100644 --- a/app/templates/editor/article/edit.jade +++ b/app/templates/editor/article/edit.jade @@ -10,6 +10,7 @@ block content li.active | #{article.attributes.name} + button(data-i18n="general.history").btn.btn-primary#history-button History button(data-toggle="coco-modal", data-target="modal/revert", data-i18n="revert.revert", disabled=authorized === true ? undefined : "true").btn.btn-primary#revert-button Revert button(data-i18n="article.edit_btn_preview", disabled=authorized === true ? undefined : "true").btn.btn-primary#preview-button Preview button(data-toggle="coco-modal", data-target="modal/save_version", data-i18n="common.save", disabled=authorized === true ? undefined : "true").btn.btn-primary#save-button Save diff --git a/app/templates/editor/level/edit.jade b/app/templates/editor/level/edit.jade index ef788fe3e..6ba77ebd7 100644 --- a/app/templates/editor/level/edit.jade +++ b/app/templates/editor/level/edit.jade @@ -42,7 +42,7 @@ block outer_content b.caret ul.dropdown-menu li#version-history-button - a(href='#') Version History + a(href='#', data-i18n="general.version_history") Version History li a(href='https://github.com/codecombat/codecombat/wiki/Artisan-Home') Wiki li diff --git a/app/views/editor/article/edit.coffee b/app/views/editor/article/edit.coffee index 77f95ac40..25aea0d9d 100644 --- a/app/views/editor/article/edit.coffee +++ b/app/views/editor/article/edit.coffee @@ -1,4 +1,5 @@ View = require 'views/kinds/RootView' +VersionHistoryView = require './versions_view' template = require 'templates/editor/article/edit' Article = require 'models/Article' @@ -9,6 +10,7 @@ module.exports = class ArticleEditView extends View events: 'click #preview-button': 'openPreview' + 'click #history-button': 'showVersionHistory' subscriptions: 'save-new-version': 'saveNewArticle' @@ -84,3 +86,8 @@ module.exports = class ArticleEditView extends View modal.modal('hide') url = "/editor/article/#{newArticle.get('slug') or newArticle.id}" document.location.href = url + + showVersionHistory: (e) -> + versionHistoryView = new VersionHistoryView level:@article, @articleID + @openModalView versionHistoryView + Backbone.Mediator.publish 'level:view-switched', e diff --git a/app/views/modal/versions_modal.coffee b/app/views/modal/versions_modal.coffee index 8845c577a..212572666 100755 --- a/app/views/modal/versions_modal.coffee +++ b/app/views/modal/versions_modal.coffee @@ -38,5 +38,4 @@ module.exports = class VersionsModalView extends ModalView context = super(context) context.page = @page context.dataList = (m.attributes for m in @collection.models) if @collection - console.debug context context From da58b68fa0716d75b299f9c169f86774a1a16356 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Tue, 11 Mar 2014 16:23:04 -0700 Subject: [PATCH 08/24] Fixed a bug with the music player where sometimes it wouldn't loop. --- app/lib/surface/MusicPlayer.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/surface/MusicPlayer.coffee b/app/lib/surface/MusicPlayer.coffee index 13cca1a17..57ff7c72e 100644 --- a/app/lib/surface/MusicPlayer.coffee +++ b/app/lib/surface/MusicPlayer.coffee @@ -23,7 +23,7 @@ module.exports = class MusicPlayer extends CocoClass src = e.file if src src = "/file#{src}#{AudioPlayer.ext}" - return @currentMusic.play() if src is @currentMusic?.src + return @currentMusic.play('none', 0, 0, -1, 0.3) if src is @currentMusic?.src media = AudioPlayer.getStatus(src) if not media?.loaded AudioPlayer.preloadSound(src) From 8ddbb498452473847dbf4b255b7aa73699756359 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Tue, 11 Mar 2014 22:01:38 -0700 Subject: [PATCH 09/24] Trying out promises to simplify view loading. --- app/models/CocoModel.coffee | 3 ++- app/views/play/ladder_view.coffee | 13 ++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/models/CocoModel.coffee b/app/models/CocoModel.coffee index 3f4c9455c..c5e321d3e 100644 --- a/app/models/CocoModel.coffee +++ b/app/models/CocoModel.coffee @@ -81,8 +81,9 @@ class CocoModel extends Backbone.Model return super attrs, options fetch: -> - super(arguments...) + res = super(arguments...) @loading = true + res markToRevert: -> @_revertAttributes = _.clone @attributes diff --git a/app/views/play/ladder_view.coffee b/app/views/play/ladder_view.coffee index e12304f96..0323d3ec5 100644 --- a/app/views/play/ladder_view.coffee +++ b/app/views/play/ladder_view.coffee @@ -33,20 +33,15 @@ module.exports = class LadderView extends RootView constructor: (options, @levelID) -> super(options) @level = new Level(_id:@levelID) - @level.fetch() - @level.once 'sync', @onLevelLoaded, @ + p1 = @level.fetch() @sessions = new LevelSessionsCollection(levelID) - @sessions.fetch({}) - @sessions.once 'sync', @onMySessionsLoaded, @ + p2 = @sessions.fetch({}) @simulator = new Simulator() @simulator.on 'statusUpdate', @updateSimulationStatus, @ @teams = [] + $.when(p1, p2).then @onLoaded - onLevelLoaded: -> @renderMaybe() - onMySessionsLoaded: -> @renderMaybe() - - renderMaybe: -> - return unless @level.loaded and @sessions.loaded + onLoaded: => @teams = teamDataFromLevel @level @startsLoading = false @render() From 5e964cd6cf9a8ab02fbbdc2208d3e7bb4fb96630 Mon Sep 17 00:00:00 2001 From: Prabh Simran Singh Baweja Date: Wed, 12 Mar 2014 15:58:33 +0530 Subject: [PATCH 10/24] Update play_view.coffee New Level Added : Sword Loop --- app/views/play_view.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/views/play_view.coffee b/app/views/play_view.coffee index 9088f1cde..fc3cb7a2c 100644 --- a/app/views/play_view.coffee +++ b/app/views/play_view.coffee @@ -161,6 +161,14 @@ module.exports = class PlayView extends View image: '/file/db/level/525ef8ef06e1ab0962000003/commanding_followers_icon.png' description: "Write a bubble sort to organize your soldiers. - by Alexandru" } + { + name: 'Sword Loop' + difficulty: 1 + id: 'sword-loop' + image: '/file/db/level/525dc5589a0765e496000006/drink_me_icon.png' + description: 'Kill the ogres and save the peasants and their cattle' + } + { name: 'Enemy Artillery' difficulty: 1 From 2a86daaa2a62e8edf6b22b8e49af8514ab0b4c51 Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Wed, 12 Mar 2014 15:22:15 +0100 Subject: [PATCH 11/24] Added Version History to Thang Types --- app/templates/editor/level/edit.jade | 2 +- app/templates/editor/thang/edit.jade | 1 + app/views/editor/article/edit.coffee | 2 +- app/views/editor/level/edit.coffee | 2 +- app/views/editor/thang/edit.coffee | 7 +++++++ .../editor/thang/{versions.coffee => versions_view.coffee} | 2 +- 6 files changed, 12 insertions(+), 4 deletions(-) rename app/views/editor/thang/{versions.coffee => versions_view.coffee} (75%) diff --git a/app/templates/editor/level/edit.jade b/app/templates/editor/level/edit.jade index 6ba77ebd7..e6f6c44e9 100644 --- a/app/templates/editor/level/edit.jade +++ b/app/templates/editor/level/edit.jade @@ -41,7 +41,7 @@ block outer_content | More b.caret ul.dropdown-menu - li#version-history-button + li#history-button a(href='#', data-i18n="general.version_history") Version History li a(href='https://github.com/codecombat/codecombat/wiki/Artisan-Home') Wiki diff --git a/app/templates/editor/thang/edit.jade b/app/templates/editor/thang/edit.jade index af30eb2c1..80d50585a 100644 --- a/app/templates/editor/thang/edit.jade +++ b/app/templates/editor/thang/edit.jade @@ -12,6 +12,7 @@ block content img#portrait.img-thumbnail + button.btn.btn-secondary#history-button(data-i18n="general.history") History button.btn.btn-primary#save-button(data-toggle="coco-modal", data-target="modal/save_version", disabled=authorized === true ? undefined : "true") Save button.btn.btn-primary#revert-button(data-toggle="coco-modal", data-target="modal/revert", data-i18n="revert.revert", disabled=authorized === true ? undefined : "true") Revert diff --git a/app/views/editor/article/edit.coffee b/app/views/editor/article/edit.coffee index 25aea0d9d..515b117e4 100644 --- a/app/views/editor/article/edit.coffee +++ b/app/views/editor/article/edit.coffee @@ -88,6 +88,6 @@ module.exports = class ArticleEditView extends View document.location.href = url showVersionHistory: (e) -> - versionHistoryView = new VersionHistoryView level:@article, @articleID + versionHistoryView = new VersionHistoryView article:@article, @articleID @openModalView versionHistoryView Backbone.Mediator.publish 'level:view-switched', e diff --git a/app/views/editor/level/edit.coffee b/app/views/editor/level/edit.coffee index 4f1ceee85..8f4f68a00 100644 --- a/app/views/editor/level/edit.coffee +++ b/app/views/editor/level/edit.coffee @@ -24,7 +24,7 @@ module.exports = class EditorLevelView extends View 'click #play-button': 'onPlayLevel' 'click #commit-level-start-button': 'startCommittingLevel' 'click #fork-level-start-button': 'startForkingLevel' - 'click #version-history-button': 'showVersionHistory' + 'click #history-button': 'showVersionHistory' constructor: (options, @levelID) -> super options diff --git a/app/views/editor/thang/edit.coffee b/app/views/editor/thang/edit.coffee index a8310cdf2..bdc4671dc 100644 --- a/app/views/editor/thang/edit.coffee +++ b/app/views/editor/thang/edit.coffee @@ -6,6 +6,7 @@ SpriteBuilder = require 'lib/sprites/SpriteBuilder' CocoSprite = require 'lib/surface/CocoSprite' Camera = require 'lib/surface/Camera' ThangComponentEditView = require 'views/editor/components/main' +VersionHistoryView = require './versions_view' DocumentFiles = require 'collections/DocumentFiles' ColorsTabView = require './colors_tab_view' @@ -30,6 +31,7 @@ module.exports = class ThangTypeEditView extends View 'change #animations-select': 'showAnimation' 'click #marker-button': 'toggleDots' 'click #end-button': 'endAnimation' + 'click #history-button': 'showVersionHistory' subscriptions: 'save-new-version': 'saveNewThangType' @@ -382,3 +384,8 @@ module.exports = class ThangTypeEditView extends View destroy: -> @camera?.destroy() super() + + showVersionHistory: (e) -> + versionHistoryView = new VersionHistoryView thangType:@thangType, @thangTypeID + @openModalView versionHistoryView + Backbone.Mediator.publish 'level:view-switched', e \ No newline at end of file diff --git a/app/views/editor/thang/versions.coffee b/app/views/editor/thang/versions_view.coffee similarity index 75% rename from app/views/editor/thang/versions.coffee rename to app/views/editor/thang/versions_view.coffee index 59c30296f..889d9c902 100755 --- a/app/views/editor/thang/versions.coffee +++ b/app/views/editor/thang/versions_view.coffee @@ -1,6 +1,6 @@ VersionsModalView = require 'views/modal/versions_modal' -module.exports = class ThangVersionsView extends VersionsModalView +module.exports = class ComponentVersionsView extends VersionsModalView id: "editor-thang-versions-view" url: "/db/thang.type/" page: "thang" From a6fb2a3994a473af5480de9de11dedb217aae208 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Wed, 12 Mar 2014 07:32:27 -0700 Subject: [PATCH 12/24] Various changes to spectate view --- app/styles/play/spectate.sass | 27 ++++++++++++++------------- app/templates/play/spectate.jade | 10 +--------- app/views/play/spectate_view.coffee | 14 +++++++------- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/app/styles/play/spectate.sass b/app/styles/play/spectate.sass index 9de885caa..a70c059b9 100644 --- a/app/styles/play/spectate.sass +++ b/app/styles/play/spectate.sass @@ -1,8 +1,11 @@ @import "app/styles/bootstrap/mixins" @import "app/styles/mixins" - +body + height: 100% + #spectate-level-view margin: 0 auto + height: 100% @include user-select(none) .level-content @@ -11,6 +14,7 @@ #canvas-wrapper width: 55% position: relative + margin: 0 auto canvas#surface background-color: #ddd @@ -22,18 +26,15 @@ //max-width: 1680px // guideline, but for now let's let it stretch out min-width: 1024px position: relative - - #code-area - @include box-sizing(border-box) - padding: 10px 1% - width: 45% - background: transparent url(/images/level/wood_texture.png) - background-size: 100% 100% - position: absolute - right: 0 - top: 0px - bottom: 0 - + #playback-view + margin: 0 auto + #thang-hud + margin: 0 auto + + #control-bar-view + margin: 0 auto + .title + margin-left: 500px #pointer position: absolute left: 0 diff --git a/app/templates/play/spectate.jade b/app/templates/play/spectate.jade index cfaba9234..8559b187f 100644 --- a/app/templates/play/spectate.jade +++ b/app/templates/play/spectate.jade @@ -11,12 +11,4 @@ .footer .content p(class='footer-link-text') - a(title='Send CodeCombat a message', tabindex=-1, data-toggle="coco-modal", data-target="modal/contact", data-i18n="nav.contact") Contact - if explainHourOfCode - // Does not show up unless lang is en-US. - div.hour-of-code-explanation - | The 'Hour of Code' is a nationwide initiative by - a(href="http://csedweek.org") Computer Science Education Week - | and - a(href="http://code.org") Code.org - | to introduce millions of students to one hour of computer science and computer programming. \ No newline at end of file + a(title='Send CodeCombat a message', tabindex=-1, data-toggle="coco-modal", data-target="modal/contact", data-i18n="nav.contact") Contact \ No newline at end of file diff --git a/app/views/play/spectate_view.coffee b/app/views/play/spectate_view.coffee index 17dbcf6d3..85749e9f1 100644 --- a/app/views/play/spectate_view.coffee +++ b/app/views/play/spectate_view.coffee @@ -71,8 +71,10 @@ module.exports = class SpectateLevelView extends View constructor: (options, @levelID) -> console.profile?() if PROFILE_ME super options - - @sessionID = @getQueryVariable 'session' + @sessionOne = @getQueryVariable 'session-one' + @sessionTwo = @getQueryVariable 'session-two' + + @sessionID = @sessionOne $(window).on('resize', @onWindowResize) @supermodel.once 'error', @onLevelLoadError @@ -91,7 +93,7 @@ module.exports = class SpectateLevelView extends View @load() load: -> - @levelLoader = new LevelLoader supermodel: @supermodel, levelID: @levelID, sessionID: @sessionID, opponentSessionID: @getQueryVariable('opponent'), team: @getQueryVariable("team") + @levelLoader = new LevelLoader supermodel: @supermodel, levelID: @levelID, sessionID: @sessionID, opponentSessionID: @sessionTwo, team: @getQueryVariable("team") @levelLoader.once 'loaded-all', @onLevelLoaderLoaded, @ @levelLoader.on 'progress', @onLevelLoaderProgressChanged, @ @god = new God() @@ -135,9 +137,8 @@ module.exports = class SpectateLevelView extends View @loadingScreen.showReady() return Backbone.Mediator.subscribeOnce 'modal-closed', @onLevelLoaderLoaded, @ - localStorage["lastLevel"] = @levelID if localStorage? @grabLevelLoaderData() - team = @getQueryVariable("team") ? @world.teamForPlayer(0) + team = @world.teamForPlayer(0) @loadOpponentTeam(team) @loadingScreen.destroy() @god.level = @level.serialize @supermodel @@ -200,10 +201,9 @@ module.exports = class SpectateLevelView extends View insertSubviews: (subviewOptions) -> @insertSubView @tome = new TomeView levelID: @levelID, session: @session, thangs: @world.thangs, supermodel: @supermodel, ladderGame: subviewOptions.ladderGame @insertSubView new PlaybackView {} - @insertSubView new GoalsView {} + @insertSubView new GoldView {} @insertSubView new HUDView {} - @insertSubView new ChatView levelID: @levelID, sessionID: @session.id, session: @session worldName = @level.get('i18n')?[me.lang()]?.name ? @level.get('name') @controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, playableTeams: @world.playableTeams, ladderGame: subviewOptions.ladderGame} #Backbone.Mediator.publish('level-set-debug', debug: true) if me.displayName() is 'Nick!' From ddae5d0763c60254f8f8c8fa622b2a3cf89e3cc2 Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Wed, 12 Mar 2014 15:32:55 +0100 Subject: [PATCH 13/24] Added Version History to Level Components --- app/templates/editor/level/component/edit.jade | 2 ++ app/views/editor/level/component/edit.coffee | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/app/templates/editor/level/component/edit.jade b/app/templates/editor/level/component/edit.jade index 911e07237..6a0a00218 100644 --- a/app/templates/editor/level/component/edit.jade +++ b/app/templates/editor/level/component/edit.jade @@ -14,6 +14,8 @@ nav.navbar.navbar-default(role='navigation') a(href="#component-config-schema" data-toggle="tab") Config Schema li a(href="#component-settings" data-toggle="tab") Settings + ul.nav.navbar-nav.navbar-left + li(data-i18n="general.history").btn.btn-primary.navbar-btn#history-button History ul.nav.navbar-nav.navbar-right li(data-i18n="editor.level_component_btn_new").btn.btn-primary.navbar-btn#create-new-component-button Create New Component diff --git a/app/views/editor/level/component/edit.coffee b/app/views/editor/level/component/edit.coffee index 8eb591dbf..18214ff60 100644 --- a/app/views/editor/level/component/edit.coffee +++ b/app/views/editor/level/component/edit.coffee @@ -1,4 +1,5 @@ View = require 'views/kinds/CocoView' +VersionHistoryView = require 'views/editor/component/versions_view' template = require 'templates/editor/level/component/edit' LevelComponent = require 'models/LevelComponent' @@ -9,6 +10,7 @@ module.exports = class LevelComponentEditView extends View events: 'click #done-editing-component-button': 'endEditing' + 'click #history-button': 'showVersionHistory' 'click .nav a': (e) -> $(e.target).tab('show') constructor: (options) -> @@ -91,3 +93,9 @@ module.exports = class LevelComponentEditView extends View destroy: -> @editor?.destroy() super() + + showVersionHistory: (e) -> + console.debug @levelComponent + versionHistoryView = new VersionHistoryView component:@levelComponent, @levelComponent.id + @openModalView versionHistoryView + Backbone.Mediator.publish 'level:view-switched', e \ No newline at end of file From 8acf35b290d29b1878b2edf5b3d27ab572192f71 Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Wed, 12 Mar 2014 15:42:57 +0100 Subject: [PATCH 14/24] Added i18n for components --- app/locale/en.coffee | 3 +++ app/locale/nl.coffee | 3 +++ app/templates/editor/level/component/edit.jade | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/locale/en.coffee b/app/locale/en.coffee index 3411adbe0..da045feb7 100644 --- a/app/locale/en.coffee +++ b/app/locale/en.coffee @@ -243,6 +243,8 @@ module.exports = nativeDescription: "English", englishDescription: "English", tr level_components_title: "Back to All Thangs" level_components_type: "Type" level_component_edit_title: "Edit Component" + level_component_config_schema: "Config Schema" + level_component_settings: "Settings" level_system_edit_title: "Edit System" create_system_title: "Create New System" new_component_title: "Create New Component" @@ -271,6 +273,7 @@ module.exports = nativeDescription: "English", englishDescription: "English", tr or: "or" email: "Email" message: "Message" + code: "Code" about: who_is_codecombat: "Who is CodeCombat?" diff --git a/app/locale/nl.coffee b/app/locale/nl.coffee index 420be4b34..1f4f9426f 100644 --- a/app/locale/nl.coffee +++ b/app/locale/nl.coffee @@ -243,6 +243,8 @@ module.exports = nativeDescription: "Nederlands", englishDescription: "Dutch", t level_components_title: "Terug naar Alle Elementen" level_components_type: "Type" level_component_edit_title: "Wijzig Component" + level_component_config_schema: "Schema" + level_component_settings: "Instellingen" level_system_edit_title: "Wijzig Systeem" create_system_title: "Maak een nieuw Systeem aan" new_component_title: "Maak een nieuw Component aan" @@ -271,6 +273,7 @@ module.exports = nativeDescription: "Nederlands", englishDescription: "Dutch", t or: "of" email: "Email" message: "Bericht" + code: "Code" about: who_is_codecombat: "Wie is CodeCombat?" diff --git a/app/templates/editor/level/component/edit.jade b/app/templates/editor/level/component/edit.jade index 6a0a00218..44d368080 100644 --- a/app/templates/editor/level/component/edit.jade +++ b/app/templates/editor/level/component/edit.jade @@ -9,11 +9,11 @@ nav.navbar.navbar-default(role='navigation') .collapse.navbar-collapse ul.nav.navbar-nav.nav-tabs li.active - a(href="#component-code" data-toggle="tab") Code + a(href="#component-code" data-toggle="tab" data-i18n="general.code") Code li - a(href="#component-config-schema" data-toggle="tab") Config Schema + a(href="#component-config-schema" data-toggle="tab" data-i18n="editor.level_component_config_schema") Config Schema li - a(href="#component-settings" data-toggle="tab") Settings + a(href="#component-settings" data-toggle="tab" data-i18n="editor.level_component_settings") Settings ul.nav.navbar-nav.navbar-left li(data-i18n="general.history").btn.btn-primary.navbar-btn#history-button History ul.nav.navbar-nav.navbar-right From 4b72ee1d04e22091d3aeca1f05798369994c8d7d Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Wed, 12 Mar 2014 15:43:49 +0100 Subject: [PATCH 15/24] Clean up --- app/views/editor/level/component/edit.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/editor/level/component/edit.coffee b/app/views/editor/level/component/edit.coffee index 18214ff60..46db9a7fb 100644 --- a/app/views/editor/level/component/edit.coffee +++ b/app/views/editor/level/component/edit.coffee @@ -95,7 +95,6 @@ module.exports = class LevelComponentEditView extends View super() showVersionHistory: (e) -> - console.debug @levelComponent versionHistoryView = new VersionHistoryView component:@levelComponent, @levelComponent.id @openModalView versionHistoryView Backbone.Mediator.publish 'level:view-switched', e \ No newline at end of file From 27fd5803249d36275ed5bbbe58eb9368be32089f Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Wed, 12 Mar 2014 16:03:36 +0100 Subject: [PATCH 16/24] Got rid of CRLF line endings --- app/templates/editor/article/table.jade | 40 +++++++++--------- app/templates/editor/components/table.jade | 40 +++++++++--------- app/templates/editor/level/table.jade | 40 +++++++++--------- app/templates/editor/thang/table.jade | 48 +++++++++++----------- app/templates/kinds/table.jade | 40 +++++++++--------- app/templates/modal/versions.jade | 46 ++++++++++----------- 6 files changed, 127 insertions(+), 127 deletions(-) diff --git a/app/templates/editor/article/table.jade b/app/templates/editor/article/table.jade index c98e17b3f..42b431c32 100755 --- a/app/templates/editor/article/table.jade +++ b/app/templates/editor/article/table.jade @@ -1,21 +1,21 @@ -table.table - tr - th(colspan=3) - span(data-i18n="general.results") - | Results - span - |: #{documents.length} - - tr - th(data-i18n="general.name") Name - th(data-i18n="general.description") Description - th(data-i18n="general.version") Version - - for data in documents - - data = data.attributes; - tr - td - a(href="/editor/article/#{data.slug || data._id}") - | #{data.name} - td.body-row #{data.description} +table.table + tr + th(colspan=3) + span(data-i18n="general.results") + | Results + span + |: #{documents.length} + + tr + th(data-i18n="general.name") Name + th(data-i18n="general.description") Description + th(data-i18n="general.version") Version + + for data in documents + - data = data.attributes; + tr + td + a(href="/editor/article/#{data.slug || data._id}") + | #{data.name} + td.body-row #{data.description} td #{data.version.major}.#{data.version.minor} \ No newline at end of file diff --git a/app/templates/editor/components/table.jade b/app/templates/editor/components/table.jade index 935fee07f..cde222790 100755 --- a/app/templates/editor/components/table.jade +++ b/app/templates/editor/components/table.jade @@ -1,21 +1,21 @@ -table.table - tr - th(colspan=3) - span(data-i18n="general.results") - | Results - span - |: #{documents.length} - - tr - th(data-i18n="general.name") Name - th(data-i18n="general.description") Description - th(data-i18n="general.version") Version - - for data in documents - - data = data.attributes; - tr - td - a(href="/editor/component/#{data.slug || data._id}") - | #{data.name} - td.body-row #{data.description} +table.table + tr + th(colspan=3) + span(data-i18n="general.results") + | Results + span + |: #{documents.length} + + tr + th(data-i18n="general.name") Name + th(data-i18n="general.description") Description + th(data-i18n="general.version") Version + + for data in documents + - data = data.attributes; + tr + td + a(href="/editor/component/#{data.slug || data._id}") + | #{data.name} + td.body-row #{data.description} td #{data.version.major}.#{data.version.minor} \ No newline at end of file diff --git a/app/templates/editor/level/table.jade b/app/templates/editor/level/table.jade index 3830b0fce..37decec4d 100755 --- a/app/templates/editor/level/table.jade +++ b/app/templates/editor/level/table.jade @@ -1,21 +1,21 @@ -table.table - tr - th(colspan=3) - span(data-i18n="general.results") - | Results - span - |: #{documents.length} - - tr - th(data-i18n="general.name") Name - th(data-i18n="general.description") Description - th(data-i18n="general.version") Version - - for data in documents - - data = data.attributes; - tr - td - a(href="/editor/level/#{data.slug || data._id}") - | #{data.name} - td.body-row #{data.description} +table.table + tr + th(colspan=3) + span(data-i18n="general.results") + | Results + span + |: #{documents.length} + + tr + th(data-i18n="general.name") Name + th(data-i18n="general.description") Description + th(data-i18n="general.version") Version + + for data in documents + - data = data.attributes; + tr + td + a(href="/editor/level/#{data.slug || data._id}") + | #{data.name} + td.body-row #{data.description} td #{data.version.major}.#{data.version.minor} \ No newline at end of file diff --git a/app/templates/editor/thang/table.jade b/app/templates/editor/thang/table.jade index aa5947fe7..26a9f6583 100755 --- a/app/templates/editor/thang/table.jade +++ b/app/templates/editor/thang/table.jade @@ -1,25 +1,25 @@ -table.table - tr - th(colspan=3) - span(data-i18n="general.results") - | Results - span - |: #{documents.length} - - tr - th#portrait-col - th(data-i18n="general.name") Name - th(data-i18n="general.description") Description - th(data-i18n="general.version") Version - - for data in documents - - data = data.attributes; - tr - td - - path = '/file/db/thang.type/'+data.original+'/portrait.png' - img(title="Add " + data.name, src=path, alt="").portrait - td - a(href="/editor/thang/#{data.slug || data._id}") - | #{data.name} - td.body-row #{data.description} +table.table + tr + th(colspan=3) + span(data-i18n="general.results") + | Results + span + |: #{documents.length} + + tr + th#portrait-col + th(data-i18n="general.name") Name + th(data-i18n="general.description") Description + th(data-i18n="general.version") Version + + for data in documents + - data = data.attributes; + tr + td + - path = '/file/db/thang.type/'+data.original+'/portrait.png' + img(title="Add " + data.name, src=path, alt="").portrait + td + a(href="/editor/thang/#{data.slug || data._id}") + | #{data.name} + td.body-row #{data.description} td #{data.version.major}.#{data.version.minor} \ No newline at end of file diff --git a/app/templates/kinds/table.jade b/app/templates/kinds/table.jade index 38b7553d1..0eb0c1500 100755 --- a/app/templates/kinds/table.jade +++ b/app/templates/kinds/table.jade @@ -1,21 +1,21 @@ -table.table - tr - th(colspan=3) - span(data-i18n="general.results") - | Results - span - |: #{documents.length} - - tr - th(data-i18n="general.name") Name - th(data-i18n="general.description") Description - th(data-i18n="general.version") Version - - for data in documents - - data = data.attributes; - tr - td - a(href="/editor/#{page}/#{data.slug || data._id}") - | #{data.name} - td.body-row #{data.description} +table.table + tr + th(colspan=3) + span(data-i18n="general.results") + | Results + span + |: #{documents.length} + + tr + th(data-i18n="general.name") Name + th(data-i18n="general.description") Description + th(data-i18n="general.version") Version + + for data in documents + - data = data.attributes; + tr + td + a(href="/editor/#{page}/#{data.slug || data._id}") + | #{data.name} + td.body-row #{data.description} td #{data.version.major}.#{data.version.minor} \ No newline at end of file diff --git a/app/templates/modal/versions.jade b/app/templates/modal/versions.jade index 1e10c056b..bd5b099eb 100755 --- a/app/templates/modal/versions.jade +++ b/app/templates/modal/versions.jade @@ -1,24 +1,24 @@ -extends /templates/modal/modal_base - -block modal-header-content - if dataList - h3 - span(data-i18n="general.version_history_for") Version History for: - |"#{dataList[0].name}" - -block modal-body-content - if dataList - table.table - tr - th(data-i18n="general.name") Name - th(data-i18n="general.version") Version - th(data-i18n="general.commit_msg") Commit Message - for data in dataList - tr - td - a(href="/editor/#{page}/#{data.slug || data._id}") - | #{data.name} - td #{data.version.major}.#{data.version.minor} - td #{data.commitMessage} - +extends /templates/modal/modal_base + +block modal-header-content + if dataList + h3 + span(data-i18n="general.version_history_for") Version History for: + |"#{dataList[0].name}" + +block modal-body-content + if dataList + table.table + tr + th(data-i18n="general.name") Name + th(data-i18n="general.version") Version + th(data-i18n="general.commit_msg") Commit Message + for data in dataList + tr + td + a(href="/editor/#{page}/#{data.slug || data._id}") + | #{data.name} + td #{data.version.major}.#{data.version.minor} + td #{data.commitMessage} + block modal-footer-content \ No newline at end of file From 23f62e5598c9c213c6a030f7f42be02de1a2d7df Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Wed, 12 Mar 2014 08:11:48 -0700 Subject: [PATCH 17/24] Added ip checks on cron mail route --- server/routes/mail.coffee | 14 +++++++++++++- server_config.coffee | 4 +++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/server/routes/mail.coffee b/server/routes/mail.coffee index 284f8d432..d0c2290e2 100644 --- a/server/routes/mail.coffee +++ b/server/routes/mail.coffee @@ -16,7 +16,7 @@ sendwithus = require '../sendwithus' module.exports.setup = (app) -> app.all config.mail.mailchimpWebhook, handleMailchimpWebHook app.get '/mail/cron/ladder-update', handleLadderUpdate - + getAllLadderScores = (next) -> query = Level.find({type: 'ladder'}) .select('levelID') @@ -29,8 +29,20 @@ getAllLadderScores = (next) -> for team in ['humans', 'ogres'] 'I ... am not doing this.' +isRequestFromDesignatedCronHandler = (req, res) -> + if req.ip isnt config.mail.cronHandlerPublicIP and req.ip isnt config.mail.cronHandlerPrivateIP + console.log "UNAUTHORIZED ATTEMPT TO SEND TRANSACTIONAL LADDER EMAIL THROUGH CRON MAIL HANDLER" + res.send("You aren't authorized to perform that action. Only the specified Cron handler may perform that action.") + res.end() + return true + return false + + handleLadderUpdate = (req, res) -> log.info("Going to see about sending ladder update emails.") + requestIsFromDesignatedCronHandler = isRequestFromDesignatedCronHandler req, res + unless requestIsFromDesignatedCronHandler then return + res.send('Great work, Captain Cron! I can take it from here.') res.end() # TODO: somehow fetch the histograms diff --git a/server_config.coffee b/server_config.coffee index b13bead19..a30cbde32 100644 --- a/server_config.coffee +++ b/server_config.coffee @@ -26,7 +26,9 @@ config.mail = mailchimpAPIKey: process.env.COCO_MAILCHIMP_API_KEY or "" mailchimpWebhook: process.env.COCO_MAILCHIMP_WEBHOOK or "/mail/webhook" sendwithusAPIKey: process.env.COCO_SENDWITHUS_API_KEY or "" - + cronHandlerPublicIP: process.env.COCO_CRON_PUBLIC_IP or "" + cronHandlerPrivateIP: process.env.COCO_CRON_PRIVATE_IP or "" + config.queue = accessKeyId: process.env.COCO_AWS_ACCESS_KEY_ID or "" secretAccessKey: process.env.COCO_AWS_SECRET_ACCESS_KEY or "" From 2e354a7f11af84e1b0d8ba2f95ebac682cd66c69 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Wed, 12 Mar 2014 09:10:36 -0700 Subject: [PATCH 18/24] Fixed #519, pressing esc while loading level, and CocoSprites updating actions and other things unnecessarily while paused. Watch for bugs with that last one. --- app/lib/surface/CocoSprite.coffee | 3 ++- app/lib/surface/SpriteBoss.coffee | 8 ++++---- app/lib/surface/Surface.coffee | 2 ++ app/views/play/level/tome/spell_palette_view.coffee | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/lib/surface/CocoSprite.coffee b/app/lib/surface/CocoSprite.coffee index b454031e1..421dbe8c9 100644 --- a/app/lib/surface/CocoSprite.coffee +++ b/app/lib/surface/CocoSprite.coffee @@ -167,10 +167,11 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass @imageObject?.play?() mark.play() for name, mark of @marks - update: -> + update: (frameChanged) -> # Gets the sprite to reflect what the current state of the thangs and surface are return if @stillLoading @updatePosition() + return unless frameChanged @updateScale() @updateAlpha() @updateRotation() diff --git a/app/lib/surface/SpriteBoss.coffee b/app/lib/surface/SpriteBoss.coffee index f84d52a28..004934105 100644 --- a/app/lib/surface/SpriteBoss.coffee +++ b/app/lib/surface/SpriteBoss.coffee @@ -158,7 +158,7 @@ module.exports = class SpriteBoss extends CocoClass update: (frameChanged) -> @adjustSpriteExistence() if frameChanged - sprite.update() for thangID, sprite of @sprites + sprite.update frameChanged for thangID, sprite of @sprites @updateSelection() @spriteLayers["Default"].updateLayerOrder() @cache() @@ -181,7 +181,7 @@ module.exports = class SpriteBoss extends CocoClass sprite.hasMoved = false @removeSprite sprite if missing @cache true if updateCache and @cached - + # mainly for handling selecting thangs from session when the thang is not always in existence if @willSelectThang and @sprites[@willSelectThang[0]] @selectThang @willSelectThang... @@ -212,12 +212,12 @@ module.exports = class SpriteBoss extends CocoClass @play() onCastSpells: -> @stop() - + play: -> sprite.imageObject.play() for thangID, sprite of @sprites @selectionMark?.play() @targetMark?.play() - + stop: -> sprite.imageObject.stop() for thangID, sprite of @sprites @selectionMark?.stop() diff --git a/app/lib/surface/Surface.coffee b/app/lib/surface/Surface.coffee index fd278b8cc..7479edf75 100644 --- a/app/lib/surface/Surface.coffee +++ b/app/lib/surface/Surface.coffee @@ -208,10 +208,12 @@ module.exports = Surface = class Surface extends CocoClass @onFramesScrubbed() # For performance, don't play these for instant transitions. onTweenEnd() + return unless @loaded @updateState true @onFrameChanged() onFramesScrubbed: (e) => + return unless @loaded if e # Gotta play all the sounds when scrubbing (but not when doing an immediate transition). rising = @currentFrame > @lastFrame diff --git a/app/views/play/level/tome/spell_palette_view.coffee b/app/views/play/level/tome/spell_palette_view.coffee index 8085b6145..2ba25e5ed 100644 --- a/app/views/play/level/tome/spell_palette_view.coffee +++ b/app/views/play/level/tome/spell_palette_view.coffee @@ -44,6 +44,7 @@ module.exports = class SpellPaletteView extends View allDocs = {} for lc in lcs for doc in (lc.get('propertyDocumentation') ? []) + doc = _.clone doc allDocs['__' + doc.name] ?= [] allDocs['__' + doc.name].push doc if doc.type is 'snippet' then doc.owner = 'snippets' From 939c5faa1a686a70c6bc733c2cc05f494fef973f Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Wed, 12 Mar 2014 09:15:37 -0700 Subject: [PATCH 19/24] Fixed a bug when a thang has multiple effects. --- app/lib/surface/CocoSprite.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/app/lib/surface/CocoSprite.coffee b/app/lib/surface/CocoSprite.coffee index b454031e1..1870b543b 100644 --- a/app/lib/surface/CocoSprite.coffee +++ b/app/lib/surface/CocoSprite.coffee @@ -402,6 +402,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass if @previousEffectNames for effect in @previousEffectNames + continue if effect in @thang.effectNames mark = @marks[effect] mark.toggle false From bd129f58240200769dafe1a6e1d0a9cca47dda9d Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Wed, 12 Mar 2014 17:19:47 +0100 Subject: [PATCH 20/24] No dropdown for sound in readOnly Treemas. --- app/treema-ext.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/treema-ext.coffee b/app/treema-ext.coffee index 9112abaa6..9707086eb 100644 --- a/app/treema-ext.coffee +++ b/app/treema-ext.coffee @@ -106,7 +106,7 @@ class SoundFileTreema extends TreemaNode.nodeMap.string if @data valEl.append(playButton) valEl.append(stopButton) - valEl.append(dropdown) if files.length + valEl.append(dropdown) if files.length and @canEdit() if @data path = @data.split('/') name = path[path.length-1] From f83fe6ce14cd2598112d459e70c639bec9ec128f Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Wed, 12 Mar 2014 09:31:45 -0700 Subject: [PATCH 21/24] Fixed bugs with sprite rotation updating. --- app/lib/surface/CocoSprite.coffee | 16 ++++++++-------- app/views/contribute/artisan_view.coffee | 2 ++ app/views/play_view.coffee | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/lib/surface/CocoSprite.coffee b/app/lib/surface/CocoSprite.coffee index 821271c11..54b94adc6 100644 --- a/app/lib/surface/CocoSprite.coffee +++ b/app/lib/surface/CocoSprite.coffee @@ -171,15 +171,15 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass # Gets the sprite to reflect what the current state of the thangs and surface are return if @stillLoading @updatePosition() - return unless frameChanged - @updateScale() - @updateAlpha() - @updateRotation() - @updateAction() - @updateStats() + if frameChanged + @updateScale() + @updateAlpha() + @updateRotation() + @updateAction() + @updateStats() + @updateGold() @updateMarks() @updateLabels() - @updateGold() cache: -> bounds = @imageObject.getBounds() @@ -252,7 +252,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass return unless @currentAction return if _.string.endsWith(@currentAction.name, 'back') return if _.string.endsWith(@currentAction.name, 'fore') - @imageObject.scaleX *= -1 if Math.abs(rotation) >= 90 + imageObject.scaleX *= -1 if Math.abs(rotation) >= 90 ################################################## updateAction: -> diff --git a/app/views/contribute/artisan_view.coffee b/app/views/contribute/artisan_view.coffee index cdef4a204..b7d184d57 100644 --- a/app/views/contribute/artisan_view.coffee +++ b/app/views/contribute/artisan_view.coffee @@ -19,4 +19,6 @@ module.exports = class ArtisanView extends ContributeClassView {name: "Axandre Oge", avatar: "axandre"} {name: "Katharine Chan", avatar: "katharine"} {name: "Derek Wong", avatar: "derek"} + {name: "Alexandru Caciulescu", avatar: ""} + {name: "Prabh Simran Singh Baweja", avatar: ""} ] diff --git a/app/views/play_view.coffee b/app/views/play_view.coffee index fc3cb7a2c..f220427ea 100644 --- a/app/views/play_view.coffee +++ b/app/views/play_view.coffee @@ -166,9 +166,9 @@ module.exports = class PlayView extends View difficulty: 1 id: 'sword-loop' image: '/file/db/level/525dc5589a0765e496000006/drink_me_icon.png' - description: 'Kill the ogres and save the peasants and their cattle' + description: 'Kill the ogres and save the peasants and their cattle. - by Prabh Simran Singh Baweja' } - + { name: 'Enemy Artillery' difficulty: 1 From 49ab47e3fee7bfc1d860c1cd8c43c40cbb1f72a5 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Wed, 12 Mar 2014 10:01:31 -0700 Subject: [PATCH 22/24] Allowing shift+space to insert spaces as well as end scripts. Not ideal yet, 'cause we can't selectively not insert the space when canceling a script. --- app/views/play/level/tome/spell_view.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/play/level/tome/spell_view.coffee b/app/views/play/level/tome/spell_view.coffee index dd9875b16..e8de8e198 100644 --- a/app/views/play/level/tome/spell_view.coffee +++ b/app/views/play/level/tome/spell_view.coffee @@ -91,6 +91,9 @@ module.exports = class SpellView extends View addCommand name: 'end-current-script' bindKey: {win: 'Shift-Space', mac: 'Shift-Space'} + passEvent: true # https://github.com/ajaxorg/ace/blob/master/lib/ace/keyboard/keybinding.js#L114 + # No easy way to selectively cancel shift+space, since we don't get access to the event. + # Maybe we could temporarily set ourselves to read-only if we somehow know that a script is active? exec: -> Backbone.Mediator.publish 'level:shift-space-pressed' addCommand name: 'end-all-scripts' From 6563f43511d6b8acf788fbba69524fdcc4bec279 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Wed, 12 Mar 2014 10:07:18 -0700 Subject: [PATCH 23/24] Edited fallback route to use all methods in fallback --- server_setup.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server_setup.coffee b/server_setup.coffee index d15035c53..437464f14 100644 --- a/server_setup.coffee +++ b/server_setup.coffee @@ -84,7 +84,7 @@ exports.setupMiddleware = (app) -> ###Routing function implementations### setupFallbackRouteToIndex = (app) -> - app.get '*', (req, res) -> + app.all '*', (req, res) -> res.sendfile path.join(__dirname, 'public', 'index.html') setupFacebookCrossDomainCommunicationRoute = (app) -> From fe93d31929e83bd54b8d99d6623b32305bf97ea8 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Wed, 12 Mar 2014 10:08:57 -0700 Subject: [PATCH 24/24] Fixed loading marks so they are positioned correctly when they load and the world is paused. --- app/lib/surface/Mark.coffee | 1 + app/lib/surface/SpriteBoss.coffee | 1 + 2 files changed, 2 insertions(+) diff --git a/app/lib/surface/Mark.coffee b/app/lib/surface/Mark.coffee index 62801a60f..a343d745d 100644 --- a/app/lib/surface/Mark.coffee +++ b/app/lib/surface/Mark.coffee @@ -155,6 +155,7 @@ module.exports = class Mark extends CocoClass onLoadedThangType: -> @build() @toggle(@toggleTo) if @toggleTo? + Backbone.Mediator.publish 'sprite:loaded' update: (pos=null) -> return false unless @on and @mark diff --git a/app/lib/surface/SpriteBoss.coffee b/app/lib/surface/SpriteBoss.coffee index 004934105..fa43720cc 100644 --- a/app/lib/surface/SpriteBoss.coffee +++ b/app/lib/surface/SpriteBoss.coffee @@ -22,6 +22,7 @@ module.exports = class SpriteBoss extends CocoClass 'god:new-world-created': 'onNewWorld' 'tome:cast-spells': 'onCastSpells' 'camera:dragged': 'onCameraDragged' + 'sprite:loaded': -> @update(true) constructor: (@options) -> super()