Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

v6.11.1. Improvement.

- v6.11.1 November 16, 2012
	- Changes made to help get the docpad server up and running as soon as
possible:
		- `server` action is now run before `generate` action
		- if a request is made while a generation is occuring, the request
will be put on hold until the generation completes
	- We now pass the option `reset` to the `generateBefore` event
		- Lets you know if the generation is a complete generation (`reset`
is `true`) or a differential generation (`reset` is `false`)
  • Loading branch information...
commit 5dafdfef855561a279764b0af5aa476a44283625 1 parent a4c3407
@balupton balupton authored
View
7 History.md
@@ -1,5 +1,12 @@
## History
+- v6.11.1 November 16, 2012
+ - Changes made to help get the docpad server up and running as soon as possible:
+ - `server` action is now run before `generate` action
+ - if a request is made while a generation is occuring, the request will be put on hold until the generation completes
+ - We now pass the option `reset` to the `generateBefore` event
+ - Lets you know if the generation is a complete generation (`reset` is `true`) or a differential generation (`reset` is `false`)
+
- v6.11.0 October 29, 2012
- Updated [QueryEngine](https://github.com/bevry/query-engine/) dependency from 1.3.x to 1.4.x
- Should see speed improvements
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "docpad",
- "version": "6.11.0",
+ "version": "6.11.1",
"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": "https://github.com/bevry/docpad",
"keywords": [
View
2  src/bin/docpad-server.coffee
@@ -3,7 +3,7 @@ DocPad = require(__dirname+'/../lib/docpad')
# DocPad Configuration
docpadConfig = {}
-serverAction = process.env.DOCPAD_SERVER_ACTION or 'generate server'
+serverAction = process.env.DOCPAD_SERVER_ACTION or 'server generate'
# --action <value>
(->
View
45 src/lib/docpad.coffee
@@ -2186,6 +2186,7 @@ class DocPad extends EventEmitterEnhanced
# Generate
# Generate Prepare
+ # opts = {reset}
# next(err)
generatePrepare: (opts,next) =>
# Prepare
@@ -2193,12 +2194,15 @@ class DocPad extends EventEmitterEnhanced
docpad = @
locale = @getLocale()
+ # Update generating flag
+ docpad.generating = true
+
# Log generating
docpad.log 'info', locale.renderGenerating
docpad.notify (new Date()).toLocaleTimeString(), title: locale.renderGeneratingNotification
# Fire plugins
- docpad.emitSync 'generateBefore', server:docpad.getServer(), (err) ->
+ docpad.emitSync 'generateBefore', {reset:opts.reset, server:docpad.getServer()}, (err) ->
# Forward
return next(err)
@@ -2206,6 +2210,7 @@ class DocPad extends EventEmitterEnhanced
@
# Generate Check
+ # opts = {}
# next(err)
generateCheck: (opts,next) =>
# Prepare
@@ -2230,6 +2235,7 @@ class DocPad extends EventEmitterEnhanced
@
# Generate Clean
+ # opts = {}
# next(err)
generateClean: (opts,next) =>
# Prepare
@@ -2243,6 +2249,7 @@ class DocPad extends EventEmitterEnhanced
@
# Parse the files
+ # opts = {}
# next(err)
generateParse: (opts,next) =>
# Prepare
@@ -2299,6 +2306,7 @@ class DocPad extends EventEmitterEnhanced
@
# Generate Render
+ # opts = {templateData,collection,setProgressIndicator}
# next(err)
generateRender: (opts,next) =>
# Prepare
@@ -2321,6 +2329,7 @@ class DocPad extends EventEmitterEnhanced
@
# Generate Postpare
+ # opts = {collection}
# next(err)
generatePostpare: (opts,next) =>
# Prepare
@@ -2330,6 +2339,9 @@ class DocPad extends EventEmitterEnhanced
database = @getDatabase()
collection = opts.collection or database
+ # Update generating flag
+ docpad.generating = false
+
# Fire plugins
docpad.emitSync 'generateAfter', server:docpad.getServer(), (err) ->
return next(err) if err
@@ -2353,6 +2365,9 @@ class DocPad extends EventEmitterEnhanced
# Date object of the last generate
lastGenerate: null
+ # Flag for whether or not we are generating
+ generating: false
+
# Generate
# next(err)
generate: (opts,next) =>
@@ -2378,12 +2393,12 @@ class DocPad extends EventEmitterEnhanced
finish = (err) ->
clearInterval(progressInterval)
progressInterval = null
- next(err)
+ return next(err)
# Re-load and re-render only what is necessary
if opts.reset? and opts.reset is false
# Prepare
- docpad.generatePrepare (err) ->
+ docpad.generatePrepare opts, (err) ->
return finish(err) if err
database = docpad.getDatabase()
@@ -2427,6 +2442,8 @@ class DocPad extends EventEmitterEnhanced
# Re-load and re-render everything
else
+ # Prepare
+ opts.reset = true
docpad.lastGenerate = new Date()
balUtil.flow(
object: docpad
@@ -2661,7 +2678,7 @@ class DocPad extends EventEmitterEnhanced
runDocpad = ->
balUtil.flow(
object: docpad
- action: 'generate server watch'
+ action: 'server generate watch'
args: [opts]
next: (err) ->
return next(err)
@@ -2833,15 +2850,24 @@ class DocPad extends EventEmitterEnhanced
res.set('X-Powered-By',tools)
next()
+ # Chain
+ return @
+
# Server Middleware: Router
serverMiddlewareRouter: (req,res,next) =>
# Prepare
docpad = @
database = docpad.getDatabase()
- # Check
+ # If we have no database, then continue to 404 router
return next() unless database
+ # If we are generating then wait until generation is complete before continuing
+ if docpad.generating
+ docpad.once 'generateAfter', ->
+ return docpad.serverMiddlewareRouter(req,res,next)
+ return @
+
# Prepare
pageUrl = req.url.replace(/\?.*/,'')
document = database.findOne(urls: $has: pageUrl)
@@ -2856,6 +2882,9 @@ class DocPad extends EventEmitterEnhanced
# Serve the document to the user
docpad.serveDocument({document,req,res,next})
+ # Chain
+ return @
+
# Server Middleware: 404
serverMiddleware404: (req,res,next) =>
# Prepare
@@ -2869,6 +2898,9 @@ class DocPad extends EventEmitterEnhanced
document = database.findOne({relativeOutPath: '404.html'})
docpad.serveDocument({document,req,res,next,statusCode:404})
+ # Chain
+ return @
+
# Server Middleware: 500
serverMiddleware500: (err,req,res,next) =>
# Prepare
@@ -2882,6 +2914,9 @@ class DocPad extends EventEmitterEnhanced
document = database.findOne({relativeOutPath: '500.html'})
docpad.serveDocument({document,err,req,res,next,statusCode:500})
+ # Chain
+ return @
+
# Server
server: (opts,next) =>
# Requires
Please sign in to comment.
Something went wrong with that request. Please try again.