Merge branch 'master' into production

This commit is contained in:
Nick Winter 2014-11-29 13:10:48 -08:00
commit 2eb8441911
77 changed files with 96 additions and 81 deletions

View file

@ -9,7 +9,6 @@ module.exports = ModuleLoader = class ModuleLoader extends CocoClass
@WADS = [
'lib'
'views/play'
'views/game-menu'
'views/editor'
]

View file

@ -1,4 +1,4 @@
errorModalTemplate = require 'templates/modal/error'
errorModalTemplate = require 'templates/core/error'
{applyErrorsToForm} = require 'core/forms'
module.exports.parseServerError = (text) ->
@ -42,7 +42,7 @@ module.exports.connectionFailure = connectionFailure = ->
showErrorModal(html)
showErrorModal = (html) ->
# TODO: make a views/modal/error_modal view for this to use so the template can reuse templates/modal/modal_base?
# TODO: make a views/modal/error_modal view for this to use so the template can reuse templates/core/modal-base?
$('#modal-wrapper').html(html)
$('.modal:visible').modal('hide')
$('#modal-error').modal('show')

View file

@ -130,3 +130,13 @@ module.exports.kindaEqual = compare = (l, r) ->
return true
else
return false
# Fast, basic way to replace text in an element when you don't need much.
# http://stackoverflow.com/a/4962398/540620
if document?
dummy = document.createElement 'div'
dummy.innerHTML = 'text'
TEXT = if dummy.textContent is 'text' then 'textContent' else 'innerText'
module.exports.replaceText = (elems, text) ->
elem[TEXT] = text for elem in elems
null

View file

@ -1,6 +1,6 @@
CocoClass = require 'core/CocoClass'
PlayHeroesModal = require 'views/play/modal/PlayHeroesModal'
InventoryModal = require 'views/game-menu/InventoryModal'
InventoryModal = require 'views/play/menu/InventoryModal'
LevelSession = require 'models/LevelSession'
SuperModel = require 'models/SuperModel'
ThangType = require 'models/ThangType'

View file

@ -192,7 +192,7 @@ module.exports = class LankBoss extends CocoClass
updatedObstacles = []
itemsJustEquipped = []
for thang in @world.thangs when thang.exists and thang.pos
itemsJustEquipped = itemsJustEquipped.concat @equipNewItems thang
itemsJustEquipped = itemsJustEquipped.concat @equipNewItems thang if thang.equip
if lank = @lanks[thang.id]
lank.setThang thang # make sure Lank has latest Thang
else

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3 Applicant Code for

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
if mode === 'login'

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="contact.contact_us") Contact CodeCombat...

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="diplomat_suggestion.title") Help translate CodeCombat!

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h1 Add Components

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="editor.fork_title") Fork New Version

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="editor.new_component_title") Create New Component

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="editor.pick_a_terrain") Pick a Terrain

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="editor.add_system_title") Add Systems to Level

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="editor.create_system_title") Create New System

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
.modal-header-content

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3 Choose Container for Vector Icon

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3 #{confirmTitle}

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
if userIsAnonymous || !userIsAuthorized

View file

@ -1,4 +1,4 @@
extends /templates/modal/contact
extends /templates/core/contact
block modal-header-content
h3(data-i18n="contact.contact_candidate") Contact Candidate

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="#{currentNew}") Create New #{modelLabel}

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="recover.recover_account_title") Recover Account

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="editor.revert_models") Revert Models

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
if isPatch

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
if dataList

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="wizard_settings.title2") Customize Your Character

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="ladder.choose_opponent") Choose an Opponent

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
img(src="/images/pages/play/level/modal/victory_modal_blue_banner.png")#victory-banner
img(src="/images/pages/play/level/modal/victory_word.png")#victory-header.out

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="play_level.infinite_loop_title") Infinite Loop Detected

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="keyboard_shortcuts.keyboard_shortcuts") Keyboard Shortcuts

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="play_level.reload_title") Reload All Code?

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="play.account") Account

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="play.achievements") Achievements

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h1#choose-hero-header.choose-hero-active.secret(data-i18n="choose_hero.choose_hero") Choose Your Hero

