Skip to content

Commit

Permalink
v6.34.2. Improvement.
Browse files Browse the repository at this point in the history
- v6.34.2 May 13, 2013
	- We now support `docpad run` on empty directories when offline
		- Before it would crash because it could not load the exchange data,
now it will continue anyway
	- Removed `cli-color` dependency
	- Progress bar will now be destroyed when a notice or higher
importance message is logged
  • Loading branch information
balupton committed May 13, 2013
1 parent 3dcd1c6 commit 13922bf
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 26 deletions.
6 changes: 6 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## History

- v6.34.2 May 13, 2013
- We now support `docpad run` on empty directories when offline
- Before it would crash because it could not load the exchange data, now it will continue anyway
- Removed `cli-color` dependency
- Progress bar will now be destroyed when a notice or higher importance message is logged

- v6.34.1 May 9, 2013
- Fixed `ReferenceError: docpad is not defined`

Expand Down
1 change: 1 addition & 0 deletions locale/en.cson
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
errorFollows: "The error follows:"
reportError: "An error occured reporting the error"
trackError: "An error occured sending statistics"
exchangeError: "An error occured fetching the exchange data, this is okay, but not all skeletons will be available to you"
unknownModelInCollection: "Unknown model structure inside the collection"
upgradeNotification: "There's a new version of DocPad available"
upgradeDetails: """
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docpad",
"version": "6.34.1",
"version": "6.34.2",
"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",
"installUrl": "http://docpad.org/install",
Expand Down Expand Up @@ -68,7 +68,6 @@
"bal-util": "~2.0.5",
"typechecker": "~2.0.1",
"ambi": "~2.0.0",
"cli-color": "~0.2.2",
"extendr": "~2.0.1",
"eachr": "~2.0.2",
"safefs": "~3.0.1",
Expand Down
81 changes: 62 additions & 19 deletions src/lib/docpad.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -383,24 +383,31 @@ class DocPad extends EventEmitterEnhanced
@skeletonsCollection = new Collection()
@skeletonsCollection.comparator = queryEngine.generateComparator(position:1, name:1)
@getExchange (err,exchange) ->
# Check
return next(err) if err
# Add options

# Prepare
index = 0
for own skeletonKey,skeleton of exchange.skeletons
skeleton.id ?= skeletonKey
skeleton.name ?= skeletonKey
skeleton.position ?= index
docpad.skeletonsCollection.add(new Model(skeleton))
++index

# If we have the exchange data, then add the skeletons from it
if exchange
for own skeletonKey,skeleton of exchange.skeletons
skeleton.id ?= skeletonKey
skeleton.name ?= skeletonKey
skeleton.position ?= index
docpad.skeletonsCollection.add(new Model(skeleton))
++index

# Add No Skeleton Option
docpad.skeletonsCollection.add(new Model(
id: 'none'
name: locale.skeletonNoneName
description: locale.skeletonNoneDescription
position: Infinity
position: index
))

# Return Collection
return next(null,docpad.skeletonsCollection)
return next(null, docpad.skeletonsCollection)
@


Expand Down Expand Up @@ -2353,13 +2360,22 @@ class DocPad extends EventEmitterEnhanced
# Requires internet access
# next(err,exchange)
getExchange: (next) ->
# Prepare
docpad = @

# Check if it is stored locally
return next(null,@exchange) unless typeChecker.isEmptyObject(@exchange)

# Otherwise fetch it from the exchangeUrl
exchangeUrl = @config.exchangeUrl+'?version='+@version
@loadConfigUrl exchangeUrl, (err,parsedData) ->
return next(err) if err
# Check
if err
locale = docpad.getLocale()
docpad.log('notice', locale.exchangeError+'\n'+locale.errorFollows, err)
return next()

# Success
@exchange = parsedData
return next(null,parsedData)

Expand Down Expand Up @@ -2723,7 +2739,7 @@ class DocPad extends EventEmitterEnhanced
if opts.reset is true
# Check plugin count
unless docpad.hasPlugins()
docpad.log('warn', locale.renderNoPlugins)
docpad.log('notice', locale.renderNoPlugins)

# Check if the source directory exists
tasks.addTask (complete) ->
Expand Down Expand Up @@ -2869,6 +2885,37 @@ class DocPad extends EventEmitterEnhanced
generateStarted: null
generateEnded: null
generating: false
progress: null

# Create Progress Bar
createProgress: ->
# Prepare
docpad = @
config = docpad.getConfig()

# Only show progress if
# - prompts are supported (so no servers)
# - and we are log level 6 (the default level)
progress = null
if config.prompts and @getLogLevel() is 6
progress = require('progressbar').create()
@getLoggers().console.unpipe(process.stdout)
@getLogger().once 'log', progress.logListener ?= (data) ->
if data.levelNumber <= 5 # notice or higher
docpad.destroyProgress(progress)

# Return
return progress

# Destroy Progress Bar
destroyProgress: (progress) ->
# Fetch
if progress
progress.finish()
@getLoggers().console.unpipe(process.stdout).pipe(process.stdout)

# Return
return progress

# Generate
# next(err)
Expand All @@ -2883,19 +2930,14 @@ class DocPad extends EventEmitterEnhanced
# Check
return next() if opts.collection?.length is 0

# Only show progress if
# - prompts are supported (so no servers)
# - and we are log level 6 (the default level)
if config.prompts and @getLogLevel() is 6
opts.progress ?= require('progressbar').create()
docpad.getLoggers().console.unpipe(process.stdout)
# Create the progress bar
opts.progress ?= @createProgress()

# Ensure progress is always removed correctly
finish = (err) ->
if opts.progress
opts.progress.finish()
docpad.destroyProgress(opts.progress)
opts.progress = null
docpad.getLoggers().console.pipe(process.stdout)
return next(err)

# Re-load and re-render only what is necessary
Expand Down Expand Up @@ -3430,6 +3472,7 @@ class DocPad extends EventEmitterEnhanced
docpad.getSkeletons (err,skeletonsCollection) ->
# Check
return next(err) if err

# Provide selection to the interface
selectSkeletonCallback skeletonsCollection, (err,skeletonModel) ->
return next(err) if err
Expand Down
9 changes: 4 additions & 5 deletions src/lib/interfaces/console.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Requires
cliColor = require('cli-color')
pathUtil = require('path')
balUtil = require('bal-util')
safefs = require('safefs')
Expand Down Expand Up @@ -274,19 +273,19 @@ class ConsoleInterface
skeletonNames = []

# Show
console.log cliColor.bold locale.skeletonSelectionIntroduction+'\n'
docpad.log 'info', locale.skeletonSelectionIntroduction+'\n'
skeletonsCollection.forEach (skeletonModel) ->
skeletonName = skeletonModel.get('name')
skeletonDescription = skeletonModel.get('description').replace(/\n/g,'\n\t')
skeletonNames.push(skeletonName)
console.log """
\t#{cliColor.bold(skeletonName)}
\t#{skeletonDescription}
#{skeletonModel.get('position')+1}. #{skeletonName}
#{skeletonDescription}
"""

# Select
console.log cliColor.bold locale.skeletonSelectionPrompt
docpad.log 'info', locale.skeletonSelectionPrompt
commander.choose skeletonNames, (i) ->
process.stdin.destroy()
return next(null, skeletonsCollection.at(i))
Expand Down

0 comments on commit 13922bf

Please sign in to comment.