Update readme, store data in homedir/.name_pending instead the cwd, move client build output back to client/dist

This commit is contained in:
khlieng 2015-04-23 00:44:40 +02:00
parent 891f7b2f10
commit 65229f7a9e
4 changed files with 199 additions and 172 deletions

View File

@ -1,28 +1,41 @@
# name_pending # name_pending
Web-based IRC client in Go. Web-based IRC client in Go.
## Building ## Installing
#### Requirements
* [Go](http://golang.org/doc/install)
* [Node.js + npm](http://nodejs.org/download/)
#### Get the source
```bash ```bash
go get github.com/khlieng/name_pending go get github.com/khlieng/name_pending
``` ```
#### Compile the server ## Running
```bash
name_pending
```
## Building the server
#### Requirements
* [Go](http://golang.org/doc/install)
```bash ```bash
cd $GOPATH/src/github.com/khlieng/name_pending cd $GOPATH/src/github.com/khlieng/name_pending
go build -o bin/name_pending go install
``` ```
#### Build the client ## Building the client
#### Requirements
* [Node.js + npm](https://nodejs.org/download/)
```bash ```bash
npm install -g gulp npm install -g gulp
go get github.com/jteeuwen/go-bindata/...
go get github.com/elazarl/go-bindata-assetfs/...
cd client cd $GOPATH/src/github.com/khlieng/name_pending/client
npm install npm install
gulp -p gulp -p
``` go-bindata-assetfs -nomemcopy dist/...
mv bindata_assetfs.go ../bindata.go
# Rebuild the server :)
```

File diff suppressed because one or more lines are too long

View File

@ -21,16 +21,16 @@ if (argv.production) {
} }
gulp.task('html', function() { gulp.task('html', function() {
gulp.src('./src/*.html') gulp.src('src/*.html')
.pipe(minifyHTML()) .pipe(minifyHTML())
.pipe(gulp.dest('../bin/assets')); .pipe(gulp.dest('dist'));
}); });
gulp.task('css', function() { gulp.task('css', function() {
gulp.src('./src/css/*.css') gulp.src('src/css/*.css')
.pipe(autoprefixer()) .pipe(autoprefixer())
.pipe(minifyCSS()) .pipe(minifyCSS())
.pipe(gulp.dest('../bin/assets/css')); .pipe(gulp.dest('dist/css'));
}); });
gulp.task('js', function() { gulp.task('js', function() {
@ -60,7 +60,7 @@ function js(watch) {
return stream return stream
.pipe(source('bundle.js')) .pipe(source('bundle.js'))
.pipe(gulpif(argv.production, streamify(uglify()))) .pipe(gulpif(argv.production, streamify(uglify())))
.pipe(gulp.dest('../bin/assets')); .pipe(gulp.dest('dist'));
}; };
bundler.on('time', function(time) { bundler.on('time', function(time) {
@ -71,26 +71,26 @@ function js(watch) {
} }
gulp.task('fonts', function() { gulp.task('fonts', function() {
gulp.src('./src/font/*') gulp.src('src/font/*')
.pipe(gulp.dest('../bin/assets/font')); .pipe(gulp.dest('dist/font'));
}); });
gulp.task('gzip', ['html', 'css', 'js', 'fonts'], function() { gulp.task('gzip', ['html', 'css', 'js', 'fonts'], function() {
gulp.src('../bin/assets/**/!(*.gz)') gulp.src('dist/**/!(*.gz)')
.pipe(gzip()) .pipe(gzip())
.pipe(gulp.dest('../bin/assets')); .pipe(gulp.dest('dist'));
}); });
gulp.task('gzip:watch', function() { gulp.task('gzip:watch', function() {
gulp.src('../bin/assets/**/*.{html,css,js}') gulp.src('dist/**/*.{html,css,js}')
.pipe(gzip()) .pipe(gzip())
.pipe(gulp.dest('../bin/assets')); .pipe(gulp.dest('dist'));
}); });
gulp.task('watch', ['default'], function() { gulp.task('watch', ['default'], function() {
gulp.watch('../bin/assets/**/*.{html,css,js}', ['gzip:watch']) gulp.watch('dist/**/*.{html,css,js}', ['gzip:watch'])
gulp.watch('./src/*.html', ['html']); gulp.watch('src/*.html', ['html']);
gulp.watch('./src/css/*.css', ['css']); gulp.watch('src/css/*.css', ['css']);
return js(true); return js(true);
}); });

View File

@ -1,13 +1,27 @@
package storage package storage
import ( import (
"log"
"os"
"os/user"
"path"
"github.com/boltdb/bolt" "github.com/boltdb/bolt"
) )
var db *bolt.DB var db *bolt.DB
func init() { func init() {
db, _ = bolt.Open("data.db", 0600, nil) var err error
currentUser, _ := user.Current()
appDir := path.Join(currentUser.HomeDir, ".name_pending")
os.Mkdir(appDir, 0777)
db, err = bolt.Open(path.Join(appDir, "data.db"), 0600, nil)
if err != nil {
log.Fatal("Unable to open database file")
}
db.Update(func(tx *bolt.Tx) error { db.Update(func(tx *bolt.Tx) error {
tx.CreateBucketIfNotExists([]byte("Users")) tx.CreateBucketIfNotExists([]byte("Users"))