View file

@ -1,4 +1,4 @@
extends /templates/modal/modal_base
extends /templates/core/modal-base
block modal-header-content
h3(data-i18n="play.settings") Settings

View file

@ -1,5 +1,5 @@
RootView = require 'views/core/RootView'
template = require 'templates/community'
template = require 'templates/community-view'
module.exports = class CommunityView extends RootView
id: 'community-view'

View file

@ -1,5 +1,5 @@
RootView = require 'views/core/RootView'
template = require 'templates/home'
template = require 'templates/home-view'
module.exports = class HomeView extends RootView
id: 'home-view'

View file

@ -1,5 +1,5 @@
CocoView = require 'views/core/CocoView'
template = require 'templates/achievements/achievement-popup'
template = require 'templates/core/achievement-popup'
User = require '../../models/User'
Achievement = require '../../models/Achievement'

View file

@ -1,8 +1,8 @@
SuperModel = require 'models/SuperModel'
utils = require 'core/utils'
CocoClass = require 'core/CocoClass'
loadingScreenTemplate = require 'templates/loading'
loadingErrorTemplate = require 'templates/loading_error'
loadingScreenTemplate = require 'templates/core/loading'
loadingErrorTemplate = require 'templates/core/loading-error'
lastToggleModalCall = 0
visibleModal = null

View file

@ -1,5 +1,5 @@
ModalView = require 'views/core/ModalView'
template = require 'templates/modal/contact'
template = require 'templates/core/contact'
forms = require 'core/forms'
{sendContactMessage} = require 'core/contact'

View file

@ -1,5 +1,5 @@
ModalView = require 'views/core/ModalView'
template = require 'templates/modal/diplomat_suggestion'
template = require 'templates/core/diplomat-suggestion'
{me} = require 'core/auth'
forms = require 'core/forms'

View file

@ -7,7 +7,7 @@ module.exports = class ModalView extends CocoView
modalWidthPercent: null
plain: false
instant: false
template: require 'templates/modal/modal_base'
template: require 'templates/core/modal-base'
events:
'click a': 'toggleModal'

View file

@ -1,5 +1,5 @@
RootView = require 'views/core/RootView'
template = require 'templates/not_found'
template = require 'templates/core/not-found'
module.exports = class NotFoundView extends RootView
id: 'not-found-view'

View file

@ -1,5 +1,5 @@
ModalView = require 'views/core/ModalView'
template = require 'templates/modal/model'
template = require 'templates/modal/model-modal'
module.exports = class ModelModal extends ModalView
id: 'model-modal'

View file

@ -1,5 +1,5 @@
RootView = require 'views/core/RootView'
template = require 'templates/main-play-view'
template = require 'templates/play/main-play-view'
LevelSession = require 'models/LevelSession'
CocoCollection = require 'collections/CocoCollection'

View file

@ -2,11 +2,11 @@ CocoView = require 'views/core/CocoView'
template = require 'templates/play/level/control_bar'
{me} = require 'core/auth'
GameMenuModal = require 'views/game-menu/GameMenuModal'
GameMenuModal = require 'views/play/menu/GameMenuModal'
RealTimeModel = require 'models/RealTimeModel'
RealTimeCollection = require 'collections/RealTimeCollection'
LevelSetupManager = require 'lib/LevelSetupManager'
GameMenuModal = require 'views/game-menu/GameMenuModal'
GameMenuModal = require 'views/play/menu/GameMenuModal'
CampaignOptions = require 'lib/CampaignOptions'
module.exports = class ControlBarView extends CocoView

View file

