Skip to content

Commit

Permalink
v4.1.0. Feedr plugin now exposes feedr.feeds instead of feeds. Feedr,…
Browse files Browse the repository at this point in the history
… Partials and Cachr plugins gain README.md and History.md files. Exchange data is now moved to the docpad-extras repo. Fixed broken balupton.docpad skeleton repo url.
  • Loading branch information
balupton committed Apr 6, 2012
1 parent 4d7f408 commit 5d8877d
Show file tree
Hide file tree
Showing 12 changed files with 292 additions and 107 deletions.
7 changes: 6 additions & 1 deletion History.md
@@ -1,5 +1,10 @@
## History

- v4.1.0 April 6, 2012
- [Feedr Plugin](https://github.com/bevry/docpad/tree/master/lib/exchange/plugins/feedr) now exposes `@feedr.feeds` to the `templateData` instead of `@feeds`
- Exchange data now moved to the [docpad-extras](https://github.com/bevry/docpad-extras) repository
- Fixed broken `balupton.docpad` skeleton repo url

- v4.0.3 April 6, 2012
- Added support for partials, with the new [Partials Plugin](https://github.com/bevry/docpad/tree/master/lib/exchange/plugins/partials)
- Added support for caching remote assets, with the new [Cachr Plugin](https://github.com/bevry/docpad/tree/master/lib/exchange/plugins/cachr)
Expand All @@ -24,7 +29,7 @@
- When an error occurs we will send an error report back to DocPad using [AirBrake](http://airbrake.io/)
- To turn this off, set `reportErrors` in your docpad configuration to `false`
- Files, Documents, Layouts and Partials are now proper "models" and are now found in the `lib/models` directory
- Moved out some unstable or not as popular plugins to the [DocPad-Extra](https://github.com/bevry/docpad-extra) repository, plugins moved are:
- Moved out some unstable or not as popular plugins to the [docpad-extras](https://github.com/bevry/docpad-extras) repository, plugins moved are:
- Admin
- Authenticate
- AutoUpdate
Expand Down
216 changes: 118 additions & 98 deletions lib/docpad.coffee
Expand Up @@ -82,6 +82,9 @@ class DocPad extends EventSystem
# Loaded plugins indexed by name
loadedPlugins: {}

# A listing of all the available extensions for DocPad
exchange: {}


# -----------------------------
# Paths
Expand All @@ -103,51 +106,8 @@ class DocPad extends EventSystem


# -----------------------------
# Exchange

###
Exchange Configuration
Still to be decided how it should function for now.
Eventually it will be loaded from:
- a remote url upon initialization
- then stored in ~/.docpad/exchange.json
Used to:
- store the information of available extensions for docpad
###
exchange:
# Plugins
plugins: {}
# Configuration

# Skeletons
skeletons:
'kitchensink.docpad':
branch: 'docpad-3.x'
repo: 'git://github.com/bevry/kitchensink.docpad.git'
description: 'The entire kitchensink to showcase everything that docpad is capable of.'
'canvas.docpad':
branch: 'docpad-3.x'
repo: 'git://github.com/bevry/canvas.docpad.git'
description: 'The bare minimum to get started, with a few bundled client-side libraries to make it easier.'
'balupton.docpad':
branch: '2012'
repo: 'git://github.com:balupton/balupton.docpad.git'
description: 'The personal website/blog of Benjamin Lupton, the creator of DocPad.'
'deckpad':
branch: 'master'
repo: 'git://github.com/calvinmetcalf/deckpad.git'
description: 'Build rich HTML5 presentations with DocPad.'
'nodechat.docpad':
branch: 'master'
repo: 'git://github.com/balupton/nodechat.docpad.git'
description: '''
A local chat application built with DocPad, Socket.io and Backbone.js.
NOTE: To run nodechat you must use `coffee server.coffee` instead of `docpad run`
'''

# Themes
themes: {}


###
Instance Configuration
Loaded from:
Expand All @@ -171,6 +131,9 @@ class DocPad extends EventSystem
# Plugin directories to load
loadPlugins: []

# Where to fetch the exchange information from
exchangeUrl: 'https://raw.github.com/bevry/docpad-extras/master/exchange.json'


# -----------------------------
# Website Paths
Expand Down Expand Up @@ -286,6 +249,7 @@ class DocPad extends EventSystem
@slowPlugins = {}
@foundPlugins = {}
@loadedPlugins = {}
@exchange = {}

# Clean the models
@cleanModels()
Expand Down Expand Up @@ -322,6 +286,55 @@ class DocPad extends EventSystem
getDebugging: ->
return @getLogLevel() is 7

# Get Exchange
# Get the exchange data
# Requires internet access
# next(err,exchange)
getExchange: (next) ->
# Check if it is stored locally
return next(null,@exchange) unless _.isEmpty(@exchange)

# Otherwise fetch it from the exchangeUrl
@loadJsonUrl @config.exchangeUrl, (err,parsedData) ->
return next(err) if err
@exchange = parsedData
return next(null,parsedData)

# Chain
@

# Get Skeletons
# Get all the available skeletons for us and their details
# next(err,skeletons)
getSkeletons: (next) ->
@getExchange (err,exchange) ->
return next(err) if err
skeletons = exchange.skeletons
return next(null,skeletons)
@

# Get Skeleton
# Returns a skeleton's details
# next(err,skeletonDetails)
getSkeleton: (skeletonId,next) ->
@getSkeletons (err,skeletons) ->
return next(err) if err
skeletonDetails = skeletons[skeletonId]
return next(null,skeletonDetails)
@

# Load a json url
# next(err,parsedData)
loadJsonUrl: (jsonUrl,next) ->
# Read the url using balUtil
balUtil.readPath jsonUrl, (err,data) ->
return next(err) if err
parsedData = JSON.parse(data.toString())
return next(null,parsedData)

# Chain
@

# Load a json path
# next(err,parsedData)
loadJsonPath: (jsonPath,next) ->
Expand Down Expand Up @@ -493,59 +506,63 @@ class DocPad extends EventSystem
docpad = @
logger = @logger
debugging = @getDebugging()
skeletonDetails = @exchange.skeletons[skeletonId] or {}
packagePath = path.join(destinationPath, 'package.json')

# Initialize a Git Repository
# Requires internet access
# next(err)
initGitRepo = (next) ->
commands = [
command: docpad.config.gitPath
args: ['init']
,
command: docpad.config.gitPath
args: ['remote','add','skeleton',skeletonDetails.repo]
,
command: docpad.config.gitPath
args: ['fetch','skeleton']
,
command: docpad.config.gitPath
args: ['pull','skeleton',skeletonDetails.branch]
,
command:docpad.config.gitPath
args: ['submodule','init']
,
command: docpad.config.gitPath
args: ['submodule','update','--recursive']
]
logger.log 'debug', "Initializing git pull for the skeleton #{skeletonId}"
balUtil.spawn commands, {cwd:destinationPath,output:debugging}, (err,results) ->
# Check
if err
logger.log 'debug', results
return next(err)

# Complete
logger.log 'debug', "Initialized git pull for the skeleton #{skeletonId}"
return next()

# Log
logger.log 'info', "Initializing the skeleton #{skeletonId} to #{destinationPath}"

# Check if the skeleton path already exists
balUtil.ensurePath destinationPath, (err) ->
# Grab the skeletonDetails
@getSkeleton skeletonId, (err,skeletonDetails) ->
# Check
return tasks.exit(err) if err
# Initalize the git repository
initGitRepo (err) ->
return next(err) if err
# And initialize and node modules we may have
docpad.initNodeModules destinationPath, (err) ->
return next(err) if err
logger.log 'info', "Initialized the skeleton #{skeletonId} to #{destinationPath}"
return next(err) if err

# Initialize a Git Repository
# Requires internet access
# next(err)
initGitRepo = (next) ->
commands = [
command: docpad.config.gitPath
args: ['init']
,
command: docpad.config.gitPath
args: ['remote','add','skeleton',skeletonDetails.repo]
,
command: docpad.config.gitPath
args: ['fetch','skeleton']
,
command: docpad.config.gitPath
args: ['pull','skeleton',skeletonDetails.branch]
,
command:docpad.config.gitPath
args: ['submodule','init']
,
command: docpad.config.gitPath
args: ['submodule','update','--recursive']
]
logger.log 'debug', "Initializing git pull for the skeleton #{skeletonId}"
balUtil.spawn commands, {cwd:destinationPath,output:debugging}, (err,results) ->
# Check
if err
logger.log 'debug', results
return next(err)

# Complete
logger.log 'debug', "Initialized git pull for the skeleton #{skeletonId}"
return next()

# Log
logger.log 'info', "Initializing the skeleton #{skeletonId} to #{destinationPath}"

# Check if the skeleton path already exists
balUtil.ensurePath destinationPath, (err) ->
# Check
return tasks.exit(err) if err
# Initalize the git repository
initGitRepo (err) ->
return next(err) if err
# And initialize and node modules we may have
docpad.initNodeModules destinationPath, (err) ->
return next(err) if err
logger.log 'info', "Initialized the skeleton #{skeletonId} to #{destinationPath}"
return next()

# Chain
@

Expand Down Expand Up @@ -1620,7 +1637,6 @@ class DocPad extends EventSystem
{opts,next} = @getActionArgs(opts,next)
docpad = @
logger = @logger
skeletons = @exchange.skeletons
skeletonId = @config.skeleton
destinationPath = @config.rootPath
selectSkeletonCallback = opts.selectSkeletonCallback or null
Expand Down Expand Up @@ -1659,11 +1675,15 @@ class DocPad extends EventSystem
if skeletonId
useSkeleton()
else
# Provide selection to the interface
selectSkeletonCallback skeletons, (err,_skeletonId) ->
return fatal(err) if err
skeletonId = _skeletonId
useSkeleton()
# Get the available skeletons
docpad.getSkeletons (err,skeletons) ->
# Check
return complete(err) if err
# Provide selection to the interface
selectSkeletonCallback skeletons, (err,_skeletonId) ->
return fatal(err) if err
skeletonId = _skeletonId
useSkeleton()

# Chain
@
Expand Down
4 changes: 4 additions & 0 deletions lib/exchange/plugins/cachr/History.md
@@ -0,0 +1,4 @@
## History

- v0.1.0 March 23, 2012
- Initial working version for [Benjamin Lupton's Website](https://github.com/balupton/balupton.docpad)
44 changes: 44 additions & 0 deletions lib/exchange/plugins/cachr/README.md
@@ -0,0 +1,44 @@
# Cachr Plugin for DocPad

This plugin caches remote resources locally.


## Usage

To use, simply wrap any url you want to cache locally within the exposed `@cachr(url)` function inside your templates.

- [CoffeeKup](http://coffeekup.org/) example:

``` coffeescript
img src:'http://somewebsite.com/someimage.gif'
```

would become:

``` coffeescript
img src:@cachr('http://somewebsite.com/someimage.gif')
```

- [Eco](https://github.com/sstephenson/eco) example:

``` coffeescript
<img src="http://somewebsite.com/someimage.gif"/>
```

would become:

``` coffeescript
<img src="<%=@cachr('http://somewebsite.com/someimage.gif')%>"/>
```



## History

You can discover the history inside the `History.md` file


## License

Licensed under the [MIT License](http://creativecommons.org/licenses/MIT/)
<br/>Copyright &copy; 2012 [Bevry Pty Ltd](http://bevry.me)
7 changes: 7 additions & 0 deletions lib/exchange/plugins/feedr/History.md
@@ -0,0 +1,7 @@
## History

- v0.2.0 April 6, 2012
- Now exposes `@feedr.feeds` to the `templateData` instead of `@feeds`

- v0.1.0 March 23, 2012
- Initial working version for [Benjamin Lupton's Website](https://github.com/balupton/balupton.docpad)

0 comments on commit 5d8877d

Please sign in to comment.