diff --git a/Gruntfile.js b/Gruntfile.js index c414ce71..1f9c8d21 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,6 +3,7 @@ module.exports = function (grunt) { var modRewrite = require('connect-modrewrite'), gzipStatic = require('connect-gzip-static'), path = require('path'), + slash = require("slash"), _ = require('lodash'); @@ -108,12 +109,12 @@ module.exports = function (grunt) { */ meta: { banner: '/**\n' + - ' * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' + - ' * <%= pkg.homepage %>\n' + - ' *\n' + - ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' + - ' * Licensed <%= pkg.licenses.type %> <<%= pkg.licenses.url %>>\n' + - ' */\n' + ' * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' + + ' * <%= pkg.homepage %>\n' + + ' *\n' + + ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' + + ' * Licensed <%= pkg.licenses.type %> <<%= pkg.licenses.url %>>\n' + + ' */\n' }, /** @@ -181,7 +182,7 @@ module.exports = function (grunt) { build_app_assets: { files: [ { - src: [ '**' ], + src: ['**'], dest: '<%= build_dir %>/assets/', cwd: 'src/assets', expand: true, @@ -244,7 +245,7 @@ module.exports = function (grunt) { }, files: [ { - src: [ '<%= app_files.js %>' ], + src: ['<%= app_files.js %>'], dest: '<%= build_dir %>/', cwd: '.', expand: true, @@ -258,7 +259,7 @@ module.exports = function (grunt) { }, files: [ { - src: [ '<%= vendor_files.js %>' ], + src: ['<%= vendor_files.js %>'], dest: '<%= build_dir %>/', cwd: '.', expand: true, @@ -269,7 +270,7 @@ module.exports = function (grunt) { compile_assets: { files: [ { - src: [ '**' ], + src: ['**'], dest: '<%= compile_dir %>/assets', cwd: '<%= build_dir %>/assets', expand: true, @@ -292,8 +293,7 @@ module.exports = function (grunt) { banner: '<%= meta.banner %>' }, nonull: true, - src: - [ + src: [ '<%= vendor_files.css %>', '<%= build_dir %>/assets/styles/*.css' ], @@ -309,8 +309,8 @@ module.exports = function (grunt) { }, nonull: true, src: [ - (function() { - return userConfig.vendor_files.js.map(function(file) { + (function () { + return userConfig.vendor_files.js.map(function (file) { return userConfig.build_dir + "/" + file; }); }()), @@ -332,7 +332,7 @@ module.exports = function (grunt) { compile: { files: [ { - src: [ '<%= app_files.js %>' ], + src: ['<%= app_files.js %>'], cwd: '<%= build_dir %>', dest: '<%= build_dir %>', expand: true @@ -365,15 +365,13 @@ module.exports = function (grunt) { * This task is run after the sass file template has been processed. */ sassReal: { - options: { - - }, + options: {}, build: { options: { imagePath: '<%= build_configs.current.siteDir %>assets/img', outputStyle: 'expanded', sourceComments: 'normal' /*'map', - sourceMap: '<%= sassDestName %>.map'*/ + sourceMap: '<%= sassDestName %>.map'*/ }, src: '<%= app_files.processedSass %>', dest: '<%= sassDest %>' @@ -440,7 +438,7 @@ module.exports = function (grunt) { options: { base: 'src/app' }, - src: [ '<%= app_files.atpl %>' ], + src: ['<%= app_files.atpl %>'], dest: '<%= build_dir %>/templates-app.js' }, @@ -451,7 +449,7 @@ module.exports = function (grunt) { options: { base: 'src' }, - src: [ '<%= app_files.ctpl %>' ], + src: ['<%= app_files.ctpl %>'], dest: '<%= build_dir %>/templates-common.js' } }, @@ -555,7 +553,6 @@ module.exports = function (grunt) { '^/assets(.*) /assets$1 [L]', - // this rule matches anything without an extension // if matched, the root (index.html) is sent back instead. // from there, angular deals with the route information @@ -570,7 +567,7 @@ module.exports = function (grunt) { ]), // disable all caching - function(req, res, next) { + function (req, res, next) { req.headers['if-none-match'] = 'no-match-for-this'; next(); }, @@ -606,7 +603,8 @@ module.exports = function (grunt) { * plugin should auto-detect. */ options: { - livereload: true + livereload: true, + spawn: false }, /** @@ -615,7 +613,7 @@ module.exports = function (grunt) { */ gruntfile: { files: 'Gruntfile.js', - tasks: [ 'jshint:gruntfile' ], + tasks: ['jshint:gruntfile'], options: { livereload: false } @@ -631,7 +629,7 @@ module.exports = function (grunt) { ], // karma:unit:run is disabled because it breaks watch by stopping it // see https://github.com/karma-runner/grunt-karma/issues/30 - tasks: [ 'jshint:src', 'karma:unit:run', 'copy:build_appjs' ] + tasks: ['jshint:src', 'karma:unit:run', 'copy:build_appjs'] }, /** @@ -642,15 +640,15 @@ module.exports = function (grunt) { files: [ 'src/assets/**/*' ], - tasks: [ 'copy:build_app_assets' ] + tasks: ['copy:build_app_assets'] }, /** * When index.html changes, we need to compile it. */ html: { - files: [ '<%= app_files.html %>' ], - tasks: [ 'index:build' ] + files: ['<%= app_files.html %>'], + tasks: ['index:build'] }, /** @@ -661,14 +659,14 @@ module.exports = function (grunt) { '<%= app_files.atpl %>', '<%= app_files.ctpl %>' ], - tasks: [ 'html2js' ] + tasks: ['html2js'] }, /** * When the CSS files change, we need to compile and minify them. */ sass: { - files: [ 'src/**/*.scss' ], + files: ['src/**/*.scss'], tasks: ['sass:build', 'concat:build_css'] }, @@ -680,7 +678,7 @@ module.exports = function (grunt) { files: [ '<%= app_files.jsunit %>' ], - tasks: [ 'jshint:test', 'karma:unit:run' ], + tasks: ['jshint:test', 'karma:unit:run'], options: { livereload: false } @@ -701,12 +699,12 @@ module.exports = function (grunt) { * before watching for changes. */ grunt.renameTask('watch', 'delta'); - grunt.registerTask('watch', [ 'build', 'karma:unit', 'connect', 'delta' ]); + grunt.registerTask('watch', ['build', 'karma:unit', 'connect', 'delta']); /** * The default task is to build and compile. */ - grunt.registerTask('default', [ 'build', 'compile' ]); + grunt.registerTask('default', ['build', 'compile']); /** * The `build` task gets your app ready to run for development and testing. @@ -785,13 +783,50 @@ module.exports = function (grunt) { grunt.registerTask('sassTemplate', 'Transforming sass file', function () { var mainScss = grunt.config('app_files.sass'); var processedScss = path.join(path.dirname(mainScss), path.basename(mainScss, ".tpl.scss")) + ".scss.processed"; + //debugger; + var scssPartials = grunt.file.expand("src/**/_*.scss"); + scssPartials = scssPartials.map(function (value) { + return slash(path.relative(path.dirname(mainScss), value)); + }); + + scssPartials = scssPartials.sort(function compare(a, b) { + var dottedA = a.indexOf("..") === 0, + dottedB = b.indexOf("..") === 0, + isSlashedA = a.indexOf("/") > 0, + isSlashedB = b.indexOf("/") > 0; + + if (isSlashedA && isSlashedB) { + if (dottedA && dottedB) { + return a.localeCompare(b); + } else if (dottedA) { + return 1; + } else if (dottedB) { + return -1; + } + + + + } else if(isSlashedA) { + return 1; + } else if (isSlashedB) { + return -1; + } + + + }); + grunt.config.set('app_files.processedSass', processedScss); grunt.log.write("Temp file: " + processedScss); grunt.file.copy(mainScss, processedScss, { process: function (contents, path) { - return grunt.template.process(contents, grunt.config()); + return grunt.template.process(contents, { + data: { + build_configs: grunt.config("build_configs"), + partials: scssPartials + } + }); } }); }); diff --git a/package.json b/package.json index 5a8cc8c7..09c6592e 100644 --- a/package.json +++ b/package.json @@ -19,10 +19,10 @@ "connect-gzip-static": "^1.0.0", "connect-modrewrite": "0.7.x", "grunt": "~0.4.1", - "grunt-bump": "0.0.16", + "grunt-bump": "0.0.14", "grunt-changelog": "~0.2.x", - "grunt-contrib-clean": "~0.6.0", - "grunt-contrib-concat": "~0.5.0", + "grunt-contrib-clean": "^0.5.0", + "grunt-contrib-concat": "^0.4.0", "grunt-contrib-connect": "0.9.x", "grunt-contrib-copy": "0.7.x", "grunt-contrib-jshint": "0.10.x", @@ -32,19 +32,15 @@ "grunt-html2js": "~0.2.3", "grunt-karma": "0.9.x", "grunt-ngmin": "0.0.3", - "grunt-sass": "0.16.x", + "grunt-sass": "0.17.x", "karma-chrome-launcher": "~0.1.1", "karma-coverage": "~0.2", "karma-firefox-launcher": "~0.1.3", - "karma-jasmine": "~0.3.x", + "karma-jasmine": "^0.2.2", "karma-phantomjs-launcher": "~0.1.1", - "lodash": "~2.4.1" + "lodash": "~2.4.1", + "slash": "^1.0.0" }, "private": true, - "dependencies": { - "karma-jasmine": "^0.2.2", - "grunt-contrib-clean": "^0.5.0", - "grunt-bump": "0.0.14", - "grunt-contrib-concat": "^0.4.0" - } + "dependencies": {} } diff --git a/src/app/annotationLibrary/_annotationLibrary.scss b/src/app/annotationLibrary/_annotationLibrary.scss index 56c468b6..d357ff38 100644 --- a/src/app/annotationLibrary/_annotationLibrary.scss +++ b/src/app/annotationLibrary/_annotationLibrary.scss @@ -1,5 +1,5 @@ //$loadGifPath: $IMAGE_ASSET_PATH + 'assets/img/load.gif'; -$loadGifPath: image-url('load.gif'); +@import "../annotationViewer/annotationViewer"; /* Library list */ .annotation-paging { diff --git a/src/app/annotationViewer/_annotation_viewer.scss b/src/app/annotationViewer/_annotationViewer.scss similarity index 100% rename from src/app/annotationViewer/_annotation_viewer.scss rename to src/app/annotationViewer/_annotationViewer.scss diff --git a/src/sass/application.tpl.scss b/src/sass/application.tpl.scss index f0819e42..81450b82 100644 --- a/src/sass/application.tpl.scss +++ b/src/sass/application.tpl.scss @@ -5,56 +5,25 @@ */ -$DEBUG: '<%= build_configs.current.key === "development" %>' == 'true'; +$DEBUG: "<%= build_configs.current.key === 'development' %>" == "true"; //@debug "Debug build is #{$DEBUG}"; -//$IMAGE_ASSET_PATH: '<%= build_configs.current.siteDir %>'; +//$IMAGE_ASSET_PATH: ''; /** * First, we include jlong's Twitter Bootstrap SCSS files. Only the ones used in the * project should be imported as the rest are just wasting space. */ -@import '../../vendor/sass-bootstrap/lib/bootstrap.scss'; - -@import "base.scss"; - -@import "layout"; - -@import "time_formats"; - -@import "touch/touch"; - -@import "angularGrowlCustomisation"; - -// TODO: create someway to automatically import files -//@import "partials/*"; - - -@import "../app/audioControl/_volumeControl.scss"; -@import "../app/annotationViewer/annotation_viewer"; -@import "../app/annotationViewer/gridLines/gridLines"; -@import "../app/audioEvents/audio_events"; -@import "../app/annotationLibrary/annotationLibrary"; -@import "../app/bookmarks/bookmarks"; -@import "../app/d3Bindings/calendarView/calendarView"; -@import "../app/d3Bindings/timelineView/timelineView"; -@import "../app/d3Bindings/dotView/dotView"; -@import "../app/d3Bindings/terrainView/terrainView"; -@import "../app/d3Bindings/audioView/audioView"; -@import "../app/home/home"; -@import "../app/listen/listen"; -@import "../app/login/login_control"; -@import "../app/photos/photos"; -@import "../app/projects/projects"; -@import "../app/recordInformation/record_information"; -@import "../app/recordings/audio_recordings"; -@import "../app/recordings/recentRecordings/recentRecordings"; -@import "../app/demo/rendering"; -@import "../app/search/saved_searches"; -@import "../app/sites/sites"; -@import "../app/tags/tags"; -@import "../app/birdWalks/birdWalks"; -@import "../components/directives/baw-toggle/_bawToggle.scss"; +@import "../../vendor/sass-bootstrap/lib/bootstrap.scss"; + +/** + * Now import all partials. + * Partials in src/sass/** will be added first + */ +<% partials.forEach(function(path){ %> +@import "<%= path %>"; +<% }); %> +