diff --git a/client/gulpfile.js b/client/gulpfile.js index cb4ff435..23d654dc 100644 --- a/client/gulpfile.js +++ b/client/gulpfile.js @@ -27,10 +27,10 @@ gulp.task('html', function() { }); gulp.task('css', function() { - gulp.src('./src/*.css') + gulp.src('./src/css/*.css') .pipe(autoprefixer()) .pipe(minifyCSS()) - .pipe(gulp.dest('./dist')); + .pipe(gulp.dest('./dist/css')); }); gulp.task('js', function() { @@ -70,14 +70,19 @@ function js(watch) { return rebundle(); } -gulp.task('gzip', ['html', 'css', 'js'], function() { - gulp.src('./dist/*.{html,css,js}') +gulp.task('fonts', function() { + gulp.src('./src/font/*') + .pipe(gulp.dest('./dist/font')); +}); + +gulp.task('gzip', ['html', 'css', 'js', 'fonts'], function() { + gulp.src('./dist/**/!(*.gz)') .pipe(gzip()) .pipe(gulp.dest('./dist')); }); gulp.task('gzip:watch', function() { - gulp.src('./dist/*.{html,css,js}') + gulp.src('./dist/**/*.{html,css,js}') .pipe(gzip()) .pipe(gulp.dest('./dist')); }); @@ -89,4 +94,4 @@ gulp.task('watch', ['default'], function() { return js(true); }); -gulp.task('default', ['html', 'css', 'js', 'gzip']); \ No newline at end of file +gulp.task('default', ['html', 'css', 'js', 'fonts', 'gzip']); \ No newline at end of file diff --git a/client/src/css/fontello.css b/client/src/css/fontello.css new file mode 100644 index 00000000..4140939a --- /dev/null +++ b/client/src/css/fontello.css @@ -0,0 +1,54 @@ +@font-face { + font-family: 'fontello'; + src: url('../font/fontello.eot?73444496'); + src: url('../font/fontello.eot?73444496#iefix') format('embedded-opentype'), + url('../font/fontello.woff?73444496') format('woff'), + url('../font/fontello.ttf?73444496') format('truetype'), + url('../font/fontello.svg?73444496#fontello') format('svg'); + font-weight: normal; + font-style: normal; +} +/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */ +/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */ +/* +@media screen and (-webkit-min-device-pixel-ratio:0) { + @font-face { + font-family: 'fontello'; + src: url('../font/fontello.svg?73444496#fontello') format('svg'); + } +} +*/ + + [class^="icon-"]:before, [class*=" icon-"]:before { + font-family: "fontello"; + font-style: normal; + font-weight: normal; + speak: none; + + display: inline-block; + text-decoration: inherit; + width: 1em; + margin-right: .2em; + text-align: center; + /* opacity: .8; */ + + /* For safety - reset parent styles, that can break glyph codes*/ + font-variant: normal; + text-transform: none; + + /* fix buttons height, for twitter bootstrap */ + line-height: 1em; + + /* Animation center compensation - margins should be symmetric */ + /* remove if not needed */ + margin-left: .2em; + + /* you can be more comfortable with increased icons size */ + /* font-size: 120%; */ + + /* Uncomment for 3D effect */ + /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */ +} + +.icon-cog:before { content: '\e800'; } /* '' */ +.icon-ellipsis:before { content: '\e801'; } /* '' */ \ No newline at end of file diff --git a/client/src/style.css b/client/src/css/style.css similarity index 98% rename from client/src/style.css rename to client/src/css/style.css index a7dfdcaa..0147b7ac 100644 --- a/client/src/style.css +++ b/client/src/css/style.css @@ -26,6 +26,10 @@ p { line-height: 1.5; } +i[class^="icon-"]:before, i[class*=" icon-"]:before { + margin: 0; +} + .tablist { position: fixed; left: 0; diff --git a/client/src/font/fontello.eot b/client/src/font/fontello.eot new file mode 100644 index 00000000..e982f220 Binary files /dev/null and b/client/src/font/fontello.eot differ diff --git a/client/src/font/fontello.svg b/client/src/font/fontello.svg new file mode 100644 index 00000000..b947f26e --- /dev/null +++ b/client/src/font/fontello.svg @@ -0,0 +1,13 @@ + + + +Copyright (C) 2015 by original authors @ fontello.com + + + + + + + + + \ No newline at end of file diff --git a/client/src/font/fontello.ttf b/client/src/font/fontello.ttf new file mode 100644 index 00000000..7f7297f8 Binary files /dev/null and b/client/src/font/fontello.ttf differ diff --git a/client/src/font/fontello.woff b/client/src/font/fontello.woff new file mode 100644 index 00000000..1a501827 Binary files /dev/null and b/client/src/font/fontello.woff differ diff --git a/client/src/index.html b/client/src/index.html index 94c57f0a..7faca1bb 100644 --- a/client/src/index.html +++ b/client/src/index.html @@ -7,8 +7,8 @@ IRC - - + + diff --git a/client/src/js/components/Connect.jsx b/client/src/js/components/Connect.jsx index 257e2f10..d4b0344e 100644 --- a/client/src/js/components/Connect.jsx +++ b/client/src/js/components/Connect.jsx @@ -65,7 +65,7 @@ var Connect = React.createClass({ {optionals}

- +

diff --git a/client/src/js/components/MessageBox.jsx b/client/src/js/components/MessageBox.jsx index 99577be8..115998a9 100644 --- a/client/src/js/components/MessageBox.jsx +++ b/client/src/js/components/MessageBox.jsx @@ -4,7 +4,6 @@ var _ = require('lodash'); var Infinite = require('react-infinite'); var util = require('../util'); -var messageStore = require('../stores/message'); var messageLineStore = require('../stores/messageLine'); var selectedTabStore = require('../stores/selectedTab'); var messageActions = require('../actions/message'); diff --git a/client/src/js/components/TabList.jsx b/client/src/js/components/TabList.jsx index 45b00381..86b30771 100644 --- a/client/src/js/components/TabList.jsx +++ b/client/src/js/components/TabList.jsx @@ -71,7 +71,7 @@ var TabList = React.createClass({ {tabs}
- +
); diff --git a/main.go b/main.go index 962bb97a..81b595f6 100644 --- a/main.go +++ b/main.go @@ -17,8 +17,14 @@ var ( sessions map[string]*Session sessionLock sync.Mutex fs http.Handler + files []File ) +type File struct { + Path string + ContentType string +} + func reconnect() { for _, user := range storage.LoadUsers() { channels := user.GetChannels() @@ -62,17 +68,25 @@ func serveFiles(w http.ResponseWriter, r *http.Request) { ext = ".gz" } - if strings.HasSuffix(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") { - w.Header().Set("Content-Type", "text/css") - r.URL.Path = "/style.css" + ext - } else { + if r.URL.Path == "/" { w.Header().Set("Content-Type", "text/html") r.URL.Path = "/index.html" + ext + fs.ServeHTTP(w, r) + return } + for _, file := range files { + if strings.HasSuffix(r.URL.Path, file.Path) { + w.Header().Set("Content-Type", file.ContentType) + r.URL.Path = file.Path + ext + fs.ServeHTTP(w, r) + return + } + } + + w.Header().Set("Content-Type", "text/html") + r.URL.Path = "/index.html" + ext + fs.ServeHTTP(w, r) } @@ -83,6 +97,16 @@ func main() { sessions = make(map[string]*Session) fs = http.FileServer(http.Dir("client/dist")) + files = []File{ + File{"/bundle.js", "text/javascript"}, + File{"/css/style.css", "text/css"}, + File{"/css/fontello.css", "text/css"}, + File{"/font/fontello.eot", "application/vnd.ms-fontobject"}, + File{"/font/fontello.svg", "image/svg+xml"}, + File{"/font/fontello.ttf", "application/x-font-ttf"}, + File{"/font/fontello.woff", "application/font-woff"}, + } + //reconnect() router := httprouter.New()