-
-
Notifications
You must be signed in to change notification settings - Fork 872
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
697 changed files
with
32,525 additions
and
44,697 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[flake8] | ||
# Idea is to remove these over time | ||
# | ||
# E203 = whitespace before ':' | ||
# E221 = multiple spaces before operator | ||
# E241 = multiple spaces after ',' | ||
# E231 = missing whitespace after ',' | ||
|
||
# E261 = at least two spaces before inline comment | ||
# E126 = continuation line over-indented for hanging indent | ||
# E128 = continuation line under-indented for visual indent | ||
# I100 = Imported names are in the wrong order. | ||
|
||
# Q000 = double quotes | ||
|
||
ignore = E126,E128,E221,E226,E261,E203,E231,E241,Q000,I100 | ||
|
||
max-line-length = 200 | ||
|
||
exclude = docs, migrations, node_modules, bower_components, venv, */__init__.py | ||
|
||
import-order-style = google |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,143 @@ | ||
var gulp = require('gulp'); | ||
var gutil = require('gulp-util'); // Error logging + NoOop | ||
|
||
// Compilation | ||
var sass = require('gulp-sass'); | ||
var rename = require('gulp-rename'); | ||
var concat = require('gulp-concat'); | ||
|
||
// Compression | ||
var minifyCSS = require('gulp-minify-css'); | ||
var cleanCSS = require('gulp-clean-css'); | ||
var uglify = require('gulp-uglify'); | ||
|
||
// Browserify | ||
var browserify = require('browserify'); // Bundling modules | ||
var babelify = require('babelify'); // Use ES syntax | ||
var vueify = require('vueify'); | ||
var source = require('vinyl-source-stream'); // Use browserify in gulp | ||
var es = require('event-stream'); // Browserify multiple files at once | ||
var streamify = require('gulp-streamify'); | ||
|
||
// Debug & Config | ||
var livereload = require('gulp-livereload'); | ||
var outputDir = 'tabbycat/static/'; | ||
var isProduction = (gutil.env.development === true) ? false: true; | ||
if (isProduction === true) { | ||
console.log('GULP: Building for production'); | ||
} else if (isProduction === false) { | ||
console.log('GULP: Building for development'); | ||
} | ||
|
||
// Tasks | ||
gulp.task('fonts-compile', function() { | ||
gulp.src([ | ||
'bower_components/**/*.eot', | ||
'bower_components/**/*.svg', | ||
'bower_components/**/*.ttf', | ||
'bower_components/**/*.woff', | ||
'bower_components/**/*.woff2', | ||
'node_modules/bootstrap-sass/assets/fonts/**/*.eot', | ||
'node_modules/bootstrap-sass/assets/fonts/**/*.svg', | ||
'node_modules/bootstrap-sass/assets/fonts/**/*.ttf', | ||
'node_modules/bootstrap-sass/assets/fonts/**/*.woff', | ||
'node_modules/bootstrap-sass/assets/fonts/**/*.woff2', | ||
'node_modules/lato-font/fonts/**/*.eot', | ||
'node_modules/lato-font/fonts/**/*.svg', | ||
'node_modules/lato-font/fonts/**/*.ttf', | ||
'node_modules/lato-font/fonts/**/*.woff', | ||
'node_modules/lato-font/fonts/**/*.woff2', | ||
]) | ||
.pipe(rename({dirname: ''})) // Remove folder structure | ||
.pipe(gulp.dest('static/fonts/vendor/')); | ||
.pipe(gulp.dest(outputDir + 'fonts/')); | ||
}); | ||
|
||
gulp.task('styles-compile', function() { | ||
gulp.src(['templates/scss/printables.scss', 'templates/scss/style.scss']) | ||
gulp.src([ | ||
'tabbycat/templates/scss/allocation-old.scss', | ||
'tabbycat/templates/scss/printables.scss', | ||
'tabbycat/templates/scss/style.scss']) | ||
.pipe(sass().on('error', sass.logError)) | ||
.pipe(minifyCSS()) | ||
.pipe(rename(function (path) { | ||
path.basename += ".min"; | ||
})) | ||
.pipe(gulp.dest('static/css/')); | ||
// '*' compatability = IE9+ | ||
.pipe(isProduction ? cleanCSS({compatibility: '*'}) : gutil.noop()) | ||
.pipe(gulp.dest(outputDir + '/css/')) | ||
.pipe(isProduction ? gutil.noop() : livereload()); | ||
}); | ||
|
||
// Creates task for collecting dependencies | ||
gulp.task('js-compile', function() { | ||
gulp.src(['templates/js/*.js']) | ||
.pipe(uglify()) | ||
.pipe(rename(function (path) { | ||
path.basename += ".min"; | ||
})) | ||
.pipe(rename({dirname: ''})) // Remove folder structure | ||
.pipe(gulp.dest('static/js/')); | ||
gulp.task("js-vendor-compile", function() { | ||
gulp.src([ | ||
'node_modules/jquery/dist/jquery.js', // For Debug Toolbar | ||
'node_modules/datatables.net/js/jquery.dataTables.js', // Deprecate, | ||
'node_modules/jquery-validation/dist/jquery.validate.js', // Deprecate, | ||
'tabbycat/templates/js-vendor/jquery-ui.min.js', // Deprecate, | ||
]) | ||
.pipe(isProduction ? uglify() : gutil.noop()) // Doesnt crash | ||
.pipe(gulp.dest(outputDir + '/js/vendor/')); | ||
}); | ||
|
||
// Creates task for collecting dependencies | ||
gulp.task('js-main-vendor-compile', function() { | ||
gulp.src(['bower_components/jquery/dist/jquery.js', | ||
'bower_components/bootstrap-sass/assets/javascripts/bootstrap.js', | ||
'templates/js/vendor/jquery.dataTables.min.js', | ||
'templates/js/vendor/fixed-header.js', | ||
]) | ||
.pipe(concat('vendor.js')) | ||
.pipe(uglify()) | ||
.pipe(rename(function (path) { | ||
path.basename += ".min"; | ||
})) | ||
.pipe(rename({dirname: ''})) // Remove folder structure | ||
.pipe(gulp.dest('static/js/vendor/')); | ||
gulp.task("js-compile", function() { | ||
gulp.src([ | ||
'tabbycat/templates/js-standalones/*.js', | ||
]) | ||
// Can't run uglify() until django logic is out of standalone js files | ||
// .pipe(isProduction ? uglify() : gutil.noop()) | ||
.pipe(gulp.dest(outputDir + '/js/')) | ||
.pipe(isProduction ? gutil.noop() : livereload()); | ||
}); | ||
|
||
// Creates task for collecting dependencies | ||
gulp.task('js-alt-vendor-compile', function() { | ||
gulp.src(['bower_components/jquery/dist/jquery.min.js', // Redundant but needed for debug toolbar | ||
'bower_components/d3/d3.min.js', | ||
'bower_components/jquery-ui/jquery-ui.min.js', | ||
'bower_components/jquery-validation/dist/jquery.validate.min.js', | ||
'bower_components/vue/dist/vue.min.js', | ||
'bower_components/vue/dist/vue.js', // For when debug is on | ||
]) | ||
.pipe(uglify()) | ||
.pipe(rename({dirname: ''})) // Remove folder structure | ||
.pipe(gulp.dest('static/js/vendor/')); | ||
gulp.task("js-browserify", function() { | ||
// With thanks to https://fettblog.eu/gulp-browserify-multiple-bundles/ | ||
// We define our input files, which we want to have bundled | ||
var files = [ | ||
'tabbycat/templates/js-bundles/public.js', | ||
'tabbycat/templates/js-bundles/admin.js' | ||
]; | ||
// map them to our stream function | ||
var tasks = files.map(function(entry) { | ||
return browserify({ entries: [entry] }) | ||
.transform(vueify) | ||
.on('error', gutil.log) | ||
.transform([babelify, { | ||
presets: ["es2015"], | ||
plugins: ['transform-runtime'] | ||
}]) | ||
.on('error', gutil.log) | ||
.bundle().on('error', gutil.log) | ||
.on('error', function() { | ||
gutil.log | ||
this.emit('end'); | ||
}) | ||
.pipe(source(entry)) | ||
.on('error', gutil.log) | ||
.pipe(isProduction ? streamify(uglify()) : gutil.noop()) | ||
.on('error', gutil.log) | ||
.pipe(rename({ | ||
extname: '.bundle.js', | ||
dirname: '' | ||
})) | ||
.pipe(gulp.dest(outputDir + '/js/')); | ||
// .pipe(isProduction ? gutil.noop() : livereload()); | ||
// TODO: get proper hot reloading going? | ||
}); | ||
// create a merged stream | ||
return es.merge.apply(null, tasks); | ||
}); | ||
|
||
// Automatically build and watch the CSS folder for when a file changes | ||
gulp.task('default', ['build'], function() { | ||
gulp.watch('templates/scss/**/*.scss', ['styles-compile']); | ||
gulp.watch('templates/js/**/*.js', ['js-compress']); | ||
gulp.task("html-reload", function() { | ||
return gulp.src('') | ||
.pipe(livereload()); | ||
}); | ||
|
||
// Build task for production | ||
gulp.task('build', ['fonts-compile', 'styles-compile', 'js-compile', 'js-main-vendor-compile', 'js-alt-vendor-compile' ]); | ||
// Runs with --production if debug is false or there's no local settings | ||
gulp.task('build', [ | ||
'fonts-compile', | ||
'styles-compile', | ||
'js-vendor-compile', | ||
'js-compile', | ||
'js-browserify', | ||
]); | ||
|
||
// Runs when debug is True and when runserver/collectstatic is called | ||
// Watch the CSS/JS for changes and copy over to static AND static files when done | ||
gulp.task('watch', ['build'], function() { | ||
livereload.listen(); | ||
gulp.watch('tabbycat/templates/scss/**/*.scss', ['styles-compile']); | ||
gulp.watch('tabbycat/templates/js-standalones/*.js', ['js-compile']); | ||
gulp.watch('tabbycat/templates/js-bundles/*.js', ['js-browserify']); | ||
gulp.watch('tabbycat/templates/**/*.vue', ['js-browserify']); | ||
gulp.watch('tabbycat/**/*.html', ['html-reload']); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# production | ||
web: waitress-serve --port=$PORT wsgi:application | ||
web: sh -c 'cd ./tabbycat/ && waitress-serve --port=$PORT wsgi:application' | ||
|
||
# debug | ||
#web: waitress-serve --port=$PORT --expose-tracebacks wsgi:application | ||
web: sh -c 'cd tabbycat && waitress-serve --port=$PORT --expose-tracebacks wsgi:application' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.