@ -2,6 +2,7 @@ CocoView = require 'views/core/CocoView'
template = require 'templates/play/level/hud'
prop_template = require 'templates/play/level/hud_prop'
LevelOptions = require 'lib/LevelOptions'
utils = require 'core/utils'
module.exports = class LevelHUDView extends CocoView
id: 'thang-hud'
@ -104,7 +105,7 @@ module.exports = class LevelHUDView extends CocoView
name = {knight: 'Tharin', captain: 'Anya', librarian: 'Hushbaum', sorcerer: 'Pender', 'potion-master': 'Omarn', samurai: 'Hattori', ninja: 'Amara'}[@thang.type] ? 'Hero'
else
name = if @thang.type then "#{@thang.id} - #{@thang.type}" else @thang.id
@$el.find('.thang-name').text name
utils.replaceText @$el.find('.thang-name'), name
props = @$el.find('.thang-props')
props.find('.prop').remove()
#propNames = _.without @thang.hudProperties ? [], 'action'
@ -145,7 +146,7 @@ module.exports = class LevelHUDView extends CocoView
labelText = prop + ': ' + @formatValue(prop, val) + ' / ' + @formatValue(prop, max)
if regen
labelText += ' (+' + @formatValue(prop, regen) + '/s)'
pel.find('.bar-prop-value').text(Math.round(max)) if max
utils.replaceText pel.find('.bar-prop-value'), Math.round(val)
else
s = @formatValue(prop, val)
labelText = "#{prop}: #{s}"
@ -153,7 +154,7 @@ module.exports = class LevelHUDView extends CocoView
cooldown = @thang.actions.attack.cooldown
dps = @thang.attackDamage / cooldown
labelText += " / #{cooldown.toFixed(2)}s (DPS: #{dps.toFixed(2)})"
pel.find('.prop-value').text s
utils.replaceText pel.find('.prop-value'), s
pel.attr 'title', labelText
pel

View file

@ -1,10 +1,10 @@
ModalView = require 'views/core/ModalView'
template = require 'templates/game-menu/game-menu-modal'
template = require 'templates/play/menu/game-menu-modal'
submenuViews = [
require 'views/game-menu/SaveLoadView'
require 'views/game-menu/OptionsView'
require 'views/game-menu/GuideView'
require 'views/game-menu/MultiplayerView'
require 'views/play/menu/SaveLoadView'
require 'views/play/menu/OptionsView'
require 'views/play/menu/GuideView'
require 'views/play/menu/MultiplayerView'
]
module.exports = class GameMenuModal extends ModalView

View file

@ -1,5 +1,5 @@
CocoView = require 'views/core/CocoView'
template = require 'templates/game-menu/guide-view'
template = require 'templates/play/menu/guide-view'
Article = require 'models/Article'
utils = require 'core/utils'

View file

@ -1,5 +1,5 @@
ModalView = require 'views/core/ModalView'
template = require 'templates/game-menu/inventory-modal'
template = require 'templates/play/menu/inventory-modal'
buyGemsPromptTemplate = require 'templates/play/modal/buy-gems-prompt'
{me} = require 'core/auth'
ThangType = require 'models/ThangType'

View file

@ -1,5 +1,5 @@
CocoView = require 'views/core/CocoView'
template = require 'templates/game-menu/item-view'
template = require 'templates/play/menu/item-view'
module.exports = class ItemView extends CocoView
className: 'item-view'

View file

@ -1,5 +1,5 @@
CocoView = require 'views/core/CocoView'
template = require 'templates/game-menu/multiplayer-view'
template = require 'templates/play/menu/multiplayer-view'
{me} = require 'core/auth'
ThangType = require 'models/ThangType'
LadderSubmissionView = require 'views/play/common/LadderSubmissionView'

View file

@ -1,5 +1,5 @@
CocoView = require 'views/core/CocoView'
template = require 'templates/game-menu/options-view'
template = require 'templates/play/menu/options-view'
{me} = require 'core/auth'
ThangType = require 'models/ThangType'
User = require 'models/User'

View file

