Web application technologies and techniques are moving at an incredible pace. This project seeks to recommend best-of-breed technologies at each level of the application stack, building a reusable prototype web application development repository. The prototype web application shall run in node.js in a server/CLI mode, and be compilable for browser deployment. Testing will be a central part of the project to ameliorate the interpreted nature of Javascript.
- github repository of a sample web app demonstrating current best practices and structure
- library functionality to run in node.js and/or browser
- Javascript style guide, including recommendations for application structure
- build process, possibly based on gulp, npm, and bowser
- embedded web server and livereload support
- sample test suite for local runs and travis-ci, possible packages are testling and mocha
- automated API documentation generation (optional, tools may not yet be robust)
- Sample project to include:
- library to extract MRML XML from a [MRB file](http://www.slicer.org/slicerWiki/index.php/Documentation/4.1/SlicerApplication/MainApplicationGUI#Medical_Reality_Bundle_.28.mrb.29_Note for details)
- display contents, print XML from node.js, convert to HTML in browser
node.js is a Javascript execution engine built on Chrome's Javascript runtime. node is a foundational portion of webapp development, providing many packages (bower, gulp, browserify, etc.) used to construct web applications.
npm is the node package manager and is responsible for installing versioned node packages, both locally or globally.
bower is a package manager for the web. Vended packages can be placed in a file, bower.json
, to lock versions and managing dependancies.
gulp is a streaming build system built upon node. gulp permits writing tasks in a declaritive sense much like Make, and is much more flexible than grunt.
(Yeoman)[http://yeoman.io/] is a build generator ecosystem. Generator templates provide a modular architecture for building web apps. Yeoman is interesting for getting started, however, the reliance on opinionated choices means learning is hampered. After mastering the basics of webapp development, Yeoman should be helpful for productivity improvements. Because of the bundling of grunt, Yeoman is less than ideal for our purposes.
Bootstrap will be used as a responsive web page scaffold. It is well-documented and many templates exist.
browserify is a compiler that enables Javascript code written for node to run in the browser. Thus libraries written with node flavored require statements can be used inside webapps. The handbook gives a great overview browserify functionality in an easy-to-read, tutorial style handbook.
BrowserSync is a simple server that synchronizes browsers when files are written to a watched directory. Getting started with gulp and BrowserSync and is made easy using the gulp-starter example repo.
gulp
- gulp tasks are stored in this directory, one per file. Each file is named after the task that it performs.gulpfile.js
uses require-dir to recursively load tasks.src
- source code of the application. Broken into different folders, includingmain
andtest
.main
- application codehtml
- contains (drum roll please) HTML codeimages
- images used by the applicationjavascript
- application source codecss
- stylesheets CSS, SASS, etc.
test
- test code
build
- build output
Build files go in the build/html
directory. HTML is stored in the root.
javascript
- output of browserify processcss
- output of stylesheet processingimages
- output if image processing (gulp-imagemin
)
gulp builds the web app by pulling source code from the src directory, possibly processing and storing in the build
directory. HTML documents are stored in the root directory, images are stored in an images directory at the top level, javascript are compiled using browserify and stored in the javascript directory, and finally styles are compiled and stored in the css directory. All references should be relative so the application becomes portable.
-
default
The default task builds the entire web app and starts up a BrowserSync server. -
build
The build task farms out to thebrowserSync
,browserify
,images
, andcss
tasks to build the entire app. This builds the browser code. Seebuild-lib
to build the node library. -
browserSync
The browserSync task starts BowserSync
Assets include Javascript libraries, HTML frameworks, etc. All assets should be controlled by package.json
and mainly placed in the devDependencies
section. Initially, only npm
will be used for downloading packages, but this may expand to bower, if necessary.
tape is a simple testing library for npm and the browser. It does not rely on magic imports like mocha.