Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
scaffold out the web app.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehunter-usgs committed Jan 23, 2014
1 parent dd98353 commit 37d27a3
Show file tree
Hide file tree
Showing 20 changed files with 584 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
@@ -0,0 +1,3 @@
{
"directory": "bower_components"
}
14 changes: 14 additions & 0 deletions .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
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* text=auto
7 changes: 7 additions & 0 deletions .gitignore
@@ -0,0 +1,7 @@
.DS_Store
.tmp
.sass-cache
dist
node_modules
bower_components
*.sublime-workspace
19 changes: 19 additions & 0 deletions .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
}
4 changes: 4 additions & 0 deletions .travis.yml
@@ -0,0 +1,4 @@
language: node_js
node_js:
- '0.8'
- '0.10'
311 changes: 311 additions & 0 deletions 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'
]);

};
9 changes: 9 additions & 0 deletions 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": {}
}

0 comments on commit 37d27a3

Please sign in to comment.