Browse files

Merge branch 'master' into dev-render

  • Loading branch information...
balupton committed Dec 3, 2012
2 parents 7b6bca7 + 173f70d commit 2ed366427f97e78e4568ce850cda4260a94d6623
Showing with 96 additions and 25 deletions.
  1. +39 −0
  2. +3 −0
  3. +7 −2
  4. +1 −1 package.json
  5. +46 −22 src/lib/
@@ -0,0 +1,39 @@
# Contributing
## Support
1. Use the GitHub Issues only for development tasks and bug reports
1. For anything else (questions, support, etc) use our [Official Support Channels](
1. With bug reports, be sure to specify:
1. Your docpad version `docpad --version`
1. Your node version `node --version`
1. Your npm version `npm --version`
1. Your operating system's name, architecture, and version
1. What you did
1. What happened
1. What you expected
## Development
1. Fork the DocPad Repository
1. Clone your fork and cd into it
1. Run `npm install` to install dependencies
1. Run `npm link` to link our local copy as the global instance (so it is available via `docpad`)
1. Run `make dev` to compile our coffeescript and recompile on changes
## Pull Requests
1. Each pull request should be made on its own branch. Branches should be stemmed from master. E.g. `git checout master; git checkout -b your-new-branch`
1. Test your changes before you submit the pull request (see testing section), if possible, add tests for your change - if you don't know how to fix the tests, submit your pull request and say so, happy to help (but it will slow down integration)
1. When submitting the pull request, specify the `dev` branch as the integration branch (the integration branch is which branch your pull request will be merged into on the official repo)
1. If you'd like, feel free to add yourself to the contributors section of the `package.json` file if it exists
1. By submitting a pull request, you agree that your submission can be used freely and without restraint by those whom your submitting the pull request to
## Testing
1. Run `npm test` to run the tests
1. There are several types of tests run, the most common is the rendering test, which compares files inside `test/out` to `test/out-expected`
@@ -1,5 +1,8 @@
## History
- v6.15.0 December 3, 2012
- [Nodejitsu]( Support
- v6.14.0 November 29, 2012
- Added `DocPad::getFileByUrl(url)` and updated the middleware router to use it
- Big performance gain on request response time
@@ -1,9 +1,14 @@
[![DocPad Logo](]( "Get started with DocPad today via the Bevry Learning Centre")
# DocPad. Streamlined web development. [![Build Status](](
Hi! I'm DocPad, I streamline the web development process and help close the gap between experts and beginners. I've been used in production by big and small companies for over a year and a half now to create [plenty of amazing and powerful web sites and applications]( quicker than ever before. What makes me different is instead of being a box to cram yourself into and hold you back, I'm a freeway to what you want to accomplish, just getting out of your way and allowing you to create stuff quicker than ever before without limits. Leave the redudant stuff up to me, so you can focus on the awesome stuff.
Discover my features below, or skip ahead to the installation instructions to get started with a [fully functional pre-made website]( in a few minutes from reading this.
**[Watch the Screencast!](**
## Features
### Out of the box
@@ -55,14 +60,14 @@ All sorts of people love DocPad, from first time web developers to even industry
## [Quick Start](
[Click here for our latest Quick Start Guide](
[Click here to skip ahead to our latest Quick Start Guide](
## What next?
Here are some quick links to help you get started:
- [Getting Started](
- [Getting Started](
- [Frequently Asked Questions](
- [Showcase and Examples](
- [Guides and Tutorials](
@@ -1,6 +1,6 @@
"name": "docpad",
"version": "6.14.0",
"version": "6.15.0",
"description": "DocPad is a language agnostic document management system. This means you write your website as documents, in whatever language you wish, and DocPad will handle the compiling, templates and layouts for you. For static documents it will generate static files, for dynamic documents it'll re-render them on each request. You can utilise DocPad by itself, or use it as a module your own custom system. It's pretty cool, and well worth checking out. We love it.",
"homepage": "",
"installUrl": "",
@@ -549,11 +549,14 @@ class DocPad extends EventEmitterEnhanced
# Get Environment
getEnvironment: ->
return @getConfig().env
env = @getConfig().env or 'development'
return env
# Get Environments
getEnvironments: ->
return @getEnvironment().split(/[, ]+/)
env = @getEnvironment()
envs = env.split(/[, ]+/)
return envs
# -----------------------------
@@ -835,6 +838,10 @@ class DocPad extends EventEmitterEnhanced
getConfig: ->
return @config or {}
# Get the Port
getPort: ->
return @getConfig().port or 9778
# =================================
# Initialization Functions
@@ -1015,9 +1022,15 @@ class DocPad extends EventEmitterEnhanced
return next(err) if err
# Get environments
@initialConfig.port ?= process.env.PORT ? process.env.VCAP_APP_PORT ? process.env.VMC_APP_PORT ? 9778
@initialConfig.env or= process.env.NODE_ENV or 'development'
@config.env = @instanceConfig.env or @websiteConfig.env or @websitePackageConfig.env or @initialConfig.env
# Here as by now we would have loaded our .env file, whereas earlier we may not have
@initialConfig.port ?= process.env.PORT ? process.env.VCAP_APP_PORT ? process.env.VMC_APP_PORT
@initialConfig.env ?= process.env.NODE_ENV
# Apply the environment
# websitePackageConfig.env is left out of the detection here as it is usually an object
# that is already merged with our process.env by the environment runner
# rather than a string which is the docpad convention
@config.env = @instanceConfig.env or @websiteConfig.env or @initialConfig.env
envs = @getEnvironments()
# Merge configurations
@@ -3149,6 +3162,7 @@ class DocPad extends EventEmitterEnhanced
docpad = @
config = @config
locale = @getLocale()
port = @getPort()
serverExpress = null
serverHttp = null
@@ -3159,35 +3173,45 @@ class DocPad extends EventEmitterEnhanced
opts.middleware404 ?= config.middleware404
opts.middleware500 ?= config.middleware500
# Handlers
complete = (err) ->
# Finish
finish = (err) ->
return next(err) if err
# Plugins
docpad.emitSync 'serverAfter', {server:serverExpress,serverExpress,serverHttp,express}, (err) ->
return next(err) if err
# Complete
# Done
docpad.log 'debug', 'Server setup'
return next()
startServer = ->
# Start the server
# Start Server
startServer = (next) ->
# Catch
serverHttp.once 'error', (err) ->
# Friendlify the error message if it is what we suspect it is
if err.message.indexOf('EADDRINUSE') isnt -1
err = new Error(util.format(locale.serverInUse, port))
# Done
return next(err)
# Listen
serverHttp.listen port, ->
# Log
address = serverHttp.address()
unless address?
throw new Error(util.format(locale.serverInUse, config.port))
serverHostname = if address.address is '' then 'localhost' else address.address
serverPort = address.port
serverLocation = "http://#{serverHostname}:#{serverPort}/"
serverDir = config.outPath
docpad.log 'info', util.format(locale.serverStarted, serverLocation, serverDir)
catch err
return complete(err)
return complete()
# Plugins
# Done
return next()
# Start
docpad.emitSync 'serverBefore', {}, (err) ->
return complete(err) if err
return finish(err) if err
# Server
{serverExpress,serverHttp} = docpad.getServer(true)
@@ -3204,7 +3228,7 @@ class DocPad extends EventEmitterEnhanced
# Extend the server
unless config.extendServer
# Start the Server
# Require
express ?= require('express')
@@ -3246,7 +3270,7 @@ class DocPad extends EventEmitterEnhanced
serverExpress.error(docpad.serverMiddleware500) if opts.middleware500 isnt false
# Start the Server
# Chain

0 comments on commit 2ed3664

Please sign in to comment.