Skip to content

Commit

Permalink
3.2.3. Attempting to fix 0.4.7 compatibility issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Feb 15, 2012
1 parent 2c4d3ab commit 712f32c
Show file tree
Hide file tree
Showing 22 changed files with 111 additions and 112 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ test:
install:
coffee ./bin/docpad install

.PHONY: test install
clean:
rm -Rf node_modules/ npm-debug.log lib/exchange/plugins/*/node_modules lib/exchange/plugins/*/npm-debug.log

.PHONY: test install clean
10 changes: 6 additions & 4 deletions bin/docpad
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ ConsoleInterface = require("#{__dirname}/../lib/consoleinterface.coffee")
# Create Program
program = require("#{__dirname}/../node_modules/commander/index.js")

# Create DocPad
docpadConfig =
skeleton: program.skeleton
port: program.port
# Configure Instance
docpadConfig = {}
docpadConfig.skeleton = program.skeleton if program.skeleton
docpadConfig.port = program.port if program.port

# Create Instance
docpad = DocPad.createInstance docpadConfig, (err) ->
# Check
throw err if err
Expand Down
56 changes: 34 additions & 22 deletions lib/docpad.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# System
fs = require('fs')
path = require('path')
request = require('request')

# Necessary
_ = require('underscore')
Expand Down Expand Up @@ -379,8 +378,8 @@ class DocPad extends EventSystem
enabledPlugins[enabledPlugin] = true
@config.enabledPlugins = enabledPlugins

# Load the plugins
@loadPlugins complete
# Initialize
@initialize complete

# Prepare configuration loading
tasks.total = 2
Expand Down Expand Up @@ -515,7 +514,7 @@ class DocPad extends EventSystem
# Requires internet access
initGitPull = (next) ->
logger.log 'debug', "Initializing git pulls for the skeleton #{skeletonId}"
commands = ["git init", "git pull origin #{skeletonDetails.branch}"]
command = "git pull origin #{skeletonDetails.branch}"
balUtil.exec commands, {cwd:skeletonPath}, (err,results) ->
# Check
if err
Expand Down Expand Up @@ -602,25 +601,34 @@ class DocPad extends EventSystem
# Chain
@

# Initialize
# next(err)
initialize: (next) ->
# Prepare
docpad = @
logger = @logger

# ---------------------------------
# Exchange
# Tasks
tasks = new balUtil.Group (err) ->
return next?(err) if err
logger.log 'debug', "Initialized DocPad"
return next?(err)
tasks.total = 2

# Log
logger.log 'debug', "Initializing DocPad"

# Update the Exchange
updateExchange: (next) ->
try
details.local = JSON.parse fs.readFileSync(local).toString()
request = require 'request' unless request
request remote, (err,response,body) =>
if not err and response.statusCode is 200
details.remote = JSON.parse body
unless @versionCompare(details.local.version, '>=', details.remote.version)
newVersionCallback(details) if newVersionCallback
else
oldVersionCallback(details) if oldVersionCallback
catch err
errorCallback(err) if errorCallback
# Load the plugins
@loadPlugins tasks.completer()

# Load the skeletons
path.exists docpad.skeletonsPath, (exists) ->
return tasks.complete() if exists
@installSkeletons tasks.completer()

# Chain
@


# ---------------------------------
# Utilities
Expand Down Expand Up @@ -884,11 +892,15 @@ class DocPad extends EventSystem
nextFile = (err,skip) ->
if err
logger.log 'warn', "Failed to load the plugin #{loader.pluginName} at #{fileFullPath}. The error follows"
docpad.error err, 'warn'
docpad.error(err, 'warn')
_nextFile(null,skip)

