diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..b13b70e --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "bower_components" +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d407f23 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = tab +indent_size = 2 + +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..51e7c58 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +.tmp +.sass-cache +dist +node_modules +bower_components +*.sublime-workspace diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..45382bd --- /dev/null +++ b/.jshintrc @@ -0,0 +1,19 @@ +{ + "bitwise": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": true, + "newcap": true, + "noarg": true, + "quotmark": "single", + "undef": true, + "unused": true, + "strict": true, + "trailing": true, + + "smarttabs": true, + + "browser": true, + "node": true +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b9207e5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - '0.8' + - '0.10' diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..3f231d6 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,311 @@ +'use strict'; + +var LIVE_RELOAD_PORT = 35729; +var lrSnippet = require('connect-livereload')({port: LIVE_RELOAD_PORT}); +var gateway = require('gateway'); + +var mountFolder = function (connect, dir) { + return connect.static(require('path').resolve(dir)); +}; + +var mountPHP = function (dir, options) { + return gateway(require('path').resolve(dir), options); +}; + +module.exports = function (grunt) { + + // Load grunt tasks + require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); + + // App configuration, used throughout + var appConfig = { + src: 'src', + dist: 'dist', + test: 'test', + tmp: '.tmp' + }; + + // TODO :: Read this from .bowerrc + var bowerConfig = { + directory: 'bower_components' + }; + + grunt.initConfig({ + app: appConfig, + bower: bowerConfig, + watch: { + scripts: { + files: ['<%= app.src %>/htdocs/js/**/*.js'], + tasks: ['concurrent:scripts'], + options: { + livereload: LIVE_RELOAD_PORT + } + }, + scss: { + files: ['<%= app.src %>/htdocs/css/**/*.scss'], + tasks: ['compass:dev'] + }, + tests: { + files: ['<%= app.test %>/*.html', '<%= app.test %>/**/*.js'], + tasks: ['concurrent:tests'] + }, + livereload: { + options: { + livereload: LIVE_RELOAD_PORT + }, + files: [ + '<%= app.src %>/htdocs/**/*.html', + '<%= app.src %>/htdocs/css/**/*.css', + '<%= app.src %>/htdocs/img/**/*.{png,jpg,jpeg,gif}', + '.tmp/css/**/*.css' + ] + }, + gruntfile: { + files: ['Gruntfile.js'], + tasks: ['jshint:gruntfile'] + } + }, + concurrent: { + scripts: ['jshint:scripts', 'mocha_phantomjs'], + tests: ['jshint:tests', 'mocha_phantomjs'], + predist: [ + 'jshint:scripts', + 'jshint:tests', + 'compass' + ], + dist: [ + 'requirejs:dist', + 'cssmin:dist', + 'htmlmin:dist', + 'uglify', + 'copy' + ] + }, + connect: { + options: { + hostname: 'localhost' + }, + dev: { + options: { + base: '<%= app.src %>/htdocs', + port: 8080, + components: bowerConfig.directory, + middleware: function (connect, options) { + return [ + lrSnippet, + mountFolder(connect, '.tmp'), + mountFolder(connect, options.components), + mountPHP(options.base), + mountFolder(connect, options.base) + ]; + } + } + }, + dist: { + options: { + base: '<%= app.dist %>/htdocs', + port: 8081, + keepalive: true, + middleware: function (connect, options) { + return [ + mountPHP(options.base), + mountFolder(connect, options.base) + ]; + } + } + }, + test: { + options: { + base: '<%= app.test %>', + components: bowerConfig.directory, + port: 8000, + middleware: function (connect, options) { + return [ + mountFolder(connect, '.tmp'), + mountFolder(connect, 'bower_components'), + mountFolder(connect, 'node_modules'), + mountFolder(connect, options.base), + mountFolder(connect, appConfig.src + '/htdocs/js') + ]; + } + } + } + }, + jshint: { + options: { + jshintrc: '.jshintrc' + }, + gruntfile: ['Gruntfile.js'], + scripts: ['<%= app.src %>/htdocs/js/**/*.js'], + tests: ['<%= app.test %>/**/*.js'] + }, + compass: { + dev: { + options: { + sassDir: '<%= app.src %>/htdocs/css', + cssDir: '<%= app.tmp %>/css', + environment: 'development' + } + } + }, + mocha_phantomjs: { + all: { + options: { + urls: [ + 'http://localhost:<%= connect.test.options.port %>/index.html' + ] + } + } + }, + requirejs: { + dist: { + options: { + name: 'index', + baseUrl: appConfig.src + '/htdocs/js', + out: appConfig.dist + '/htdocs/js/index.js', + optimize: 'uglify2', + mainConfigFile: appConfig.src + '/htdocs/js/index.js', + useStrict: true, + wrap: true, + uglify2: { + report: 'gzip', + mangle: true, + compress: true, + preserveComments: 'some' + } + } + } + }, + cssmin: { + dist: { + files: { + '<%= app.dist %>/htdocs/css/index.css': [ + '<%= app.src %>/htdocs/css/**/*.css', + '.tmp/css/**/*.css' + ] + } + } + }, + htmlmin: { + dist: { + options: { + collapseWhitespace: true + }, + files: [{ + expand: true, + cwd: '<%= app.src %>', + src: '**/*.html', + dest: '<%= app.dist %>' + }] + } + }, + uglify: { + options: { + mangle: true, + compress: true, + report: 'gzip' + }, + dist: { + files: { + '<%= app.dist %>/htdocs/lib/requirejs/require.js': + ['<%= bower.directory %>/requirejs/require.js'], + '<%= app.dist %>/htdocs/lib/html5shiv/html5shiv.js': + ['<%= bower.directory %>/html5shiv-dist/html5shiv.js'] + } + } + }, + copy: { + app: { + expand: true, + cwd: '<%= app.src %>/htdocs', + dest: '<%= app.dist %>/htdocs', + src: [ + 'img/**/*.{png,gif,jpg,jpeg}', + '**/*.php' + ] + }, + conf: { + expand: true, + cwd: '<%= app.src %>/conf', + dest: '<%= app.dist/conf', + src: [ + '**/*', + '!**/*.orig' + ] + }, + lib: { + expand: true, + cwd: '<%= app.src %>/lib', + dest: '<%= app.dist %>/lib', + src: [ + '**/*' + ] + } + }, + replace: { + dist: { + src: [ + '<%= app.dist %>/htdocs/index.html', + '<%= app.dist %>/**/*.php' + ], + overwrite: true, + replacements: [ + { + from: 'requirejs/require.js', + to: 'lib/requirejs/require.js' + }, + { + from: 'html5shiv-dist/html5shiv.js', + to: 'lib/html5shiv/html5shiv.js' + } + ] + } + }, + open: { + dev: { + path: 'http://localhost:<%= connect.dev.options.port %>' + }, + test: { + path: 'http://localhost:<%= connect.test.options.port %>' + }, + dist: { + path: 'http://localhost:<%= connect.dist.options.port %>' + } + }, + clean: { + dist: ['<%= app.dist %>'], + dev: ['<%= app.tmp %>', '.sass-cache'] + } + }); + + grunt.event.on('watch', function (action, filepath) { + // Only lint the file that actually changed + grunt.config(['jshint', 'scripts'], filepath); + }); + + grunt.registerTask('test', [ + 'clean:dist', + 'connect:test', + 'mocha_phantomjs' + ]); + + grunt.registerTask('build', [ + 'clean:dist', + 'concurrent:predist', + 'concurrent:dist', + 'replace', + 'open:dist', + 'connect:dist' + ]); + + grunt.registerTask('default', [ + 'clean:dist', + 'compass:dev', + 'connect:test', + 'connect:dev', + 'open:test', + 'open:dev', + 'watch' + ]); + +}; diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..f21fd7b --- /dev/null +++ b/bower.json @@ -0,0 +1,9 @@ +{ + "name": "earthquake-latest-earthquakes", + "version": "0.0.0", + "dependencies": { + "html5shiv-dist": "~3.6.2", + "requirejs": "~2.1.6" + }, + "devDependencies": {} +} diff --git a/earthquake-latest-earthquakes.sublime-project b/earthquake-latest-earthquakes.sublime-project new file mode 100644 index 0000000..330925e --- /dev/null +++ b/earthquake-latest-earthquakes.sublime-project @@ -0,0 +1,28 @@ +{ + "folders": + [ + { + "path": ".", + "file_exclude_patterns": [ + "earthquake-latest-earthquakes.sublime-workspace" + ], + "folder_exclude_patterns": [ + ".sass-cache", + "node_modules", + "bower_components", + ".tmp" + ] + } + ], + "settings": { + "ensure_newline_at_eof_on_save": true, + "rulers": [80], + "tab_size": 2, + "auto_indent": true, + "smart_indent": true, + "indent_to_bracket": false, + "translate_tabs_to_spaces": false, + "trim_automatic_white_space": true, + "trim_trailing_white_space_one_save": true + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..cef4102 --- /dev/null +++ b/package.json @@ -0,0 +1,40 @@ +{ + "name": "earthquake-latest-earthquakes", + "version": "0.0.0", + "description": "Mobile friendly, interactive earthquake map and list application.", + "repository": {"type":"git","url":"https://github.com/usgs/earthquake-latest-earthquakes.git"}, + "keywords": [ + "usgs" + ], + "scripts": { + "test": "grunt test" + }, + "dependencies": {}, + "devDependencies": { + "chai": "~1.7.0", + "connect-livereload": "~0.2.0", + "gateway": "~0.1.1", + "grunt": "~0.4.1", + "grunt-concurrent": "~0.3.0", + "grunt-contrib-clean": "~0.4.1", + "grunt-contrib-compass": "~0.2.0", + "grunt-contrib-connect": "~0.3.0", + "grunt-contrib-copy": "~0.4.1", + "grunt-contrib-cssmin": "~0.6.1", + "grunt-contrib-htmlmin": "~0.1.3", + "grunt-contrib-jshint": "~0.6.0", + "grunt-contrib-requirejs": "~0.4.1", + "grunt-contrib-uglify": "~0.2.2", + "grunt-contrib-watch": "~0.4.4", + "grunt-mocha-phantomjs": "~0.2.8", + "grunt-open": "~0.2.0", + "grunt-text-replace": "~0.3.6", + "matchdep": "~0.1.2", + "mocha": "~1.9.0", + "sinon": "~1.7.3" + }, + "engines": { + "node": ">=0.8.0" + } +} + diff --git a/src/conf/config.ini.orig b/src/conf/config.ini.orig new file mode 100644 index 0000000..140bfb0 --- /dev/null +++ b/src/conf/config.ini.orig @@ -0,0 +1,2 @@ +MOUNT_PATH='/absolute/url/path'; +MOUNT_DIR='/absolute/file_system/path'; diff --git a/src/htdocs/css/index.scss b/src/htdocs/css/index.scss new file mode 100644 index 0000000..98bb0ae --- /dev/null +++ b/src/htdocs/css/index.scss @@ -0,0 +1,10 @@ +@import 'compass/css3'; + +* { + @include box-sizing(border-box); +} + +h1 { + text-align:center; + color:#222; +} diff --git a/src/htdocs/favicon.ico b/src/htdocs/favicon.ico new file mode 100644 index 0000000..79311cf Binary files /dev/null and b/src/htdocs/favicon.ico differ diff --git a/src/htdocs/index.html b/src/htdocs/index.html new file mode 100644 index 0000000..0b912e5 --- /dev/null +++ b/src/htdocs/index.html @@ -0,0 +1,24 @@ + + + + + + + + + Page Title + + + + + + + + + +

Page Title

+ + + + + diff --git a/src/htdocs/js/index.js b/src/htdocs/js/index.js new file mode 100644 index 0000000..77381a7 --- /dev/null +++ b/src/htdocs/js/index.js @@ -0,0 +1,14 @@ +require.config({ + baseUrl: 'js', + paths: { + }, + shim: { + } +}); + +require([ +], function ( +) { + 'use strict'; + console.log('Framework Loaded'); +}); diff --git a/src/lib/pre-install b/src/lib/pre-install new file mode 100755 index 0000000..1b6214a --- /dev/null +++ b/src/lib/pre-install @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +pushd `dirname $0` > /dev/null 2>&1; + +configFile='../conf/config.ini'; +httpdFile='../conf/httpd.conf'; + +if [ ! -f $configFile ]; then + # TODO :: Prompt for installation configuration stuff + cp ${configFile}.orig $configFile; +fi + +source $configFile; + +cat << EOF > $httpdFile +Alias $MOUNT_PATH $MOUNT_DIR + +EOF + +popd > /dev/null 2>&1; + +exit 0; diff --git a/src/lib/uninstall b/src/lib/uninstall new file mode 100755 index 0000000..d467c9b --- /dev/null +++ b/src/lib/uninstall @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +push `dirname $0` > /dev/null 2>&1; + +configFile='../conf/config.ini'; +httpdFile='../conf/httpd.conf'; + +# Remove httpd config file, but leave the config INI file in place +rm -vf ../httpd.conf; + +popd > /dev/null 2>&1; + +exit 0; diff --git a/test/favicon.ico b/test/favicon.ico new file mode 100644 index 0000000..79311cf Binary files /dev/null and b/test/favicon.ico differ diff --git a/test/index.html b/test/index.html new file mode 100644 index 0000000..ba38616 --- /dev/null +++ b/test/index.html @@ -0,0 +1,23 @@ + + + + + + + + + Test Suite + + + + + + + +

Test Suite

+
+ + + + + diff --git a/test/index.js b/test/index.js new file mode 100644 index 0000000..dec3ef4 --- /dev/null +++ b/test/index.js @@ -0,0 +1,40 @@ +require.config({ + baseUrl: '..', + paths: { + mocha: 'mocha/mocha', + chai: 'chai/chai', + sinon: 'sinon/pkg/sinon' + }, + shim: { + mocha: { + exports: 'mocha' + }, + chai: { + deps: ['mocha'], + exports: 'chai' + }, + sinon: { + exports: 'sinon' + } + } +}); + +require([ + 'mocha', +], function ( + mocha +) { + 'use strict'; + + mocha.setup('bdd'); + + // Add each test class here as they are implemented + require([ + ], function () { + if (window.mochaPhantomJS) { + window.mochaPhantomJS.run(); + } else { + mocha.run(); + } + }); +});