aboutsummaryrefslogtreecommitdiff
path: root/web/trunk/gulpfile.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/trunk/gulpfile.js')
-rw-r--r--web/trunk/gulpfile.js100
1 files changed, 0 insertions, 100 deletions
diff --git a/web/trunk/gulpfile.js b/web/trunk/gulpfile.js
deleted file mode 100644
index 2030db9..0000000
--- a/web/trunk/gulpfile.js
+++ /dev/null
@@ -1,100 +0,0 @@
-// see https://github.com/tugberkugurlu/gulp-bootswatch-sample/
-
-var gulp = require('gulp'),
- minifycss = require('gulp-minify-css'),
- concat = require('gulp-concat'),
- less = require('gulp-less'),
- gulpif = require('gulp-if'),
- order = require('gulp-order'),
- gutil = require('gulp-util'),
- rename = require('gulp-rename'),
- foreach = require('gulp-foreach'),
- debug = require('gulp-debug'),
- path =require('path'),
- merge = require('merge-stream'),
- del = require('del');
-
-var bootswatch_theme = 'superhero';
-
-gulp.task('default', ['clean'], function() {
- gulp.start('fonts', 'styles');
-});
-
-gulp.task('clean', function(cb) {
- del(['assets/css', 'assets/js', 'assets/less', 'assets/img', 'assets/fonts'], cb)
-});
-
-gulp.task('fonts', function() {
-
- var fileList = [
- 'bower_components/bootstrap/dist/fonts/*',
- 'bower_components/fontawesome/fonts/*'
- ];
-
- return gulp.src(fileList)
- .pipe(gulp.dest('assets/fonts'));
-});
-
-gulp.task('styles', function() {
-
- var baseContent = '@import "bower_components/bootstrap/less/bootstrap.less";@import "bower_components/bootswatch/' + bootswatch_theme + '/variables.less";@import "bower_components/bootswatch/' + bootswatch_theme + '/bootswatch.less";@import "bower_components/bootstrap/less/utilities.less";';
- var isBootswatchFile = function(file) {
- var suffix = 'bootswatch.less';
- return file.path.indexOf(suffix, file.path.length - suffix.length) !== -1;
- }
-
- var isBootstrapFile = function(file) {
- var suffix = 'bootstrap-',
- fileName = path.basename(file.path);
-
- return fileName.indexOf(suffix) == 0;
- }
-
- var fileList = [
- 'client/less/main.less',
- 'bower_components/bootswatch/**/bootswatch.less',
- 'bower_components/fontawesome/css/font-awesome.css'
- ];
-
- return gulp.src(fileList)
- .pipe(gulpif(isBootswatchFile, foreach(function(stream, file) {
- var themeName = path.basename(path.dirname(file.path)),
- content = replaceAll(baseContent, bootswatch_theme, themeName),
- file = string_src('bootstrap-' + themeName + '.less', content);
-
- return file;
- })))
- .pipe(less())
- .pipe(gulp.dest('assets/css'))
- .pipe(gulpif(isBootstrapFile, foreach(function(stream, file) {
- var fileName = path.basename(file.path),
- themeName = fileName.substring(fileName.indexOf('-') + 1, fileName.indexOf('.'));
-
- // http://stackoverflow.com/questions/21719833/gulp-how-to-add-src-files-in-the-middle-of-a-pipe
- // https://github.com/gulpjs/gulp/blob/master/docs/recipes/using-multiple-sources-in-one-task.md
- return merge(stream, gulp.src(['assets/css/font-awesome.css', 'assets/css/main.css']))
- .pipe(concat('style-' + themeName + ".css"))
- .pipe(gulp.dest('assets/css'))
- .pipe(rename({suffix: '.min'}))
- .pipe(minifycss())
- .pipe(gulp.dest('assets/css'));
- })))
-});
-
-// http://stackoverflow.com/questions/1144783/replacing-all-occurrences-of-a-string-in-javascript
-function escapeRegExp(string) {
- return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
-}
-
-function replaceAll(string, find, replace) {
- return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
-}
-
-function string_src(filename, string) {
- var src = require('stream').Readable({ objectMode: true })
- src._read = function () {
- this.push(new gutil.File({ cwd: "", base: "", path: filename, contents: new Buffer(string) }))
- this.push(null)
- }
- return src
-} \ No newline at end of file