diff --git a/client/gulpfile.js b/client/gulpfile.js index c4dde109..cb4ff435 100644 --- a/client/gulpfile.js +++ b/client/gulpfile.js @@ -4,6 +4,7 @@ var minifyHTML = require('gulp-minify-html'); var minifyCSS = require('gulp-minify-css'); var autoprefixer = require('gulp-autoprefixer'); var uglify = require('gulp-uglify'); +var gzip = require('gulp-gzip'); var browserify = require('browserify'); var source = require('vinyl-source-stream'); var streamify = require('gulp-streamify'); @@ -69,10 +70,23 @@ function js(watch) { return rebundle(); } +gulp.task('gzip', ['html', 'css', 'js'], function() { + gulp.src('./dist/*.{html,css,js}') + .pipe(gzip()) + .pipe(gulp.dest('./dist')); +}); + +gulp.task('gzip:watch', function() { + gulp.src('./dist/*.{html,css,js}') + .pipe(gzip()) + .pipe(gulp.dest('./dist')); +}); + gulp.task('watch', ['default'], function() { + gulp.watch('./dist/*.{html,css,js}', ['gzip:watch']) gulp.watch('./src/*.html', ['html']); gulp.watch('./src/*.css', ['css']); return js(true); }); -gulp.task('default', ['html', 'css', 'js']); \ No newline at end of file +gulp.task('default', ['html', 'css', 'js', 'gzip']); \ No newline at end of file diff --git a/client/package.json b/client/package.json index 62cbebdf..1e6fd915 100644 --- a/client/package.json +++ b/client/package.json @@ -16,12 +16,14 @@ "watchify": "~2.2.1", "browserify": "~8.0.3", "gulp-autoprefixer": "~2.0.0", - "reactify": "~0.17.1" + "reactify": "~0.17.1", + "gulp-gzip": "0.0.8" }, "dependencies": { "lodash": "3.0.0", "reflux": "0.2.4", "react-router": "~0.11.6", - "react": "~0.12.2" + "react": "~0.12.2", + "react-infinite": "~0.2.2" } } diff --git a/client/src/js/app.js b/client/src/js/app.js index c41ecd0f..ba3ab62b 100644 --- a/client/src/js/app.js +++ b/client/src/js/app.js @@ -10,21 +10,12 @@ var App = require('./components/App.jsx'); var Connect = require('./components/Connect.jsx'); var Chat = require('./components/Chat.jsx'); var Settings = require('./components/Settings.jsx'); -var tabActions = require('./actions/tab'); -var serverActions = require('./actions/server'); -var channelActions = require('./actions/channel'); var uuid = localStorage.uuid || (localStorage.uuid = util.UUID()); var nick = 'test' + Math.floor(Math.random() * 99999); socket.on('connect', function() { socket.send('uuid', uuid); - - /*serverActions.connect('irc.freenode.net', nick, 'username', true, 'Freenode'); - serverActions.connect('irc.quakenet.org', nick, 'username', false, 'QuakeNet'); - - channelActions.join(['#stuff'], 'irc.freenode.net'); - channelActions.join(['#herp'], 'irc.quakenet.org');*/ }); socket.on('error', function(error) { diff --git a/client/src/js/stores/server.js b/client/src/js/stores/server.js index 49c9f46e..53bbac9c 100644 --- a/client/src/js/stores/server.js +++ b/client/src/js/stores/server.js @@ -17,7 +17,7 @@ var serverStore = Reflux.createStore({ server = server.slice(0, i); } - servers[server] = { + servers[server] = { address: server, nick: nick, username: username, diff --git a/main.go b/main.go index 139511cf..630d7815 100644 --- a/main.go +++ b/main.go @@ -20,12 +20,22 @@ var ( ) func serveFiles(w http.ResponseWriter, r *http.Request) { + var ext string + + if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { + w.Header().Set("Content-Encoding", "gzip") + ext = ".gz" + } + if strings.HasSuffix(r.URL.Path, "bundle.js") { - r.URL.Path = "/bundle.js" + w.Header().Set("Content-Type", "text/javascript") + r.URL.Path = "/bundle.js" + ext } else if strings.HasSuffix(r.URL.Path, "style.css") { - r.URL.Path = "/style.css" + w.Header().Set("Content-Type", "text/css") + r.URL.Path = "/style.css" + ext } else { - r.URL.Path = "/" + w.Header().Set("Content-Type", "text/html") + r.URL.Path = "/index.html" + ext } fs.ServeHTTP(w, r)