gzipping when in production but not going through Cloudflare.

This commit is contained in:
Nick Winter 2014-04-17 10:12:23 -07:00
parent f95d814e90
commit eec1888b22
4 changed files with 13 additions and 19 deletions

View file

@ -426,11 +426,11 @@ module.exports = class ThangsTabView extends View
@editThangView = null @editThangView = null
@onThangsChanged() @onThangsChanged()
@$el.find('.thangs-column').show() @$el.find('.thangs-column').show()
preventDefaultContextMenu: (e) -> preventDefaultContextMenu: (e) ->
return unless $(e.target).closest('#canvas-wrapper').length return unless $(e.target).closest('#canvas-wrapper').length
e.preventDefault() e.preventDefault()
onSpriteContextMenu: (e) -> onSpriteContextMenu: (e) ->
{clientX, clientY} = e.originalEvent.nativeEvent {clientX, clientY} = e.originalEvent.nativeEvent
if @addThangType if @addThangType
@ -439,11 +439,11 @@ module.exports = class ThangsTabView extends View
$('#duplicate a').html 'Duplicate' $('#duplicate a').html 'Duplicate'
$('#contextmenu').css { position: 'fixed', left: clientX, top: clientY } $('#contextmenu').css { position: 'fixed', left: clientX, top: clientY }
$('#contextmenu').show() $('#contextmenu').show()
onDeleteClicked: (e) -> onDeleteClicked: (e) ->
$('#contextmenu').hide() $('#contextmenu').hide()
@deleteSelectedExtantThang e @deleteSelectedExtantThang e
onDuplicateClicked: (e) -> onDuplicateClicked: (e) ->
$('#contextmenu').hide() $('#contextmenu').hide()
if !@addThangType if !@addThangType

View file

@ -11,6 +11,7 @@ exports.config =
ignored: (path) -> startsWith(sysPath.basename(path), '_') ignored: (path) -> startsWith(sysPath.basename(path), '_')
workers: workers:
enabled: false # turned out to be much, much slower than without workers enabled: false # turned out to be much, much slower than without workers
sourceMaps: true
files: files:
javascripts: javascripts:
defaultExtension: 'coffee' defaultExtension: 'coffee'

View file

@ -91,7 +91,8 @@
"karma-requirejs": "~0.2.1", "karma-requirejs": "~0.2.1",
"karma-phantomjs-launcher": "~0.1.1", "karma-phantomjs-launcher": "~0.1.1",
"karma": "~0.10.9", "karma": "~0.10.9",
"karma-coverage": "~0.1.4" "karma-coverage": "~0.1.4",
"compressible": "~1.0.1"
}, },
"license": "MIT for the code, and CC-BY for the art and music", "license": "MIT for the code, and CC-BY for the art and music",
"private": true, "private": true,

View file

@ -3,7 +3,8 @@ path = require 'path'
authentication = require 'passport' authentication = require 'passport'
useragent = require 'express-useragent' useragent = require 'express-useragent'
fs = require 'graceful-fs' fs = require 'graceful-fs'
log = require('winston') log = require 'winston'
compressible = require 'compressible'
database = require './server/commons/database' database = require './server/commons/database'
baseRoute = require './server/routes/base' baseRoute = require './server/routes/base'
@ -11,17 +12,7 @@ user = require './server/users/user_handler'
logging = require './server/commons/logging' logging = require './server/commons/logging'
config = require './server_config' config = require './server_config'
auth = require './server/routes/auth' auth = require './server/routes/auth'
UserHandler = require('./server/users/user_handler') UserHandler = require './server/users/user_handler'
###Middleware setup functions implementation###
# 2014-03-03: Try not using this and see if it's still a problem
#setupRequestTimeoutMiddleware = (app) ->
# app.use (req, res, next) ->
# req.setTimeout 15000, ->
# console.log 'timed out!'
# req.abort()
# self.emit('pass',message)
# next()
productionLogging = (tokens, req, res) -> productionLogging = (tokens, req, res) ->
status = res.statusCode status = res.statusCode
@ -36,10 +27,12 @@ productionLogging = (tokens, req, res) ->
null null
setupExpressMiddleware = (app) -> setupExpressMiddleware = (app) ->
#setupRequestTimeoutMiddleware app
if config.isProduction if config.isProduction
express.logger.format('prod', productionLogging) express.logger.format('prod', productionLogging)
app.use(express.logger('prod')) app.use(express.logger('prod'))
app.use express.compress filter: (req, res) ->
return false if req.headers.host is 'codecombat.com' # Cloudflare will gzip it for us on codecombat.com
compressible res.getHeader('Content-Type')
else else
app.use(express.logger('dev')) app.use(express.logger('dev'))
app.use(express.static(path.join(__dirname, 'public'))) app.use(express.static(path.join(__dirname, 'public')))
@ -50,7 +43,6 @@ setupExpressMiddleware = (app) ->
app.use(express.bodyParser()) app.use(express.bodyParser())
app.use(express.methodOverride()) app.use(express.methodOverride())
app.use(express.cookieSession({secret:'defenestrate'})) app.use(express.cookieSession({secret:'defenestrate'}))
#app.use(express.compress()) if config.isProduction # just let Cloudflare do it
setupPassportMiddleware = (app) -> setupPassportMiddleware = (app) ->
app.use(authentication.initialize()) app.use(authentication.initialize())