Atlassian Confluence® Importer Plugin for DocPad
Import Atlassian Confluence spaces into DocPad collections. Forked from docpad-plugin-tumblr, with modifications and improvements from docpad-plugin-mongodb.
Install
docpad install conflux
Configure
Specify your Confluence site, space, and login credentials
Specify your Confluence site with CONFLUX_SITE
(e.g.,
http://confluence.example.org
), your space key with
CONFLUX_SPACE_KEY
and your login credentials with CONFLUX_USER
and
CONFLUX_PW
in either your
.env
configuration file
like so:
CONFLUX_SITE=http://confluence.example.org
CONFLUX_SPACE_KEY=SPACE1
CONFLUX_USER=user1
CONFLUX_PW=password1
Or in your docpad configuration file:
plugins:conflux:collections:site: 'http://confluence.example.org'spaceKey: 'SPACE1'user: 'user1'pass: 'password1'
Customize the output
Here's a more complex example:
plugins:conflux:collectionDefaults:site: 'http://confluence.example.org'user: 'user1'pass: 'password1'collections:spaceKey: 'SPACE1'collectionName: 'docs'relativeDirPath: 'docs'extension: '.html.eco':documentsetMetalayout: 'default'tags: documentget'tags' orspaceKey: 'SPACE2'collectionName: 'blog'relativeDirPath: 'posts'extension: '.html.eco':documentsetMetalayout: 'default'tags: documentget'tags' or
Configuration details
Each configuration object in collections
inherits default values
from collectionDefaults
and then from the built-in defaults:
collectionDefaults:site: processenvCONFLUX_SITEspaceKey: processenvCONFLUX_SPACE_KEYuser: processenvCONFLUX_USERpw: processenvCONFLUX_PWcollectionName: 'conflux'relativeDirPath: null # defaults to collectionNameextension: '.json'injectDocumentHelper: nullsort: null # http://documentcloud.github.io/backbone/#Collection-comparatormeta:
-
collectionName
- the name of the collection and also the default directory for the imported documents. The default isconflux
. You can customize this using therelativeDirPath
plugin configuration option. -
extension
- Use this option to customize the extension for imported documents. The default is.json
. -
injectDocumentHelper
- Use this option to customize the content of the imported documents. Define a function which takes in a single Document Model. You can access the Confluence JSON data from theconflux
object. For example:docpadConfig =plugins:conflux:collectionDefaults::documentsetMetadata: adjustSource documentget'conflux'bodyviewvaluelayout: 'default'tags: documentget'tags' or=# Images use cachr plugintext = textreplace/src=""/g"src=\"<%=@cachr('$1')%>\""# Inter-page linkstext = textreplace/href="\/display\/\/">/g'href="../$1/$2.html">'# Code blockstext = textreplace/<script type="syntaxhighlighter".*<!\[CDATA\[/g'<pre><code>'text = textreplace/]]><\/script>/g'</code></pre>'# Note iconstext = textreplace/<span class="aui-icon icon-hint">Icon/g'<span class="fa fa-info-circle">'text = textreplace/<span class="aui-icon icon-warning">Icon/g'<span class="fa fa-warning">'text = textreplace/<span class="aui-icon icon-sucess">Icon/g'<span class="fa fa-check-circle">'text = textreplace/<span class="aui-icon icon-problem">Icon/g'<span class="fa fa-exclamation-circle">'return text
Create a file listing
As imported documents are just like normal documents, you can also
list them just as you would other documents. Here is an example of an
index.html.eco
file that renders the titles and links to all the
imported documents:
Confluence:
History
See the change history in the
HISTORY.md
file.
Contribute
See how you can contribute in the
CONTRIBUTING.md
file.
License
Licensed under the incredibly permissive MIT license.
© 2015 Phoenix Technical Publications info@phoenixtechpubs.com (http://phoenixtechpubs.com)