@ -1,5 +1,5 @@
CocoView = require 'views/core/CocoView'
template = require 'templates/game-menu/save-load-view'
template = require 'templates/play/menu/save-load-view'
{me} = require 'core/auth'
ThangType = require 'models/ThangType'

View file

@ -35,7 +35,6 @@
"aether": "~0.2.39",
"underscore.string": "~2.3.3",
"firebase": "~1.0.2",
"catiline": "~2.9.3",
"d3": "~3.4.4",
"jsondiffpatch": "0.1.8",
"nanoscroller": "~0.8.0",

View file

@ -72,7 +72,6 @@ exports.config =
#- Wads. Groups of modules by folder which are loaded as a group when needed.
'javascripts/app/lib.js': regJoin('^app/lib')
'javascripts/app/views/play.js': regJoin('^app/views/play')
'javascripts/app/views/game-menu.js': regJoin('^app/views/game-menu')
'javascripts/app/views/editor.js': regJoin('^app/views/editor')
#- world.js, used by the worker to generate the world in game
@ -140,17 +139,7 @@ exports.config =
templates:
defaultExtension: 'jade'
joinTo:
'javascripts/app.js': [
regJoin('^app/templates/core')
'app/templates/modal/error.jade'
'app/templates/not_found.jade'
'app/templates/achievements/achievement-popup.jade'
'app/templates/loading.jade'
'app/templates/loading_error.jade'
'app/templates/modal/contact.jade'
'app/templates/modal/modal_base.jade'
'app/templates/modal/diplomat_suggestion.jade'
]
'javascripts/app.js': regJoin('^app/templates/core')
'javascripts/app/views/play.js': regJoin('^app/templates/play')
'javascripts/app/views/game-menu.js': regJoin('^app/templates/game-menu')
'javascripts/app/views/editor.js': regJoin('^app/templates/editor')
@ -195,8 +184,20 @@ for file in coffeeFiles
inputFile = file.replace('./app', 'app')
outputFile = file.replace('.coffee', '.js').replace('./app', 'javascripts/app')
exports.config.files.javascripts.joinTo[outputFile] = inputFile
numBundles = 0
for file in jadeFiles
inputFile = file.replace('./app', 'app')
outputFile = file.replace('.jade', '.js').replace('./app', 'javascripts/app')
exports.config.files.templates.joinTo[outputFile] = inputFile
exports.config.files.templates.joinTo[outputFile] = inputFile
#- If a view template name matches its view, bundle it in there.
templateFileName = outputFile.match(/[^/]+$/)[0]
viewFileName = _.str.capitalize(_.str.camelize(templateFileName))
possibleViewFilePath = outputFile.replace(templateFileName, viewFileName).replace('/templates/', '/views/')
if exports.config.files.javascripts.joinTo[possibleViewFilePath]
exports.config.files.templates.joinTo[possibleViewFilePath] = inputFile
numBundles += 1
console.log 'Bundled', numBundles, 'templates with their views.'

View file

@ -298,6 +298,8 @@ module.exports = class Handler
getLatestVersion: (req, res, original, version) ->
# can get latest overall version, latest of a major version, or a specific version
return @sendBadInputError(res, 'Invalid MongoDB id: '+original) if not Handler.isID(original)
query = { 'original': mongoose.Types.ObjectId(original) }
if version?
version = version.split('.')

View file

@ -42,7 +42,10 @@ developmentLogging = (tokens, req, res) ->
setupErrorMiddleware = (app) ->
app.use (err, req, res, next) ->
if err
res.status(500).send(error: "Something went wrong!")
if err.status and 400 <= err.status < 500
res.status(err.status).send("Error #{err.status}")
return
res.status(err.status ? 500).send(error: "Something went wrong!")
message = "Express error: #{req.method} #{req.path}: #{err.message}"
log.error "#{message}, stack: #{err.stack}"
hipchat.sendTowerHipChatMessage(message)