Permalink
Browse files

node-pinboard source

  • Loading branch information...
0 parents commit 04f0f002f87c2f885ac5612ed8fe08cd2c87b0da @frozzare committed Aug 24, 2011
Showing with 476 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +71 −0 README.md
  3. +6 −0 examples/README.md
  4. +21 −0 examples/pinboard-couchdb.js
  5. +1 −0 index.js
  6. +346 −0 lib/pinboard.js
  7. +29 −0 package.json
@@ -0,0 +1,2 @@
+.DS_Store
+node_modules/
@@ -0,0 +1,71 @@
+# node-pinboard
+node-pinboard is a node module for Pinboard.in API
+
+# installation
+1. install npm `curl http://npmjs.org/install.sh | sh`
+2. `npm install pinboard`
+
+# usage
+a quick example using `node-pinboard`, this module require that you have a [Pinboard](http://pinboard.in) account.
+
+to use `node-pinboard` you need to do include the module in your code
+
+ var pinboard = require('pinboard');
+
+then you need to auth yourself so you are good to go with the API
+
+ pinboard.config({
+ username: 'username',
+ password: 'password',
+ format: 'json' // or 'xml', default is 'json'.
+ });
+
+the default format for `node-pinboard` is json. but 'xml' is default on Pinboard API, so for thoose method that don't have the format support we get the xml and parse it into json if you have json format on that method request.
+
+all Pinboard methods is paste into the `pinboard.get` function, e.g.
+
+ pinboard.get( method, [options,] callback );
+
+ pinboard.get('posts/all', function(data) {
+ console.log(data); // => xml or json output of all your bookmarks
+ });
+
+the `pinboard.get` have differnt options depending on the method you are requesting. The only option that all method have is the format option.
+when you set format option inside the `pinboard.get` function you will use that format instead of the `pinboard.config` format.
+
+## methods
+`node-pinboard` support all the method that are on [Pinboard API](http://pinboard.in/api) documentation except the `user/secret` method (maybe later).
+
+`node-pinboard` have some build in alias functions for the `pinboard.get` function. so instead of writing
+
+ pinboard.get('posts/all', function(data) {
+ console.log(data); // => xml or json output of all your bookmarks
+ });
+
+you can write
+
+ pinboard.all(function(data) {
+ console.log(data); // => xml or json output of all your bookmarks
+ });
+
+the methods that have alias is
+
+ "posts/all" => pinboard.all([options,] callback)
+ "posts/add" => pinboard.add([options,] callback)
+ "posts/delete" => pinboard.destroy([options,] callback)
+ "tags/get" => pinboard.tags([options,] callback)
+
+# pinboard functions
+all callback function have the data argument `function(data) {...}`
+
+`pinboard.config(options)` `pinboard.get(method, [options,] callback)` `pinboard.all([options,] callback)` `pinboard.add([options,] callback)` `pinboard.destroy([options,] callback)` `pinboard.tags([options,] callback)`
+
+# meta
+ * code: `git clone git://github.com/duofy/node-pinboard.git`
+ * home: <http://github.com/duofy/node-pinboard>
+ * bugs: <http://github.com/duofy/node-pinboard/issues>
+
+# copyright and license
+`node-pinboard` is release under MIT license.
+
+Copyright 2011 [Fredrik Forsmo](http://forsmo.me), [Duofy team](http://duofy.com)
@@ -0,0 +1,6 @@
+# examples
+Don't forget to add your username and password before you run any example file!
+
+pinboard-couchdb.js is a example showing how easy it's to backup all your bookmarks from [Pinboard](http://pinboard.in) to couchdb. You need to install cradle to test `npm install cradle`
+
+More example to come.
@@ -0,0 +1,21 @@
+var pinboard = require('../'),
+ cradle = require('cradle'),
+ db = new(cradle.Connection)().database('pinboard');
+
+db.exists(function(exists) {
+ if(!exists) db.create('pinboard');
+});
+
+pinboard.config({
+ username: 'username',
+ password: 'password'
+});
+
+pinboard.all(function(data) {
+ data.forEach(function(item, index) {
+ db.save("pin" + index, data[index], function (err, res) {
+ if (err) throw err;
+ console.log( data[index].href + ' saved!' )
+ });
+ });
+});
@@ -0,0 +1 @@
+module.exports = require('./lib/pinboard.js');
Oops, something went wrong.

0 comments on commit 04f0f00

Please sign in to comment.