Upgrade
Upgrade Instructions
To upgrade your DocPad installation from an older version to the latest, check out the latest installation instructions as well as the upgrade manuals below.
Upgrading from 5.x to 6.x (v6 is the latest stable version)
Changes affecting configuration:
Removed the following configuration options:
documentsPath,filesPath, andlayoutsPath. Use their array-based alternatives instead:documentsPaths,filesPaths, andlayoutsPaths.
Changes affecting templates:
Removed
requirefromtemplateData. Instead, specify it in yourdocpad.csonorserver.coffeefile insteadRemoved
database,documents,collections,blocksfromtemplatedata. Instead, use their helper based alternatives:getDatabase(),getCollection('documents'),getCollection('collectionName'),getBlock('blockName')
Changes affecting everyone:
Removed the prototypes
String::startsWith,String::finishesWith,Array::hasCount,Array::hasas no one ever used themPlugin versions have been bumped to
2.xfor DocPad v6.x compatibility. You should update all your DocPad plugins versions in yourpackage.jsonto2.0.x(e.g.,"docpad-plugin-eco": "2.0.x") then runnpm installto install the new versions of the plugins
Changes affecting plugin developers:
Removed
docpadInstance.documents. UsedocpadInstance.getCollection('documents')instead.Plugin tests are now run via
npm teston your plugin directory, allowing you to use whatever test runner you wantDocPad and the tester helpers have moved from Mocha to Joe, you'll probably want to do the same
Upgrading from 4.x to 5.x
Documents, Partials and Layouts (which extend from the File Class) are now Backbone Models
For end-users this will have minimal effect, as
@documentinside thetemplateDatawill have all the same attributes. However, any function calls will now only be accessible via the new@documentModel. This is because@documentModelis the backbone model, and@documentis the JSONified version of the backbone model (e.g.,@documentis the same as@documentModel.toJSON()).For plugin developers this affects how you will retrieve and set attributes for documents - which now use the Backbone getters and setters instead of directly reading and writing to and from the attributes directly (e.g.,
document.relatedDocuments = []now becomesdocument.set(relatedDocuments:[])instead)
Query-Engine has been updated from version 0.6 to version 1.1
For end-users this will have an effect wherever
@databaseis used, as that is now represented by the new Query-Engine v1.1 collection, which has several changes. The most significant re@database.findis now@database.findAll, and that they now only have a synchronous interfacee. E.g. the@database.findAllselector(err, results) ->should now beresults = @database.findAll(selector)For plugin developers, this affects any
docpad.documents,docpad.partials, anddocpad.layoutscalls with the same advice as those for end-users.
Plugins are now handled via npm dependencies instead of being directly handled by DocPad and end-users. This is the most significant change and affects everybody.
For end-users, you will need to add the plugins you use to your website's
package.jsonfile. You can refer thepackage.jsonfile of thecanvas.docpadskeleton here for how to do this. Once added to your website'spackage.jsonfile, run anpm installto install them.For plugin developers, there have been several important changes:
All plugins must now have
docpad-plugininside thekeywordsproperty of theirpackage.jsonfile. It is also highly recommended to ensure your plugin's name follows thedocpad-plugin-#{pluginName}convention as this may become mandatory at a later date.You can now feel free to publish your plugin via npm (e.g.,
npm publish) and add your plugin to the Plugins page so others can install it themselves (e.g.,npm install docpad-plugin-#{pluginName}).
Upgrading from 3.x to 4.x
Skeletons are no longer cached, which means that you can no longer create a new website using a skeleton while offline. While this can be a pain, it was an essential change in order to improve stability and reduce complexity of the code base.
A document's
titlewill no longer default to the document'sfilenameif not set. Instead a new property callednameexists, which can be set by your document meta data. This is so thetitleproperty can be used for Page Titles (e.g.,<title>) whereas thenameproperty can be used for navigation listings etc.The DocPad core has been cleaned up a lot, and as such so has the way plugin events are triggered. We now utilise balUtil's emitSync and emitAsync instead of the old
triggerPluginEvent. This means that for now, plugin priorities are discarded - however they may be added back in the future (so leave them in there if you have them).Plugin rendering has had a significant change, which is you should no longer use
file.contentto read and update the current document's content. Instead a new argument calledcontentwil be passed, and it should be written to as well. This is a breaking change, and all renderers must be updated to facilitate this change. To learn the new way, then check out the Extending DocPad wiki page.When an error occurs, the error will now be sent back to DocPad using the AirBrake service. If you would like this disabled then you can turn it off by setting
reportErrorstofalsein your DocPad configuration.A lot of unstable or less-popular plugins have been moved out to the new docpad-extras repository. The plugins moved are:
admin,authenticate,autoupdate,buildr,html2jade,move,php,rest,roy, andruby. If you would like to continue using them, you will have to download them manually from thedocpad-extrasrepository and insert them into your website'spluginsdirectory.
Upgrading from 2.x to 3.x
A lot of property names of the
Fileclass have changed. TheFileclass is used for all documents and layouts, which would likely affect you when rendering properties from documents inside your templates e.g.@document.title. This change was made to better correlate the names with their values (before the correlation was quite ambiguous). You can find the current set of properties and their descriptions here.For plugin developers, the way you extend from the
BasePlugin, and the way youmodule.exportsyour plugin has changed. To learn about the new convention, refer to the new Extending guide by clicking here.For those using DocPad as a module, DocPad now supports a
nextcallback on its constructor, allowing you to donew DocPad(config,next). Anything that depends on a DocPad action being completed should go inside thenextcallback. While this is optional, it has proven helpful in eliminating timing problems.
Upgrading from 1.x to 2.x
CoffeeScript v1.1.2 does not work with Node 0.5 or 0.6, you have to use v1.1.3 or higher. To do this, re-install CoffeeScript with
npm install -g coffee-scriptFor plugin developers:
Plugins have been revised to become more future proof and configurable. Plugins must be in their own directory, with the following format:
plugins/${pluginName}/${pluginName}.plugin.coffeePlugin dependencies should no longer be in the DocPad's or your project's
package.jsonfile, but instead in their plugin directory'spackage.json(e.g.,plugins/${pluginName}/package.json); this file is optional, but recommended.If a plugin's
package.jsonexists, as well as itsmainproperty, DocPad will use that as the plugin file's location instead of the location in step 2.1.Plugin configuration should be moved to their
package.jsonfile, to the keydocpad.pluginwhich should be an object. This is then customisable by DocPad'spackage.jsonas well as the website's viadocpad.plugin.#{pluginName}. The configuration of a plugin is available via the@configproperty.To access DocPad within a plugin, you should now use
@docpadrather than having it passed through as an argument, this applies for logger too (now use@logger).A lot of DocPad configuration has been moved to
@docpad.config
The Bootstrap Skeleton is now the Kitchensink Skeleton
Upgrading from 0.x to 1.x
Install DocPad with the new global dependencies
npm install -g coffee-script docpadAny of your
documentsorlayoutswhich use the eco templating engine should have the extension.ecoappended (e.g.,layouts/default.htmltolayouts/default.html.eco)Any of your
documentsorlayoutswhich utilise a markup language should have the extension.htmlprepended (e.g.,documents/something-in-markdown.mdtodocuments/something-in-markdown.html.md)These changes allow for some new incredibly powerful possibilities, such as allowing other templating engines other than eco, and allowing for multiple and more explicit markups to be applied to the files.
Last updated
Was this helpful?