mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-02 03:47:09 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
b414886878
14 changed files with 48 additions and 28 deletions
|
@ -19,8 +19,8 @@ module.exports = class LevelComponent extends CocoModel
|
||||||
@set 'js', @compile(@get 'code') unless @get 'js'
|
@set 'js', @compile(@get 'code') unless @get 'js'
|
||||||
|
|
||||||
compile: (code) ->
|
compile: (code) ->
|
||||||
if @get('language') and @get('language') isnt 'coffeescript'
|
if @get('codeLanguage') and @get('codeLanguage') isnt 'coffeescript'
|
||||||
return console.error("Can't compile", @get('language'), "-- only CoffeeScript.", @)
|
return console.error("Can't compile", @get('codeLanguage'), "-- only CoffeeScript.", @)
|
||||||
try
|
try
|
||||||
js = CoffeeScript.compile(code, bare: true)
|
js = CoffeeScript.compile(code, bare: true)
|
||||||
catch e
|
catch e
|
||||||
|
|
|
@ -21,8 +21,8 @@ module.exports = class LevelSystem extends CocoModel
|
||||||
SystemNameLoader.setName @
|
SystemNameLoader.setName @
|
||||||
|
|
||||||
compile: (code) ->
|
compile: (code) ->
|
||||||
if @get('language') and @get('language') isnt 'coffeescript'
|
if @get('codeLanguage') and @get('codeLanguage') isnt 'coffeescript'
|
||||||
return console.error("Can't compile", @get('language'), "-- only CoffeeScript.", @)
|
return console.error("Can't compile", @get('codeLanguage'), "-- only CoffeeScript.", @)
|
||||||
try
|
try
|
||||||
js = CoffeeScript.compile(code, bare: true)
|
js = CoffeeScript.compile(code, bare: true)
|
||||||
catch e
|
catch e
|
||||||
|
|
|
@ -60,13 +60,13 @@ DependencySchema = c.object {
|
||||||
LevelComponentSchema = c.object {
|
LevelComponentSchema = c.object {
|
||||||
title: "Component"
|
title: "Component"
|
||||||
description: "A Component which can affect Thang behavior."
|
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":
|
"default":
|
||||||
system: "ai"
|
system: "ai"
|
||||||
name: "AttacksSelf"
|
name: "AttacksSelf"
|
||||||
description: "This Component makes the Thang attack itself."
|
description: "This Component makes the Thang attack itself."
|
||||||
code: attackSelfCode
|
code: attackSelfCode
|
||||||
language: "coffeescript"
|
codeLanguage: "coffeescript"
|
||||||
dependencies: [] # TODO: should depend on something by default
|
dependencies: [] # TODO: should depend on something by default
|
||||||
propertyDocumentation: []
|
propertyDocumentation: []
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ _.extend LevelComponentSchema.properties,
|
||||||
type: "string"
|
type: "string"
|
||||||
maxLength: 2000
|
maxLength: 2000
|
||||||
"default": "This Component makes the Thang attack itself."
|
"default": "This Component makes the Thang attack itself."
|
||||||
language:
|
codeLanguage:
|
||||||
type: "string"
|
type: "string"
|
||||||
title: "Language"
|
title: "Language"
|
||||||
description: "Which programming language this Component is written in."
|
description: "Which programming language this Component is written in."
|
||||||
|
|
|
@ -54,12 +54,12 @@ DependencySchema = c.object {
|
||||||
LevelSystemSchema = c.object {
|
LevelSystemSchema = c.object {
|
||||||
title: "System"
|
title: "System"
|
||||||
description: "A System which can affect Level behavior."
|
description: "A System which can affect Level behavior."
|
||||||
required: ["name", "description", "code", "dependencies", "propertyDocumentation", "language"]
|
required: ["name", "description", "code", "dependencies", "propertyDocumentation", "codeLanguage"]
|
||||||
"default":
|
"default":
|
||||||
name: "JitterSystem"
|
name: "JitterSystem"
|
||||||
description: "This System makes all idle, movable Thangs jitter around."
|
description: "This System makes all idle, movable Thangs jitter around."
|
||||||
code: jitterSystemCode
|
code: jitterSystemCode
|
||||||
language: "coffeescript"
|
codeLanguage: "coffeescript"
|
||||||
dependencies: [] # TODO: should depend on something by default
|
dependencies: [] # TODO: should depend on something by default
|
||||||
propertyDocumentation: []
|
propertyDocumentation: []
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ _.extend LevelSystemSchema.properties,
|
||||||
type: "string"
|
type: "string"
|
||||||
maxLength: 2000
|
maxLength: 2000
|
||||||
"default": "This System doesn't do anything yet."
|
"default": "This System doesn't do anything yet."
|
||||||
language:
|
codeLanguage:
|
||||||
type: "string"
|
type: "string"
|
||||||
title: "Language"
|
title: "Language"
|
||||||
description: "Which programming language this System is written in."
|
description: "Which programming language this System is written in."
|
||||||
|
|
|
@ -222,11 +222,11 @@ block content
|
||||||
h3.edit-label Tag your programming skills
|
h3.edit-label Tag your programming skills
|
||||||
each skill in ["python", "coffeescript", "node", "ios", "objective-c", "javascript", "app-engine", "mongodb", "web dev", "django", "backbone"]
|
each skill in ["python", "coffeescript", "node", "ios", "objective-c", "javascript", "app-engine", "mongodb", "web dev", "django", "backbone"]
|
||||||
code.edit-example-tag= skill
|
code.edit-example-tag= skill
|
||||||
span
|
span
|
||||||
else
|
else
|
||||||
each skill in profile.skills
|
each skill in profile.skills
|
||||||
code= skill
|
code= skill
|
||||||
span
|
span
|
||||||
|
|
||||||
form.editable-form
|
form.editable-form
|
||||||
.editable-icon.glyphicon.glyphicon-remove
|
.editable-icon.glyphicon.glyphicon-remove
|
||||||
|
@ -267,7 +267,7 @@ block content
|
||||||
img.header-icon(src="/images/pages/account/profile/work.png", alt="")
|
img.header-icon(src="/images/pages/account/profile/work.png", alt="")
|
||||||
span(data-i18n="account_profile.work_experience") Work Experience
|
span(data-i18n="account_profile.work_experience") Work Experience
|
||||||
| - #{profile.experience}
|
| - #{profile.experience}
|
||||||
|
|
|
|
||||||
span(data-i18n=profile.experience == 1 ? "units.year" : "units.years")
|
span(data-i18n=profile.experience == 1 ? "units.year" : "units.years")
|
||||||
each job in profile.work
|
each job in profile.work
|
||||||
if job.role && job.employer
|
if job.role && job.employer
|
||||||
|
@ -454,9 +454,9 @@ block content
|
||||||
else if user
|
else if user
|
||||||
.public-profile-container
|
.public-profile-container
|
||||||
h2
|
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= 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))
|
img.profile-photo(src=user.getPhotoURL(256))
|
||||||
|
|
||||||
|
@ -465,8 +465,8 @@ block content
|
||||||
else
|
else
|
||||||
.public-profile-container
|
.public-profile-container
|
||||||
h2
|
h2
|
||||||
span(data-i18n="account_profile.profile_for_prefix") Profile for
|
span(data-i18n="account_profile.profile_for_prefix") Profile for
|
||||||
span= userID
|
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")
|
span(data-i18n="loading_error.not_found")
|
||||||
|
|
|
@ -8,7 +8,7 @@ SaveVersionModal = require 'views/modal/save_version_modal'
|
||||||
module.exports = class LevelComponentEditView extends View
|
module.exports = class LevelComponentEditView extends View
|
||||||
id: "editor-level-component-edit-view"
|
id: "editor-level-component-edit-view"
|
||||||
template: template
|
template: template
|
||||||
editableSettings: ['name', 'description', 'system', 'language', 'dependencies', 'propertyDocumentation', 'i18n']
|
editableSettings: ['name', 'description', 'system', 'codeLanguage', 'dependencies', 'propertyDocumentation', 'i18n']
|
||||||
|
|
||||||
events:
|
events:
|
||||||
'click #done-editing-component-button': 'endEditing'
|
'click #done-editing-component-button': 'endEditing'
|
||||||
|
|
|
@ -8,7 +8,7 @@ SaveVersionModal = require 'views/modal/save_version_modal'
|
||||||
module.exports = class LevelSystemEditView extends View
|
module.exports = class LevelSystemEditView extends View
|
||||||
id: "editor-level-system-edit-view"
|
id: "editor-level-system-edit-view"
|
||||||
template: template
|
template: template
|
||||||
editableSettings: ['name', 'description', 'language', 'dependencies', 'propertyDocumentation', 'i18n']
|
editableSettings: ['name', 'description', 'codeLanguage', 'dependencies', 'propertyDocumentation', 'i18n']
|
||||||
|
|
||||||
events:
|
events:
|
||||||
'click #done-editing-system-button': 'endEditing'
|
'click #done-editing-system-button': 'endEditing'
|
||||||
|
|
|
@ -12,6 +12,7 @@ LevelComponentSchema.plugin plugins.PermissionsPlugin
|
||||||
LevelComponentSchema.plugin plugins.VersionedPlugin
|
LevelComponentSchema.plugin plugins.VersionedPlugin
|
||||||
LevelComponentSchema.plugin plugins.SearchablePlugin, {searchable: ['name', 'description', 'system']}
|
LevelComponentSchema.plugin plugins.SearchablePlugin, {searchable: ['name', 'description', 'system']}
|
||||||
LevelComponentSchema.plugin plugins.PatchablePlugin
|
LevelComponentSchema.plugin plugins.PatchablePlugin
|
||||||
|
LevelComponentSchema.plugin plugins.MigrationPlugin, {'language': 'codeLanguage'}
|
||||||
|
|
||||||
LevelComponentSchema.pre 'init', (next) ->
|
LevelComponentSchema.pre 'init', (next) ->
|
||||||
return next() unless jsonschema.properties?
|
return next() unless jsonschema.properties?
|
||||||
|
|
|
@ -11,6 +11,7 @@ LevelSystemSchema.plugin(plugins.PermissionsPlugin)
|
||||||
LevelSystemSchema.plugin(plugins.VersionedPlugin)
|
LevelSystemSchema.plugin(plugins.VersionedPlugin)
|
||||||
LevelSystemSchema.plugin(plugins.SearchablePlugin, {searchable: ['name', 'description']})
|
LevelSystemSchema.plugin(plugins.SearchablePlugin, {searchable: ['name', 'description']})
|
||||||
LevelSystemSchema.plugin(plugins.PatchablePlugin)
|
LevelSystemSchema.plugin(plugins.PatchablePlugin)
|
||||||
|
LevelSystemSchema.plugin plugins.MigrationPlugin, {'language': 'codeLanguage'}
|
||||||
|
|
||||||
LevelSystemSchema.pre 'init', (next) ->
|
LevelSystemSchema.pre 'init', (next) ->
|
||||||
return next() unless jsonschema.properties?
|
return next() unless jsonschema.properties?
|
||||||
|
|
|
@ -2,6 +2,24 @@ mongoose = require('mongoose')
|
||||||
User = require('../users/User')
|
User = require('../users/User')
|
||||||
textSearch = require('mongoose-text-search')
|
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.<collection>.update({}, { $rename: {'<oldname>':'<newname>'} }) 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) ->
|
module.exports.PatchablePlugin = (schema) ->
|
||||||
schema.is_patchable = true
|
schema.is_patchable = true
|
||||||
schema.index({'target.original':1, 'status':'1', 'created':-1})
|
schema.index({'target.original':1, 'status':'1', 'created':-1})
|
||||||
|
|
|
@ -6,7 +6,7 @@ describe 'LevelComponent', ->
|
||||||
name:'BashesEverything'
|
name:'BashesEverything'
|
||||||
description:'Makes the unit uncontrollably bash anything bashable, using the bash system.'
|
description:'Makes the unit uncontrollably bash anything bashable, using the bash system.'
|
||||||
code: 'bash();'
|
code: 'bash();'
|
||||||
language: 'coffeescript'
|
codeLanguage: 'coffeescript'
|
||||||
permissions:simplePermissions
|
permissions:simplePermissions
|
||||||
propertyDocumentation: []
|
propertyDocumentation: []
|
||||||
system: 'ai'
|
system: 'ai'
|
||||||
|
@ -35,7 +35,7 @@ describe 'LevelComponent', ->
|
||||||
expect(body.name).toBe(component.name)
|
expect(body.name).toBe(component.name)
|
||||||
expect(body.description).toBe(component.description)
|
expect(body.description).toBe(component.description)
|
||||||
expect(body.code).toBe(component.code)
|
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.__v).toBe(0)
|
||||||
expect(body.creator).toBeDefined()
|
expect(body.creator).toBeDefined()
|
||||||
expect(body.original).toBeDefined()
|
expect(body.original).toBeDefined()
|
||||||
|
@ -69,7 +69,7 @@ describe 'LevelComponent', ->
|
||||||
expect(body.slug).toBeDefined()
|
expect(body.slug).toBeDefined()
|
||||||
expect(body.description).toBe(components[0].description)
|
expect(body.description).toBe(components[0].description)
|
||||||
expect(body.code).toBe(components[0].code)
|
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.__v).toBe(0)
|
||||||
expect(body.official).toBeDefined()
|
expect(body.official).toBeDefined()
|
||||||
expect(body.creator).toBeDefined()
|
expect(body.creator).toBeDefined()
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe 'LevelSystem', ->
|
||||||
constructor: (world) ->
|
constructor: (world) ->
|
||||||
super world
|
super world
|
||||||
"""
|
"""
|
||||||
language: 'coffeescript'
|
codeLanguage: 'coffeescript'
|
||||||
permissions:simplePermissions
|
permissions:simplePermissions
|
||||||
dependencies: []
|
dependencies: []
|
||||||
propertyDocumentation: []
|
propertyDocumentation: []
|
||||||
|
@ -37,7 +37,7 @@ describe 'LevelSystem', ->
|
||||||
expect(body.name).toBe(system.name)
|
expect(body.name).toBe(system.name)
|
||||||
expect(body.description).toBe(system.description)
|
expect(body.description).toBe(system.description)
|
||||||
expect(body.code).toBe(system.code)
|
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.__v).toBe(0)
|
||||||
expect(body.creator).toBeDefined()
|
expect(body.creator).toBeDefined()
|
||||||
expect(body.original).toBeDefined()
|
expect(body.original).toBeDefined()
|
||||||
|
@ -71,7 +71,7 @@ describe 'LevelSystem', ->
|
||||||
expect(body.slug).toBeDefined()
|
expect(body.slug).toBeDefined()
|
||||||
expect(body.description).toBe(systems[0].description)
|
expect(body.description).toBe(systems[0].description)
|
||||||
expect(body.code).toBe(systems[0].code)
|
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.__v).toBe(0)
|
||||||
expect(body.official).toBeDefined()
|
expect(body.official).toBeDefined()
|
||||||
expect(body.creator).toBeDefined()
|
expect(body.creator).toBeDefined()
|
||||||
|
|
|
@ -6,7 +6,7 @@ describe 'LevelComponent', ->
|
||||||
name:'Bashes Everything'
|
name:'Bashes Everything'
|
||||||
description:'Makes the unit uncontrollably bash anything bashable, using the bash system.'
|
description:'Makes the unit uncontrollably bash anything bashable, using the bash system.'
|
||||||
code: 'bash();'
|
code: 'bash();'
|
||||||
language: 'javascript'
|
codeLanguage: 'javascript'
|
||||||
official: true
|
official: true
|
||||||
permissions:simplePermissions
|
permissions:simplePermissions
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe 'LevelSystem', ->
|
||||||
constructor: (world) ->
|
constructor: (world) ->
|
||||||
super world
|
super world
|
||||||
"""
|
"""
|
||||||
language: 'coffeescript'
|
codeLanguage: 'coffeescript'
|
||||||
official: true
|
official: true
|
||||||
permissions:simplePermissions
|
permissions:simplePermissions
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue