Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shaefner-usgs committed Aug 4, 2016
0 parents commit 0dc6f4b
Show file tree
Hide file tree
Showing 40 changed files with 1,286 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.build
.git
dist
node_modules
src/conf/config.ini
src/conf/httpd.conf
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
.build
dist
node_modules
*.sublime-workspace
src/conf/config.ini*
src/conf/httpd.conf
18 changes: 18 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"bitwise": true,
"curly": true,
"eqeqeq": true,
"esnext": true,
"immed": true,
"latedef": true,
"newcap": false,
"noarg": true,
"quotmark": "single",
"undef": true,
"unused": true,
"strict": true,
"trailing": true,

"browser": true,
"node": true
}
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
sudo: false
language: php
php:
- '5.6'
before_install:
- composer self-update
- nvm install stable
- nvm use stable
- npm install -g grunt-cli
- npm --version
- node --version
- npm list -g
install:
- npm install phantomjs-prebuilt
- npm install
- php src/lib/pre-install.php --non-interactive
script:
- npm test
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## Docker file to build app as container

FROM debian:jessie
MAINTAINER "Jeremy Fee" <[email protected]>
LABEL dockerfile_version="v0.1.0"


# install dependencies
RUN apt-key update -y \
&& apt-get update -y \
&& apt-get install -y \
bzip2 \
curl \
git \
php5-cgi \
php5-curl \
&& curl -o- \
https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh \
| /bin/bash \
&& /bin/bash --login -c " \
nvm install 4.2.4 \
&& npm install -g grunt-cli"

# copy application (ignores set in .dockerignore)
COPY . /hazdev-project

# configure application
RUN /bin/bash --login -c " \
cd /hazdev-project \
&& npm install \
&& php ./src/lib/pre-install.php --non-interactive \
&& grunt builddist \
&& rm -r \
/hazdev-project/node_modules/grunt-mocha-phantomjs \
/root/.npm \
/tmp/npm* \
"


WORKDIR /hazdev-project
EXPOSE 8881
CMD /bin/bash --login -c "grunt rundist"
64 changes: 64 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
'use strict';

module.exports = function (grunt) {

var gruntConfig = require('./gruntconfig');

gruntConfig.tasks.forEach(grunt.loadNpmTasks);
grunt.initConfig(gruntConfig);

grunt.event.on('watch', function (action, filepath) {
// Only lint the file that actually changed
grunt.config(['jshint', 'scripts'], filepath);
});

grunt.registerTask('test', [
'build',
'connect:test',
'mocha_phantomjs'
]);

grunt.registerTask('build', [
'clean:build',
'jshint:scripts',
'jshint:tests',
'browserify',
'postcss:build',
'copy:build',
'copy:test'
]);

grunt.registerTask('builddist', [
'build',
'clean:dist',
'copy:dist',
'postcss:dist',
'uglify'
]);

grunt.registerTask('rundist', [
'configureRewriteRules',
'configureProxies:dist',
'connect:template',
'connect:dist'
]);

grunt.registerTask('dist', [
'builddist',
'rundist'
]);

grunt.registerTask('default', [
'build',
'configureRewriteRules',
'configureProxies:dev',
'configureProxies:test',
'connect:template',
'connect:dev',
'connect:test',
'connect:example',
'mocha_phantomjs',
'watch'
]);

};
5 changes: 5 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Unless otherwise noted, This software is in the public domain because it
contains materials that originally came from the United States Geological
Survey, an agency of the United States Department of Interior. For more
information, see the official USGS copyright policy at
http://www.usgs.gov/visual-id/credit_usgs.html#copyright
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
hazdev-project-skeleton
==============

Project skeleton for hazdev web applications.



Generating a new Project
------------------------

- Download ZIP of current repository (button to the right of URLs)
- extract and rename folder to `new-project`
- update package.json, README.md with `new-project` name
- set default MOUNT_PATH in src/lib/configure.inc.php
- import into new repository


Using the Generated Project
---------------------------

## Getting Started
- run `npm install` to install application development dependencies
- configure the application
- run `grunt` from the install directory

## Configuration
- run `src/lib/pre-install` to setup config.ini
- configuration options are defined in `src/lib/configure.inc.php`
- `MOUNT_PATH` is the base url for the application

## CSS
- SCSS files (`*.scss`, `!_*.scss`) in the `src/htdocs/css` directory are compiled.

- Path is configured in `gruntconfig/config.js`:
```
cssPath: [
'src/htdocs/css',
'node_modules/hazdev-webutils/src'
]
```

## JS
- JS files (`*.js`) in the `src/htdocs/js` directory are compiled.

- Path is configured in `gruntconfig/config.js`:
```
jsPath: {
// DIRECTORY: EXPORT_PATTERN,
# export all files in these directories in htdocs/js/bundle.js
# for use in testing
'src/htdocs/js': '*/*.js',
'node_modules/hazdev-webutils/src': '**/*.js',
# add to path, but don't export
'node_modules/other-module/dist': null
}
```

## Docker

### Building a container

From root of project, run:
```
docker build -t project-skeleton:version .
```

### Running container

- Run the container using the tag
```
docker run -it -p 8000:8881 project-skeleton:version
```
- Connect to running container in browser
```
docker-machine env default \
| grep HOST \
| sed s/.*tcp/http/g \
| awk -F: '{print $1":"$2":8000"}' \
| xargs open
```
3 changes: 3 additions & 0 deletions etc/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"test": "Hello World"
}
40 changes: 40 additions & 0 deletions example/_config.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

$SITE_TITLE = 'Earthquake Hazards Program';
$SITE_URL = 'earthquake.usgs.gov';


$SITE_DESCRIPTION = 'USGS Earthquake Hazards Program, responsible for' .
' monitoring, reporting, and researching earthquakes and' .
' earthquake hazards';

$SITE_KEYWORDS = 'aftershock,earthquake,epicenter,fault,foreshock,geologist,' .
'geophysics,hazard,hypocenter,intensity,intensity scale,magnitude,' .
'magnitude scale,mercalli,plate,richter,seismic,seismicity,seismogram,' .
'seismograph,seismologist,seismology,subduction,tectonics,tsunami,quake,' .
'sismologico,sismologia';

$SITE_SITENAV =
navItem('#earthquakes', 'Earthquakes') .
navItem('#hazards', 'Hazards') .
navItem('#learn', 'Learn') .
navItem('#data', 'Data') .
navItem('#monitoring', 'Monitoring') .
navItem('#research', 'Research')
;

$SITE_COMMONNAV = '
<a href="#home">Home</a>
<a href="#aboutus">About Us</a>
<a href="#contactus">Contact Us</a>
<a href="#legal">Legal</a>
<a href="#partners">Partners</a>
';


// add site css
if (!isset($HEAD)) {
$HEAD = '';
}
$HEAD = '<link rel="stylesheet" href="/theme/site/earthquake/index.css"/>' .
$HEAD;
5 changes: 5 additions & 0 deletions example/_navigation.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

echo navItem('/example.php', 'Examples');

?>
17 changes: 17 additions & 0 deletions example/example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
if (!isset($TEMPLATE)) {

$TITLE = 'Examples Index';

// If you want to include section navigation.
// The nearest _navigation.inc.php file will be used by default
$NAVIGATION = true;

include 'template.inc.php';
}
?>


<p class="alert info">
Choose an example from the left navigation.
</p>
Loading

0 comments on commit 0dc6f4b

Please sign in to comment.