From 86223167afb3e07b7039245b193e081ad2fbd049 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Tue, 10 Jun 2014 07:46:43 -0700 Subject: [PATCH 1/2] Re-added significant trailing whitespace. --- app/templates/account/profile.jade | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/templates/account/profile.jade b/app/templates/account/profile.jade index c96beff16..0d1511f10 100644 --- a/app/templates/account/profile.jade +++ b/app/templates/account/profile.jade @@ -222,11 +222,11 @@ block content h3.edit-label Tag your programming skills each skill in ["python", "coffeescript", "node", "ios", "objective-c", "javascript", "app-engine", "mongodb", "web dev", "django", "backbone"] code.edit-example-tag= skill - span + span else each skill in profile.skills code= skill - span + span form.editable-form .editable-icon.glyphicon.glyphicon-remove @@ -267,7 +267,7 @@ block content img.header-icon(src="/images/pages/account/profile/work.png", alt="") span(data-i18n="account_profile.work_experience") Work Experience | - #{profile.experience} - | + | span(data-i18n=profile.experience == 1 ? "units.year" : "units.years") each job in profile.work if job.role && job.employer @@ -454,9 +454,9 @@ block content else if user .public-profile-container h2 - span(data-i18n="account_profile.profile_for_prefix") Profile for + span(data-i18n="account_profile.profile_for_prefix") Profile for span= user.get('name') || "Anonymous Wizard" - span(data-i18n="account_profile.profile_for_suffix") + span(data-i18n="account_profile.profile_for_suffix") img.profile-photo(src=user.getPhotoURL(256)) @@ -465,8 +465,8 @@ block content else .public-profile-container h2 - span(data-i18n="account_profile.profile_for_prefix") Profile for + span(data-i18n="account_profile.profile_for_prefix") Profile for span= userID - span(data-i18n="account_profile.profile_for_suffix") - | + span(data-i18n="account_profile.profile_for_suffix") + | span(data-i18n="loading_error.not_found") From f0ff8c242ec9b5ad2ee12b71e9ba2c72f782911a Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Tue, 10 Jun 2014 13:20:14 -0700 Subject: [PATCH 2/2] Migrating language to codeLanguage on systems and components because they conflict with the search system. --- app/models/LevelComponent.coffee | 4 ++-- app/models/LevelSystem.coffee | 4 ++-- app/schemas/models/level_component.coffee | 6 +++--- app/schemas/models/level_system.coffee | 6 +++--- app/views/editor/level/component/edit.coffee | 2 +- app/views/editor/level/system/edit.coffee | 2 +- server/levels/components/LevelComponent.coffee | 1 + server/levels/systems/LevelSystem.coffee | 1 + server/plugins/plugins.coffee | 18 ++++++++++++++++++ .../functional/level_component.spec.coffee | 6 +++--- .../server/functional/level_system.spec.coffee | 6 +++--- .../models/LevelComponent.spec.coffee | 2 +- .../integration/models/LevelSystem.spec.coffee | 2 +- 13 files changed, 40 insertions(+), 20 deletions(-) diff --git a/app/models/LevelComponent.coffee b/app/models/LevelComponent.coffee index 9a7569ad0..3f6ef20b6 100644 --- a/app/models/LevelComponent.coffee +++ b/app/models/LevelComponent.coffee @@ -19,8 +19,8 @@ module.exports = class LevelComponent extends CocoModel @set 'js', @compile(@get 'code') unless @get 'js' compile: (code) -> - if @get('language') and @get('language') isnt 'coffeescript' - return console.error("Can't compile", @get('language'), "-- only CoffeeScript.", @) + if @get('codeLanguage') and @get('codeLanguage') isnt 'coffeescript' + return console.error("Can't compile", @get('codeLanguage'), "-- only CoffeeScript.", @) try js = CoffeeScript.compile(code, bare: true) catch e diff --git a/app/models/LevelSystem.coffee b/app/models/LevelSystem.coffee index f2ca539b4..8ba7bb264 100644 --- a/app/models/LevelSystem.coffee +++ b/app/models/LevelSystem.coffee @@ -21,8 +21,8 @@ module.exports = class LevelSystem extends CocoModel SystemNameLoader.setName @ compile: (code) -> - if @get('language') and @get('language') isnt 'coffeescript' - return console.error("Can't compile", @get('language'), "-- only CoffeeScript.", @) + if @get('codeLanguage') and @get('codeLanguage') isnt 'coffeescript' + return console.error("Can't compile", @get('codeLanguage'), "-- only CoffeeScript.", @) try js = CoffeeScript.compile(code, bare: true) catch e diff --git a/app/schemas/models/level_component.coffee b/app/schemas/models/level_component.coffee index 8552979ee..e1b101ebe 100644 --- a/app/schemas/models/level_component.coffee +++ b/app/schemas/models/level_component.coffee @@ -60,13 +60,13 @@ DependencySchema = c.object { LevelComponentSchema = c.object { title: "Component" description: "A Component which can affect Thang behavior." - required: ["system", "name", "description", "code", "dependencies", "propertyDocumentation", "language"] + required: ["system", "name", "description", "code", "dependencies", "propertyDocumentation", "codeLanguage"] "default": system: "ai" name: "AttacksSelf" description: "This Component makes the Thang attack itself." code: attackSelfCode - language: "coffeescript" + codeLanguage: "coffeescript" dependencies: [] # TODO: should depend on something by default propertyDocumentation: [] } @@ -85,7 +85,7 @@ _.extend LevelComponentSchema.properties, type: "string" maxLength: 2000 "default": "This Component makes the Thang attack itself." - language: + codeLanguage: type: "string" title: "Language" description: "Which programming language this Component is written in." diff --git a/app/schemas/models/level_system.coffee b/app/schemas/models/level_system.coffee index 1804de363..63c12919b 100644 --- a/app/schemas/models/level_system.coffee +++ b/app/schemas/models/level_system.coffee @@ -54,12 +54,12 @@ DependencySchema = c.object { LevelSystemSchema = c.object { title: "System" description: "A System which can affect Level behavior." - required: ["name", "description", "code", "dependencies", "propertyDocumentation", "language"] + required: ["name", "description", "code", "dependencies", "propertyDocumentation", "codeLanguage"] "default": name: "JitterSystem" description: "This System makes all idle, movable Thangs jitter around." code: jitterSystemCode - language: "coffeescript" + codeLanguage: "coffeescript" dependencies: [] # TODO: should depend on something by default propertyDocumentation: [] } @@ -72,7 +72,7 @@ _.extend LevelSystemSchema.properties, type: "string" maxLength: 2000 "default": "This System doesn't do anything yet." - language: + codeLanguage: type: "string" title: "Language" description: "Which programming language this System is written in." diff --git a/app/views/editor/level/component/edit.coffee b/app/views/editor/level/component/edit.coffee index 6d416e011..3bc526813 100644 --- a/app/views/editor/level/component/edit.coffee +++ b/app/views/editor/level/component/edit.coffee @@ -8,7 +8,7 @@ SaveVersionModal = require 'views/modal/save_version_modal' module.exports = class LevelComponentEditView extends View id: "editor-level-component-edit-view" template: template - editableSettings: ['name', 'description', 'system', 'language', 'dependencies', 'propertyDocumentation', 'i18n'] + editableSettings: ['name', 'description', 'system', 'codeLanguage', 'dependencies', 'propertyDocumentation', 'i18n'] events: 'click #done-editing-component-button': 'endEditing' diff --git a/app/views/editor/level/system/edit.coffee b/app/views/editor/level/system/edit.coffee index 404ac360b..6560bafa7 100644 --- a/app/views/editor/level/system/edit.coffee +++ b/app/views/editor/level/system/edit.coffee @@ -8,7 +8,7 @@ SaveVersionModal = require 'views/modal/save_version_modal' module.exports = class LevelSystemEditView extends View id: "editor-level-system-edit-view" template: template - editableSettings: ['name', 'description', 'language', 'dependencies', 'propertyDocumentation', 'i18n'] + editableSettings: ['name', 'description', 'codeLanguage', 'dependencies', 'propertyDocumentation', 'i18n'] events: 'click #done-editing-system-button': 'endEditing' diff --git a/server/levels/components/LevelComponent.coffee b/server/levels/components/LevelComponent.coffee index 6c1a58370..81529125a 100644 --- a/server/levels/components/LevelComponent.coffee +++ b/server/levels/components/LevelComponent.coffee @@ -12,6 +12,7 @@ LevelComponentSchema.plugin plugins.PermissionsPlugin LevelComponentSchema.plugin plugins.VersionedPlugin LevelComponentSchema.plugin plugins.SearchablePlugin, {searchable: ['name', 'description', 'system']} LevelComponentSchema.plugin plugins.PatchablePlugin +LevelComponentSchema.plugin plugins.MigrationPlugin, {'language': 'codeLanguage'} LevelComponentSchema.pre 'init', (next) -> return next() unless jsonschema.properties? diff --git a/server/levels/systems/LevelSystem.coffee b/server/levels/systems/LevelSystem.coffee index f945aaa95..2dc69cbc7 100644 --- a/server/levels/systems/LevelSystem.coffee +++ b/server/levels/systems/LevelSystem.coffee @@ -11,6 +11,7 @@ LevelSystemSchema.plugin(plugins.PermissionsPlugin) LevelSystemSchema.plugin(plugins.VersionedPlugin) LevelSystemSchema.plugin(plugins.SearchablePlugin, {searchable: ['name', 'description']}) LevelSystemSchema.plugin(plugins.PatchablePlugin) +LevelSystemSchema.plugin plugins.MigrationPlugin, {'language': 'codeLanguage'} LevelSystemSchema.pre 'init', (next) -> return next() unless jsonschema.properties? diff --git a/server/plugins/plugins.coffee b/server/plugins/plugins.coffee index 4b189967e..d1ab78c71 100644 --- a/server/plugins/plugins.coffee +++ b/server/plugins/plugins.coffee @@ -2,6 +2,24 @@ mongoose = require('mongoose') User = require('../users/User') textSearch = require('mongoose-text-search') +module.exports.MigrationPlugin = (schema, migrations) -> + # Property name migrations made EZ + # This is for just when you want one property to be named differently + + # 1. Change the schema and the client/server logic to use the new name + # 2. Add this plugin to the target models, passing in a dictionary of old/new names. + # 3. Check that tests still run, deploy to production. + # 4. Run db..update({}, { $rename: {'':''} }) on the server + # 5. Remove the names you added to the migrations dictionaries for the next deploy + + schema.post 'init', -> + for oldKey in _.keys migrations + val = @get oldKey + @set oldKey, undefined + continue if val is undefined + newKey = migrations[oldKey] + @set newKey, val + module.exports.PatchablePlugin = (schema) -> schema.is_patchable = true schema.index({'target.original':1, 'status':'1', 'created':-1}) diff --git a/test/server/functional/level_component.spec.coffee b/test/server/functional/level_component.spec.coffee index 9127ccefd..4269eee21 100644 --- a/test/server/functional/level_component.spec.coffee +++ b/test/server/functional/level_component.spec.coffee @@ -6,7 +6,7 @@ describe 'LevelComponent', -> name:'BashesEverything' description:'Makes the unit uncontrollably bash anything bashable, using the bash system.' code: 'bash();' - language: 'coffeescript' + codeLanguage: 'coffeescript' permissions:simplePermissions propertyDocumentation: [] system: 'ai' @@ -35,7 +35,7 @@ describe 'LevelComponent', -> expect(body.name).toBe(component.name) expect(body.description).toBe(component.description) expect(body.code).toBe(component.code) - expect(body.language).toBe(component.language) + expect(body.codeLanguage).toBe(component.codeLanguage) expect(body.__v).toBe(0) expect(body.creator).toBeDefined() expect(body.original).toBeDefined() @@ -69,7 +69,7 @@ describe 'LevelComponent', -> expect(body.slug).toBeDefined() expect(body.description).toBe(components[0].description) expect(body.code).toBe(components[0].code) - expect(body.language).toBe(components[0].language) + expect(body.codeLanguage).toBe(components[0].codeLanguage) expect(body.__v).toBe(0) expect(body.official).toBeDefined() expect(body.creator).toBeDefined() diff --git a/test/server/functional/level_system.spec.coffee b/test/server/functional/level_system.spec.coffee index 229c3a39d..c933eb8bb 100644 --- a/test/server/functional/level_system.spec.coffee +++ b/test/server/functional/level_system.spec.coffee @@ -9,7 +9,7 @@ describe 'LevelSystem', -> constructor: (world) -> super world """ - language: 'coffeescript' + codeLanguage: 'coffeescript' permissions:simplePermissions dependencies: [] propertyDocumentation: [] @@ -37,7 +37,7 @@ describe 'LevelSystem', -> expect(body.name).toBe(system.name) expect(body.description).toBe(system.description) expect(body.code).toBe(system.code) - expect(body.language).toBe(system.language) + expect(body.codeLanguage).toBe(system.codeLanguage) expect(body.__v).toBe(0) expect(body.creator).toBeDefined() expect(body.original).toBeDefined() @@ -71,7 +71,7 @@ describe 'LevelSystem', -> expect(body.slug).toBeDefined() expect(body.description).toBe(systems[0].description) expect(body.code).toBe(systems[0].code) - expect(body.language).toBe(systems[0].language) + expect(body.codeLanguage).toBe(systems[0].codeLanguage) expect(body.__v).toBe(0) expect(body.official).toBeDefined() expect(body.creator).toBeDefined() diff --git a/test/server/integration/models/LevelComponent.spec.coffee b/test/server/integration/models/LevelComponent.spec.coffee index 90dc5779d..6936fa86f 100644 --- a/test/server/integration/models/LevelComponent.spec.coffee +++ b/test/server/integration/models/LevelComponent.spec.coffee @@ -6,7 +6,7 @@ describe 'LevelComponent', -> name:'Bashes Everything' description:'Makes the unit uncontrollably bash anything bashable, using the bash system.' code: 'bash();' - language: 'javascript' + codeLanguage: 'javascript' official: true permissions:simplePermissions diff --git a/test/server/integration/models/LevelSystem.spec.coffee b/test/server/integration/models/LevelSystem.spec.coffee index 39008f9f7..d61cd98e0 100644 --- a/test/server/integration/models/LevelSystem.spec.coffee +++ b/test/server/integration/models/LevelSystem.spec.coffee @@ -9,7 +9,7 @@ describe 'LevelSystem', -> constructor: (world) -> super world """ - language: 'coffeescript' + codeLanguage: 'coffeescript' official: true permissions:simplePermissions