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'
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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."
|
||||
|
|
|
@ -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."
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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.<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) ->
|
||||
schema.is_patchable = true
|
||||
schema.index({'target.original':1, 'status':'1', 'created':-1})
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ describe 'LevelSystem', ->
|
|||
constructor: (world) ->
|
||||
super world
|
||||
"""
|
||||
language: 'coffeescript'
|
||||
codeLanguage: 'coffeescript'
|
||||
official: true
|
||||
permissions:simplePermissions
|
||||
|
||||
|
|
Loading…
Reference in a new issue