From 0dc6f4b407b72c2780572da405e91d0694ca23b3 Mon Sep 17 00:00:00 2001 From: Scott Haefner Date: Thu, 4 Aug 2016 12:54:55 -0700 Subject: [PATCH] initial commit --- .dockerignore | 6 ++ .editorconfig | 14 +++++ .gitattributes | 1 + .gitignore | 7 +++ .jshintrc | 18 ++++++ .travis.yml | 18 ++++++ Dockerfile | 42 +++++++++++++ Gruntfile.js | 64 +++++++++++++++++++ LICENSE.md | 5 ++ README.md | 83 ++++++++++++++++++++++++ etc/data.json | 3 + example/_config.inc.php | 40 ++++++++++++ example/_navigation.inc.php | 5 ++ example/example.php | 17 +++++ gruntconfig/browserify.js | 76 ++++++++++++++++++++++ gruntconfig/clean.js | 17 +++++ gruntconfig/config.js | 48 ++++++++++++++ gruntconfig/connect.js | 111 +++++++++++++++++++++++++++++++++ gruntconfig/copy.js | 53 ++++++++++++++++ gruntconfig/index.js | 33 ++++++++++ gruntconfig/jshint.js | 24 +++++++ gruntconfig/mocha_phantomjs.js | 15 +++++ gruntconfig/postcss.js | 54 ++++++++++++++++ gruntconfig/uglify.js | 30 +++++++++ gruntconfig/watch.js | 72 +++++++++++++++++++++ package.json | 50 +++++++++++++++ src/conf/config.inc.php | 11 ++++ src/htdocs/_config.inc.php | 39 ++++++++++++ src/htdocs/css/index.scss | 4 ++ src/htdocs/favicon.ico | Bin 0 -> 1406 bytes src/htdocs/index.php | 24 +++++++ src/htdocs/js/index.js | 25 ++++++++ src/lib/configure.inc.php | 100 +++++++++++++++++++++++++++++ src/lib/pre-install | 19 ++++++ src/lib/pre-install.php | 67 ++++++++++++++++++++ src/lib/uninstall | 13 ++++ test/favicon.ico | Bin 0 -> 1406 bytes test/spec/ExampleTest.js | 35 +++++++++++ test/test.html | 27 ++++++++ test/test.js | 16 +++++ 40 files changed, 1286 insertions(+) create mode 100755 .dockerignore create mode 100755 .editorconfig create mode 100755 .gitattributes create mode 100755 .gitignore create mode 100755 .jshintrc create mode 100755 .travis.yml create mode 100755 Dockerfile create mode 100755 Gruntfile.js create mode 100755 LICENSE.md create mode 100755 README.md create mode 100755 etc/data.json create mode 100755 example/_config.inc.php create mode 100755 example/_navigation.inc.php create mode 100755 example/example.php create mode 100755 gruntconfig/browserify.js create mode 100755 gruntconfig/clean.js create mode 100755 gruntconfig/config.js create mode 100755 gruntconfig/connect.js create mode 100755 gruntconfig/copy.js create mode 100755 gruntconfig/index.js create mode 100755 gruntconfig/jshint.js create mode 100755 gruntconfig/mocha_phantomjs.js create mode 100755 gruntconfig/postcss.js create mode 100755 gruntconfig/uglify.js create mode 100755 gruntconfig/watch.js create mode 100755 package.json create mode 100755 src/conf/config.inc.php create mode 100755 src/htdocs/_config.inc.php create mode 100755 src/htdocs/css/index.scss create mode 100755 src/htdocs/favicon.ico create mode 100755 src/htdocs/index.php create mode 100755 src/htdocs/js/index.js create mode 100755 src/lib/configure.inc.php create mode 100755 src/lib/pre-install create mode 100755 src/lib/pre-install.php create mode 100755 src/lib/uninstall create mode 100755 test/favicon.ico create mode 100755 test/spec/ExampleTest.js create mode 100755 test/test.html create mode 100755 test/test.js diff --git a/.dockerignore b/.dockerignore new file mode 100755 index 0000000..0ea0d32 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.build +.git +dist +node_modules +src/conf/config.ini +src/conf/httpd.conf diff --git a/.editorconfig b/.editorconfig new file mode 100755 index 0000000..2078b45 --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.gitattributes b/.gitattributes new file mode 100755 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..96d0fd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +.build +dist +node_modules +*.sublime-workspace +src/conf/config.ini* +src/conf/httpd.conf diff --git a/.jshintrc b/.jshintrc new file mode 100755 index 0000000..7ec894d --- /dev/null +++ b/.jshintrc @@ -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 +} diff --git a/.travis.yml b/.travis.yml new file mode 100755 index 0000000..8418935 --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..e5de476 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +## Docker file to build app as container + +FROM debian:jessie +MAINTAINER "Jeremy Fee" +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" diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100755 index 0000000..36788ce --- /dev/null +++ b/Gruntfile.js @@ -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' + ]); + +}; diff --git a/LICENSE.md b/LICENSE.md new file mode 100755 index 0000000..77620d3 --- /dev/null +++ b/LICENSE.md @@ -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 diff --git a/README.md b/README.md new file mode 100755 index 0000000..5b80c50 --- /dev/null +++ b/README.md @@ -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 + ``` diff --git a/etc/data.json b/etc/data.json new file mode 100755 index 0000000..b23bfe8 --- /dev/null +++ b/etc/data.json @@ -0,0 +1,3 @@ +{ + "test": "Hello World" +} diff --git a/example/_config.inc.php b/example/_config.inc.php new file mode 100755 index 0000000..db9d1e1 --- /dev/null +++ b/example/_config.inc.php @@ -0,0 +1,40 @@ +Home + About Us + Contact Us + Legal + Partners +'; + + +// add site css +if (!isset($HEAD)) { + $HEAD = ''; +} +$HEAD = '' . + $HEAD; diff --git a/example/_navigation.inc.php b/example/_navigation.inc.php new file mode 100755 index 0000000..193b724 --- /dev/null +++ b/example/_navigation.inc.php @@ -0,0 +1,5 @@ + diff --git a/example/example.php b/example/example.php new file mode 100755 index 0000000..63efe86 --- /dev/null +++ b/example/example.php @@ -0,0 +1,17 @@ + + + +

