Skip to content

Commit 207cf60

Browse files
committed
minor fixes
1 parent 114b8e1 commit 207cf60

7 files changed

Lines changed: 102 additions & 12 deletions

File tree

Lines changed: 63 additions & 0 deletions
Loading

gulpfile.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ gulp.task('client:compile-css',
118118
);
119119

120120

121-
gulp.task('client:minify', lazyRequireTask('./tasks/minify', {
122-
root: './public'
123-
}));
121+
gulp.task('client:minify', lazyRequireTask('./tasks/minify'));
124122

125123
gulp.task('client:webpack', lazyRequireTask('./tasks/webpack'));
126124

hmvc/tutorial/client/ebook.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
exports.init = function() {
2+
/* special JS for ebook, nothing here yet */
3+
};

hmvc/tutorial/client/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ exports.init = function() {
1414
});
1515

1616
prism();
17+
18+
if (window.isEbook) {
19+
require.ensure('./ebook', function() {
20+
require('./ebook').init();
21+
}, 'ebook');
22+
}
1723
};
1824

1925
exports.TutorialMap = require('./tutorialMap');

hmvc/tutorial/templates/ebook.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ block content
5555
a(href=('#' + task.url + '/content')) К условию
5656

5757
script(src=script("tutorial"))
58-
5958
script tutorial.init();
6059

6160

61+

scripts/elastic/db

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
#!/bin/bash
22

3-
curl -XDELETE 'http://localhost:9200/js'
3+
# Delete all
4+
curl -XDELETE 'http://localhost:9200/*'
45

6+
# Partial delete
7+
# curl -XDELETE 'http://localhost:9200/js'
58
curl -XPUT 'http://localhost:9200/js' -d @db-js.json
69

710
# River will deliver from Mongo -> to index
8-
# Index must be empty!
11+
# Index must be empty (deleted above)!
912

10-
curl -XDELETE 'http://localhost:9200/_river/articles'
13+
# Partial delete
14+
# curl -XDELETE 'http://localhost:9200/_river/articles'
1115
curl -XPUT 'http://localhost:9200/_river/articles/_meta' -d @river-articles.json
1216

13-
curl -XDELETE 'http://localhost:9200/_river/tasks'
17+
# curl -XDELETE 'http://localhost:9200/_river/tasks'
1418
curl -XPUT 'http://localhost:9200/_river/tasks/_meta' -d @river-tasks.json
1519

1620
# get river status

tasks/minify.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const path = require('path');
66
const gulp = require('gulp');
77
const gp = require('gulp-load-plugins')();
88
const gutil = require('gulp-util');
9+
const fs = require('fs');
910

1011
/**
1112
*
@@ -14,14 +15,29 @@ const gutil = require('gulp-util');
1415
* @returns {Function}
1516
*/
1617
module.exports = function(options) {
17-
const root = options.root;
18+
options = options || {};
19+
20+
const root = options.root || require('yargs').argv.root;
21+
22+
if (!root) {
23+
throw new Error("Root not set");
24+
}
1825

1926
return function(callback) {
2027

21-
return gulp.src(options.root + '/**/*.{svg,png,jpg,gif}')
28+
gutil.log("minify " + root);
29+
30+
return gulp.src(root + '/**/*.{svg,png,jpg,gif}')
2231
.pipe(es.map(function(image, cb) {
2332
gutil.log("minify " + image.path);
24-
minifyImage(image.path, cb);
33+
34+
var sizeBefore = image.stat.size;
35+
minifyImage(image.path, function() {
36+
var sizeAfter = fs.statSync(image.path).size;
37+
gutil.log(sizeBefore + " -> " + sizeAfter);
38+
cb();
39+
});
40+
2541
}));
2642
};
2743

@@ -52,6 +68,6 @@ function minifyImage(imagePath, callback) {
5268
.dest(imagePath)
5369
.use(plugin);
5470

55-
imagemin.optimize(callback);
71+
imagemin.run(callback);
5672

5773
}

0 commit comments

Comments
 (0)