A simple node.js wrapper for the LocalWiki api
JavaScript
Pull request Compare This branch is 41 commits behind openseattle:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
.gitignore
README.md
index.js
package.json

README.md

node-localwiki-client

A simple node.js wrapper for the localwiki api.

Installation:

npm install node-localwiki-client

Examples:

Require the module:

var LocalWikiClient = require('node-localwiki-client')

Initialize with at least the localwiki url:

var wiki = new LocalWikiClient({
  url: 'YOUR_LOCALWIKI_URL' // like http://seattlewiki.net or https://sfwiki.org

  // user and apikey not required for get requests
  user: process.env.LOCALWIKI_USER,
  apikey: process.env.LOCALWIKI_API_KEY
})

create a page named Waterside Park

wiki.create({
  resource_type: LocalWikiClient.Type.PAGE,
  data: {
    'name': "Waterside Park",
    'content': "A simple test page."
  },
  success: function(resource) {
    console.log("Created new page", resource.identifier)
  }
})

get a resource

wiki.fetch({
  identifier: 'WatersidePark',
  success: function(resource) {
    console.log("page data: ", resource.data.content)
  }
})

update a page

wiki.fetch({
  identifier: 'WatersidePark',
  success: function(resource) {
    resource.data.content += "<br /> Updated at " + new Date()
    resource.update(function() {
      console.log("Success");
    })
  }
})

delete a page

resource.delete(function() {
  console.log("resource deleted.");
});

list multiple resources

wiki.list({
  resource_type: LocalWikiClient.Type.PAGE,
  filters: {
    limit: 5
  },
  success: function(items) {
    console.log("found " + items.length + " matching pages.")
  }
})