+ Choose an example from the left navigation. +

diff --git a/gruntconfig/browserify.js b/gruntconfig/browserify.js new file mode 100755 index 0000000..8b07edf --- /dev/null +++ b/gruntconfig/browserify.js @@ -0,0 +1,76 @@ +'use strict'; + + +var babelify = require('babelify'), + config = require('./config'), + glob = require('glob'); + + +var BUNDLE_CLASSES; + +BUNDLE_CLASSES = []; + + +Object.keys(config.jsPath).forEach(function (path) { + var files, + pattern; + + pattern = config.jsPath[path]; + if (pattern) { + path = path + '/'; + files = glob.sync(path + pattern); + files.forEach(function (file) { + var alias; + alias = file.replace(path, '').replace('.js', ''); + BUNDLE_CLASSES.push('./' + file + ':' + alias); + }); + } +}); + + +var browserify = { + + options: { + browserifyOptions: { + debug: true, + paths: Object.keys(config.jsPath) + }, + transform: [ + babelify.configure({ + presets: ['es2015'] + }) + ] + }, + + + 'bundle': { + src: [], + dest: config.build + '/' + config.src + '/htdocs/js/bundle.js', + options: { + alias: BUNDLE_CLASSES + } + }, + + 'entrypoints': { + expand: true, + cwd: './' + config.src + '/htdocs/js', + dest: './' + config.build + '/' + config.src + '/htdocs/js', + src: [ + '*.js' + ], + options: { + } + }, + + 'test': { + src: config.test + '/test.js', + dest: config.build + '/' + config.test + '/test.js', + options: { + external: BUNDLE_CLASSES + } + } + +}; + + +module.exports = browserify; diff --git a/gruntconfig/clean.js b/gruntconfig/clean.js new file mode 100755 index 0000000..1950ee7 --- /dev/null +++ b/gruntconfig/clean.js @@ -0,0 +1,17 @@ +'use strict'; + + +var config = require('./config'); + + +var clean = { + build: [ + config.build + ], + dist: [ + config.dist + ] +}; + + +module.exports = clean; diff --git a/gruntconfig/config.js b/gruntconfig/config.js new file mode 100755 index 0000000..587b44a --- /dev/null +++ b/gruntconfig/config.js @@ -0,0 +1,48 @@ +'use strict'; + + +var fs = require('fs'), + ini = require('ini'); + + +var config, + basePort, + iniConfig, + packageJson; + +basePort = 8880; +iniConfig = ini.parse(fs.readFileSync('./src/conf/config.ini', 'utf-8')); +packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf-8')); + + +config = { + build: '.build', + buildPort: basePort, + dist: 'dist', + distPort: basePort + 1, + etc: 'etc', + example: 'example', + examplePort: basePort + 2, + ini: iniConfig, + lib: 'lib', + packageJson: packageJson, + src: 'src', + templatePort: basePort + 3, + test: 'test', + testPort: basePort + 4, + liveReloadPort: basePort + 9, + + cssPath: [ + 'src/htdocs/css', + 'node_modules/hazdev-webutils/src' + ], + + jsPath: { + 'src/htdocs/js': '*/*.js', + 'node_modules/hazdev-webutils/src': '**/*.js' + } + +}; + + +module.exports = config; diff --git a/gruntconfig/connect.js b/gruntconfig/connect.js new file mode 100755 index 0000000..9200c8e --- /dev/null +++ b/gruntconfig/connect.js @@ -0,0 +1,111 @@ +'use strict'; + +var config = require('./config'); + + +var MOUNT_PATH = config.ini.MOUNT_PATH; + + +var addMiddleware = function (connect, options, middlewares) { + middlewares.unshift( + require('grunt-connect-rewrite/lib/utils').rewriteRequest, + require('grunt-connect-proxy/lib/utils').proxyRequest, + require('gateway')(options.base[0], { + '.php': 'php-cgi', + 'env': { + 'PHPRC': 'node_modules/hazdev-template/dist/conf/php.ini' + } + }) + ); + return middlewares; +}; + + +var connect = { + options: { + hostname: '*' + }, + + proxies: [ + { + context: '/theme/', + host: 'localhost', + port: config.templatePort, + rewrite: { + '^/theme': '' + } + } + ], + + rules: [ + { + from: '^' + MOUNT_PATH + '/(.*)$', + to: '/$1' + } + ], + + dev: { + options: { + base: [ + config.build + '/' + config.src + '/htdocs' + ], + livereload: config.liveReloadPort, + middleware: addMiddleware, + open: 'http://localhost:' + config.buildPort + + MOUNT_PATH + '/index.php', + port: config.buildPort + } + }, + + dist: { + options: { + base: [ + config.dist + '/htdocs' + ], + port: config.distPort, + keepalive: true, + open: 'http://localhost:' + config.distPort + + MOUNT_PATH + '/index.php', + middleware: addMiddleware + } + }, + + example: { + options: { + base: [ + config.example, + config.build + '/' + config.src + '/htdocs', + config.etc + ], + middleware: addMiddleware, + open: 'http://localhost:' + config.examplePort + '/example.php', + port: config.examplePort + } + }, + + template: { + options: { + base: [ + 'node_modules/hazdev-template/dist/htdocs' + ], + port: config.templatePort, + middleware: addMiddleware + } + }, + + test: { + options: { + base: [ + config.build + '/' + config.src + '/htdocs', + config.build + '/' + config.test, + config.etc, + 'node_modules' + ], + port: config.testPort, + open: 'http://localhost:' + config.testPort + '/test.html' + } + } +}; + + +module.exports = connect; diff --git a/gruntconfig/copy.js b/gruntconfig/copy.js new file mode 100755 index 0000000..f3eb870 --- /dev/null +++ b/gruntconfig/copy.js @@ -0,0 +1,53 @@ +'use strict'; + +var config = require('./config'); + + +var copy = { + + build: { + expand: true, + cwd: config.src, + dest: config.build + '/' + config.src, + src: [ + '**/*', + '!**/*.js', + '!**/*.scss', + '!**/*.orig' + ], + filter: 'isFile', + options: { + mode: true + } + }, + + test: { + expand: true, + cwd: config.test, + dest: config.build + '/' + config.test, + src: [ + '**/*', + '!**/*.js' + ], + filter: 'isFile' + }, + + dist: { + expand: true, + cwd: config.build + '/' + config.src, + dest: config.dist, + src: [ + '**/*', + '!**/*.js', + '!**/*.css' + ], + filter: 'isFile', + options: { + mode: true + } + } + +}; + + +module.exports = copy; diff --git a/gruntconfig/index.js b/gruntconfig/index.js new file mode 100755 index 0000000..db3339f --- /dev/null +++ b/gruntconfig/index.js @@ -0,0 +1,33 @@ +'use strict'; + + +var gruntConfig = { + config: require('./config'), + + browserify: require('./browserify'), + clean: require('./clean'), + connect: require('./connect'), + copy: require('./copy'), + jshint: require('./jshint'), + mocha_phantomjs: require('./mocha_phantomjs'), + postcss: require('./postcss'), + uglify: require('./uglify'), + watch: require('./watch'), + + tasks: [ + 'grunt-browserify', + 'grunt-connect-proxy', + 'grunt-connect-rewrite', + 'grunt-contrib-clean', + 'grunt-contrib-connect', + 'grunt-contrib-copy', + 'grunt-contrib-jshint', + 'grunt-contrib-uglify', + 'grunt-contrib-watch', + 'grunt-mocha-phantomjs', + 'grunt-postcss' + ] +}; + + +module.exports = gruntConfig; diff --git a/gruntconfig/jshint.js b/gruntconfig/jshint.js new file mode 100755 index 0000000..4adc1d1 --- /dev/null +++ b/gruntconfig/jshint.js @@ -0,0 +1,24 @@ +'use strict'; + + +var config = require('./config'); + + +var jshint = { + options: { + jshintrc: '.jshintrc' + }, + gruntfile: [ + 'Gruntfile.js', + 'gruntconfig/**/*.js' + ], + scripts: [ + config.src + '/htdocs/**/*.js' + ], + tests: [ + config.test + '/**/*.js' + ] +}; + + +module.exports = jshint; diff --git a/gruntconfig/mocha_phantomjs.js b/gruntconfig/mocha_phantomjs.js new file mode 100755 index 0000000..9a11423 --- /dev/null +++ b/gruntconfig/mocha_phantomjs.js @@ -0,0 +1,15 @@ +'use strict'; + +var config = require('./connect').test.options; + +var mocha_phantomjs = { + all: { + options: { + urls: [ + 'http://localhost:' + config.port + '/test.html' + ] + } + } +}; + +module.exports = mocha_phantomjs; diff --git a/gruntconfig/postcss.js b/gruntconfig/postcss.js new file mode 100755 index 0000000..81acd4c --- /dev/null +++ b/gruntconfig/postcss.js @@ -0,0 +1,54 @@ +'use strict'; + +var autoprefixer = require('autoprefixer'), + cssnano = require('cssnano'), + calc = require('postcss-calc'), + postcssImport = require('postcss-import'), + precss = require('precss'); + + +var config = require('./config'); + + +var postcss = { + + build: { + options: { + map: true, + processors: [ + postcssImport({ + path: config.cssPath + }), + precss(), + calc(), + autoprefixer({'browsers': 'last 3 versions'}) + ] + }, + cwd: config.src + '/htdocs', + dest: config.build + '/' + config.src + '/htdocs', + expand: true, + ext: '.css', + extDot: 'last', + src: [ + '**/*.scss', + '!**/_*.scss' + ] + }, + + dist: { + options: { + processors: [ + cssnano({zindex: false}) + ] + }, + cwd: config.build + '/' + config.src + '/htdocs', + dest: config.dist + '/htdocs', + expand: true, + src: [ + '**/*.css' + ] + } + +}; + +module.exports = postcss; diff --git a/gruntconfig/uglify.js b/gruntconfig/uglify.js new file mode 100755 index 0000000..9455c69 --- /dev/null +++ b/gruntconfig/uglify.js @@ -0,0 +1,30 @@ +'use strict'; + + +var config = require('./config'); + + +var uglify = { + + options: { + mangle: true, + compress: {}, + report: 'gzip' + }, + + dist: { + files: [{ + expand: true, + cwd: config.build + '/' + config.src, + src: [ + '**/*.js', + '!**/bundle.js' + ], + dest: config.dist + }] + } + +}; + + +module.exports = uglify; diff --git a/gruntconfig/watch.js b/gruntconfig/watch.js new file mode 100755 index 0000000..cd3c4c6 --- /dev/null +++ b/gruntconfig/watch.js @@ -0,0 +1,72 @@ +'use strict'; + + +var config = require('./config'); + + +var watch = { + + gruntfile: { + files: [ + 'Gruntfile.js', + 'gruntconfig/**/*.js' + ], + tasks: [ + 'jshint:gruntfile' + ] + }, + + livereload: { + options: { + livereload: config.liveReloadPort + }, + files: [ + config.build + '/' + config.src + '/**/*' + ] + }, + + scripts: { + files: [config.src + '/htdocs/**/*.js'], + tasks: [ + 'jshint:scripts', + 'browserify', + 'mocha_phantomjs' + ] + }, + + scss: { + files: [config.src + '/htdocs/**/*.scss'], + tasks: [ + 'postcss:build' + ] + }, + + static: { + files: [ + config.src + '/**/*', + '!**/*.js', + '!**/*.scss', + '!**/*.orig' + ], + tasks: [ + 'copy:build' + ] + }, + + tests: { + files: [ + config.test + '/*.html', + config.test + '/**/*.js' + ], + tasks: [ + 'jshint:tests', + 'copy:test', + 'browserify:test', + 'mocha_phantomjs' + ] + } + +}; + + +module.exports = watch; diff --git a/package.json b/package.json new file mode 100755 index 0000000..5d0922e --- /dev/null +++ b/package.json @@ -0,0 +1,50 @@ +{ + "name": "hazdev-project-skeleton", + "version": "0.1.0", + "description": "Skeleton for web applications.", + "repository": { + "type": "git", + "url": "https://github.com/usgs/hazdev-skeleton.git" + }, + "keywords": [ + "usgs" + ], + "scripts": { + "test": "grunt test" + }, + "license": "CC0-1.0", + "dependencies": {}, + "devDependencies": { + "autoprefixer": "^6.0.3", + "babel-preset-es2015": "^6.9.0", + "babelify": "^7.3.0", + "chai": "^3.4.0", + "compression": "^1.6.0", + "cssnano": "^3.3.1", + "gateway": "^1.0.0", + "glob": "^7.0.3", + "grunt": "^0.4.5", + "grunt-browserify": "^4.0.1", + "grunt-connect-proxy": "^0.2.0", + "grunt-connect-rewrite": "^0.2.1", + "grunt-contrib-clean": "^0.6.0", + "grunt-contrib-connect": "^0.11.2", + "grunt-contrib-copy": "^0.8.2", + "grunt-contrib-jshint": "^0.11.0", + "grunt-contrib-uglify": "^0.10.0", + "grunt-contrib-watch": "^0.6.1", + "grunt-mocha-phantomjs": "3.0.0", + "grunt-postcss": "^0.7.0", + "hazdev-template": "~0.2.4", + "hazdev-webutils": "~0.1.8", + "ini": "^1.2.1", + "mocha": "^2.1.0", + "postcss-calc": "^5.0.0", + "postcss-import": "^7.1.0", + "precss": "^1.3.0", + "sinon": "^1.17.1" + }, + "engines": { + "node": ">=0.10.0" + } +} diff --git a/src/conf/config.inc.php b/src/conf/config.inc.php new file mode 100755 index 0000000..4900d42 --- /dev/null +++ b/src/conf/config.inc.php @@ -0,0 +1,11 @@ +Home + About Us + Contact Us + Legal + Partners +'; + + +// add site css +if (!isset($HEAD)) { + $HEAD = ''; +} +$HEAD = '' . $HEAD; diff --git a/src/htdocs/css/index.scss b/src/htdocs/css/index.scss new file mode 100755 index 0000000..f9cb590 --- /dev/null +++ b/src/htdocs/css/index.scss @@ -0,0 +1,4 @@ +#application:after { + content: 'css content'; + display: block; +} diff --git a/src/htdocs/favicon.ico b/src/htdocs/favicon.ico new file mode 100755 index 0000000000000000000000000000000000000000..79311cf12c4f0faed91ffec487fc573144eb2a19 GIT binary patch literal 1406 zcmZQzU<5(|0R}M0U}azs1F|%L7$l?s#Ec9aKoUFn|NlROce^9Q@tcPk!uov~a_6No zeEI&Fp?PgB!_vbG7?P$%GF*Cio}qtBCqu>3LWUO~o-^#ew4Gtro+%7>U)*NcaB2;9 zgGWV2Ltr!n27L%Hk^s1vIC&AunYlR_S(td4p(4ycS$1YdCLV6E05cm4BO51>!^J89 zRKg9E + + diff --git a/src/htdocs/js/index.js b/src/htdocs/js/index.js new file mode 100755 index 0000000..d054bb1 --- /dev/null +++ b/src/htdocs/js/index.js @@ -0,0 +1,25 @@ +'use strict'; + +var View = require('mvc/View'); + + +var view; + +view = View({ + el: document.querySelector('#application') +}); + +view.render = function () { + view.el.innerHTML = view.model.get('content'); +}; + +new Promise(function (resolve/*, reject*/) { + view.model.set({ + content: 'waiting 2 seconds' + }); + setTimeout(resolve, 2000); +}).then(function () { + view.model.set({ + content: 'js content' + }); +}); diff --git a/src/lib/configure.inc.php b/src/lib/configure.inc.php new file mode 100755 index 0000000..b84b69f --- /dev/null +++ b/src/lib/configure.inc.php @@ -0,0 +1,100 @@ + array( + // 'prompt' => String, // Prompt to request value from user + // 'default' => String, // Value to use if input is empty + // 'secure' => Boolean // True if input should not be echo'd to console + // ) + + 'MOUNT_PATH' => array( + 'prompt' => 'URL Path for application', + 'default' => '/mount/path', + 'secure' => false + ) + +); + + +if (!function_exists('configure')) { + function configure ($prompt, $default = null, $secure = false) { + + echo $prompt; + if ($default != null) { + echo ' [' . $default . ']'; + } + echo ': '; + + if (NON_INTERACTIVE) { + // non-interactive + echo '(Non-interactive, using default)' . PHP_EOL; + return $default; + } + + if ($secure) { + system('stty -echo'); + $answer = trim(fgets(STDIN)); + system('stty echo'); + echo "\n"; + } else { + $answer = trim(fgets(STDIN)); + } + + if ($answer == '') { + $answer = $default; + } + + return $answer; + } +} + +// This script should only be included by the pre-install.php script. The +// calling script is responsible for defining the $CONFIG_FILE_INI and calling +// date_default_timezone_set prior to including this configuration script. + +$CONFIG = array(); +if (file_exists($CONFIG_FILE_INI)) { + $answer = configure('A previous configuration exists. ' . + 'Would you like to use it as defaults?', 'Y|n', false); + + if (strtoupper(substr($answer, 0, 1)) == 'Y') { + $CONFIG = parse_ini_file($CONFIG_FILE_INI); + print_r($CONFIG); + } + + $answer = configure('Would you like to save the old configuration file?', + 'Y|n', false); + + if (strtoupper(substr($answer, 0, 1)) == 'Y') { + $BAK_CONFIG_FILE = $CONFIG_FILE_INI . '.' . date('YmdHis'); + rename($CONFIG_FILE_INI, $BAK_CONFIG_FILE); + echo 'Old configuration saved to file: ' . basename($BAK_CONFIG_FILE) . + "\n"; + } +} + + +// write config +$FP_CONFIG = fopen($CONFIG_FILE_INI, 'w'); +fwrite($FP_CONFIG, ';; auto generated: ' . date('r') . "\n\n"); +foreach ($PROMPTS as $key => $item) { + $default = null; + if (isset($CONFIG[$key])) { + $default = $CONFIG[$key]; + } else if (isset($item['default'])) { + $default = $item['default']; + } + + fwrite($FP_CONFIG, $key . ' = "' . + configure($item['prompt'], $default, isset($item['secure']) ? $item['secure'] : false) . + "\"\n"); +} + + +// Do any custom prompting here + + +// Close the file +fclose($FP_CONFIG); diff --git a/src/lib/pre-install b/src/lib/pre-install new file mode 100755 index 0000000..78b4d5d --- /dev/null +++ b/src/lib/pre-install @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +pushd `dirname $0` > /dev/null 2>&1; + +PHP_BIN=`which php`; + +if [ -z "$PHP_BIN" ]; then + read -p 'PHP executable not found, enter path to php: ' PHP_BIN; +fi + +if [ -x "$PHP_BIN" ]; then + $PHP_BIN ./pre-install.php +else + echo 'PHP executable not found, unable to run pre-install.php'; + exit 1; +fi + +popd > /dev/null 2>&1; +exit 0; diff --git a/src/lib/pre-install.php b/src/lib/pre-install.php new file mode 100755 index 0000000..a14c4e1 --- /dev/null +++ b/src/lib/pre-install.php @@ -0,0 +1,67 @@ + + Order allow,deny + Allow from all + + + deny from all + + + ExpiresActive on + ExpiresDefault "access plus 1 days" + +'); 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 100755 index 0000000000000000000000000000000000000000..79311cf12c4f0faed91ffec487fc573144eb2a19 GIT binary patch literal 1406 zcmZQzU<5(|0R}M0U}azs1F|%L7$l?s#Ec9aKoUFn|NlROce^9Q@tcPk!uov~a_6No zeEI&Fp?PgB!_vbG7?P$%GF*Cio}qtBCqu>3LWUO~o-^#ew4Gtro+%7>U)*NcaB2;9 zgGWV2Ltr!n27L%Hk^s1vIC&AunYlR_S(td4p(4ycS$1YdCLV6E05cm4BO51>!^J89 zRKg9E + + + + + + + + Test Suite + + + + + + + +

Test Suite

+
+ + + + + + + + + diff --git a/test/test.js b/test/test.js new file mode 100755 index 0000000..4094434 --- /dev/null +++ b/test/test.js @@ -0,0 +1,16 @@ +/* global mocha */ +'use strict'; + + +mocha.setup('bdd'); + + +// Add each test class here as they are implemented +require('./spec/ExampleTest'); + + +if (window.mochaPhantomJS) { + window.mochaPhantomJS.run(); +} else { + mocha.run(); +}