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

View file

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

View file

@ -91,7 +91,8 @@
"karma-requirejs": "~0.2.1",
"karma-phantomjs-launcher": "~0.1.1",
"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",
"private": true,

View file

@ -3,7 +3,8 @@ path = require 'path'
authentication = require 'passport'
useragent = require 'express-useragent'
fs = require 'graceful-fs'
log = require('winston')
log = require 'winston'
compressible = require 'compressible'
database = require './server/commons/database'
baseRoute = require './server/routes/base'
@ -11,17 +12,7 @@ user = require './server/users/user_handler'
logging = require './server/commons/logging'
config = require './server_config'
auth = require './server/routes/auth'
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()
UserHandler = require './server/users/user_handler'
productionLogging = (tokens, req, res) ->
status = res.statusCode
@ -36,10 +27,12 @@ productionLogging = (tokens, req, res) ->
null
setupExpressMiddleware = (app) ->
#setupRequestTimeoutMiddleware app
if config.isProduction
express.logger.format('prod', productionLogging)
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
app.use(express.logger('dev'))
app.use(express.static(path.join(__dirname, 'public')))
@ -50,7 +43,6 @@ setupExpressMiddleware = (app) ->
app.use(express.bodyParser())
app.use(express.methodOverride())
app.use(express.cookieSession({secret:'defenestrate'}))
#app.use(express.compress()) if config.isProduction # just let Cloudflare do it
setupPassportMiddleware = (app) ->
app.use(authentication.initialize())