frankendoc
Version:
bringing documents alive
54 lines (38 loc) • 1.39 kB
text/coffeescript
rest = require 'restler'
{ Docs } = require './docs'
= -> new Confluence().read()
class Confluence
read: ->
return unless ?
= [ ]
while .length
doc = .shift()
if doc.is_suite
then .add_suite doc.name
else .read_doc doc
.docs
read_doc: (id, done) ->
uri = "#{@root_uri}/content/#{id}?expand=children"
rest.get(uri, ).on 'complete', () =>
if
done()
add_suite: -> .unshift .add_suite .title
add_doc: -> .add .title, .body.value
has_children: -> .children.content.length
queue_children: -> for child in .children.content
.unshift child.id
constructor: ->
= new Docs
line_break: '\n'
code_block: /ac:name="code".*?CDATA\[([\s\S]*?)\]\]><\//g
= "http://#{@host}/rest/prototype/1"
= 'Basic ' + + ':' +
=
headers:
authorization:
accept: 'application/json'
read_settings: -> @[setting] = value for setting, value of settings.docs
encode64: (string) -> new Buffer(string).toString 'base64'