# Prepare
loader = new PluginLoader dirPath: fileFullPath, docpad: docpad, BasePlugin: BasePlugin
loader = new PluginLoader(
dirPath: fileFullPath
docpad: docpad
BasePlugin: BasePlugin
)
pluginName = loader.pluginName
enabled = (
(config.enableUnlistedPlugins and config.enabledPlugins[pluginName]? is false) or
Expand Down
12 changes: 6 additions & 6 deletions lib/exchange/plugins/cleanurls/cleanurls.plugin.coffee
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Export Plugin
module.exports = (BasePlugin) ->
# Requires
path = require 'path'
fs = require 'fs'
util = require 'bal-util'

# Define Plugin
class CleanUrlsPlugin extends BasePlugin
# Plugin Name
name: 'cleanUrls'

# Parsing all files has finished
parseAfter: ({docpad,logger},next) ->
# Requires
path = require('path')
fs = require('fs')
balUtil = require('bal-util')

# Prepare
documents = docpad.documents
logger.log 'debug', 'Creating clean urls'

# Async
tasks = new util.Group (err) ->
tasks = new balUtil.Group (err) ->
logger.log 'debug', 'Created clean urls'
next err

Expand Down
14 changes: 4 additions & 10 deletions lib/exchange/plugins/coffee/coffee.plugin.coffee
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# Export Plugin
module.exports = (BasePlugin) ->
# Requires
ck = null
html2ck = null
coffee = null
js2coffee = null

# Define Plugin
class CoffeePlugin extends BasePlugin
# Plugin name
Expand All @@ -19,13 +13,13 @@ module.exports = (BasePlugin) ->
try
# CoffeeKup to anything
if inExtension in ['coffeekup','ck'] or (inExtension is 'coffee' and !(outExtension in ['js','css']))
ck = require 'coffeekup' unless ck
ck = require('coffeekup')
file.content = ck.render file.content, templateData, (@config.coffeekup or {})
next()

# HTML to CoffeeKup
else if inExtension is 'html' and outExtension in ['coffeekup','ck','coffee']
html2ck = require 'html2coffeekup' unless html2ck
html2ck = require('html2coffeekup')
outputStream = {
content: ''
write: (content) ->
Expand All @@ -38,13 +32,13 @@ module.exports = (BasePlugin) ->

# CoffeeScript to JavaScript
else if inExtension is 'coffee' and outExtension is 'js'
coffee = require 'coffee-script' unless coffee
coffee = require('coffee-script')
file.content = coffee.compile file.content
next()

# JavaScript to CoffeeScript
else if inExtension is 'js' and outExtension is 'coffee'
js2coffee = require 'js2coffee/lib/js2coffee.coffee' unless js2coffee
js2coffee = require('js2coffee/lib/js2coffee.coffee')
file.content = js2coffee.build file.content
next()

Expand Down
5 changes: 1 addition & 4 deletions lib/exchange/plugins/eco/eco.plugin.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Export Plugin
module.exports = (BasePlugin) ->
# Requires
eco = null

# Define Plugin
class EcoPlugin extends BasePlugin
# Plugin name
Expand All @@ -15,7 +12,7 @@ module.exports = (BasePlugin) ->
render: ({inExtension,outExtension,templateData,file}, next) ->
try
if inExtension is 'eco'
eco = require 'eco' unless eco
eco = require('eco')
file.content = eco.render file.content, templateData
next()
else
Expand Down
5 changes: 1 addition & 4 deletions lib/exchange/plugins/haml/haml.plugin.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Export Plugin
module.exports = (BasePlugin) ->
# Requires
haml = null

# Define Plugin
class HamlPlugin extends BasePlugin
# Plugin name
Expand All @@ -15,7 +12,7 @@ module.exports = (BasePlugin) ->
render: ({inExtension,outExtension,templateData,file}, next) ->
try
if inExtension is 'haml'
haml = require 'haml' unless haml
haml = require('haml')
file.content = haml.render file.content, locals: templateData
next()
else
Expand Down
5 changes: 1 addition & 4 deletions lib/exchange/plugins/hogan/hogan.plugin.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Export Plugin
module.exports = (BasePlugin) ->
# Requires
hogan = null

# Define Plugin
class HoganPlugin extends BasePlugin
# Plugin name
Expand All @@ -15,7 +12,7 @@ module.exports = (BasePlugin) ->
render: ({inExtension,outExtension,templateData,file}, next) ->
try
if inExtension is 'hogan'
hogan = require('hogan.js') unless hogan
hogan = require('hogan.js')
file.content = hogan.compile(file.content).render(templateData)
next()
else
Expand Down
8 changes: 2 additions & 6 deletions lib/exchange/plugins/html2jade/html2jade.plugin.coffee
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Export Plugin
module.exports = (BasePlugin) ->
# Requires
path = null
html2jade = null

# Define Plugin
class Html2JadePlugin extends BasePlugin
# Plugin name
Expand All @@ -16,10 +12,10 @@ module.exports = (BasePlugin) ->
render: ({inExtension,outExtension,templateData,file}, next) ->
try
if outExtension is 'jade' and inExtension is 'html'
path = require 'path' unless path
path = require('path')
try
unless html2jade
html2jade = require 'html2jade'
html2jade = require('html2jade')
catch err
unless html2jade
html2jade = require path.resolve(__dirname, 'node_modules', 'html2jade', 'lib', 'html2jade.coffee')
Expand Down
5 changes: 1 addition & 4 deletions lib/exchange/plugins/jade/jade.plugin.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Export Plugin
module.exports = (BasePlugin) ->
# Requires
jade = null

# Define Plugin
class JadePlugin extends BasePlugin
# Plugin name
Expand All @@ -15,7 +12,7 @@ module.exports = (BasePlugin) ->
render: ({inExtension,outExtension,templateData,file}, next) ->
try
if inExtension is 'jade'
jade = require 'jade' unless jade
jade = require('jade')
file.content = jade.compile(file.content, {
filename: file.fullPath
})(templateData)
Expand Down
10 changes: 3 additions & 7 deletions lib/exchange/plugins/less/less.plugin.coffee
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Export Plugin
module.exports = (BasePlugin) ->
# Requires
path = null
less = null

# Define Plugin
class LessPlugin extends BasePlugin
# Plugin name
Expand All @@ -16,9 +12,9 @@ module.exports = (BasePlugin) ->
render: ({inExtension,outExtension,templateData,file}, next) ->
try
if inExtension is 'less' and outExtension is 'css'
# Load
path = require 'path' unless path
less = require 'less-clean' unless less
# Requires
path = require('path')
less = require('less')

# Prepare
srcPath = file.fullPath
Expand Down
2 changes: 1 addition & 1 deletion lib/exchange/plugins/less/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"url": "http://github.com/bevry/docpad.git"
},
"dependencies": {
"less-clean": ">=1.1.x"
"less": "1.2.x"
},
"engines" : {
"node": ">=0.4.0"
Expand Down
7 changes: 4 additions & 3 deletions lib/exchange/plugins/markdown/markdown.plugin.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Export Plugin
module.exports = (BasePlugin) ->
# Requires
markdown = require('github-flavored-markdown')

# Define Plugin
class MarkdownPlugin extends BasePlugin
# Plugin name
Expand All @@ -15,6 +12,10 @@ module.exports = (BasePlugin) ->
render: ({inExtension,outExtension,templateData,file}, next) ->
try
if inExtension in ['md','markdown'] and outExtension is 'html'
# Requires
markdown = require('github-flavored-markdown')

# Render
file.content = markdown.parse file.content
next()
else
Expand Down
8 changes: 4 additions & 4 deletions lib/exchange/plugins/move/move.plugin.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Export Plugin
module.exports = (BasePlugin) ->
# Required
roy = null

# Define Plugin
class MovePlugin extends BasePlugin
# Plugin name
Expand All @@ -15,7 +12,10 @@ module.exports = (BasePlugin) ->
render: ({inExtension,outExtension,templateData,file}, next) ->
try
if inExtension in ['move'] and outExtension is 'js'
move = require('move') unless roy
# Requires
move = require('move')

# Render
file.content = move.compile(file.content)
next()
else
Expand Down
8 changes: 4 additions & 4 deletions lib/exchange/plugins/related/related.plugin.coffee
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Export Plugin
module.exports = (BasePlugin) ->
# Requires
util = require 'bal-util'

# Define Relations Plugin
class RelationsPlugin extends BasePlugin
# Plugin Name
name: 'relations'

# Parsing all files has finished
parseAfter: ({logger},next) ->
# Requires
balUtil = require('bal-util')

# Prepare
docpad = @docpad
documents = docpad.documents
logger.log 'debug', 'Generating relations'

# Async
tasks = new util.Group (err) ->
tasks = new balUtil.Group (err) ->
logger.log 'debug', 'Generated relations'
next err

Expand Down
Loading

0 comments on commit 712f32c

Please sign in to comment.