node-pingback
Pingbacks have come to node.js. If you're writing a blog, you may be interested in this. It conforms to the pingback specification, as well as the XML-RPC spec, however, it may need more testing.
It protects against spam, has no dependencies, and can be used right out of the box. Connect/Express middleware is included.
Usage
Receiving Pingbacks (contrived example for clarity)
app;
What you see above is merely the abstracted interface of the bundled middleware. See example.js/test.js for more in-depth and lower-level examples.
Sending Pingbacks
// ping a target - err will be a fault code if presentPingback;// scan an html string for links to pingvar text = 'a link here: <a href="http://localhost:9000/article">a post</a>';Pingback;
Again, see example.js/test.js for more examples and explanation.
Reference
Fault Code Constants
PingbackMETHOD_NOT_FOUND = -32601;PingbackGENERAL_ERROR = 0;PingbackSOURCE_DOES_NOT_EXIST = 16;PingbackNO_LINK_TO_TARGET = 17;PingbackTARGET_DOES_NOT_EXIST = 32;PingbackTARGET_CANNOT_BE_USED = 33;PingbackALREADY_REGISTERED = 48;PingbackACCESS_DENIED = 49;
Pingback properties
source
: a parsed url object of the sourcetarget
: a parsed url object of the targetexcerpt
: an excerpt from the source's pagetitle
: the title of the source page
Events for receiving pingbacks
ping
: An optional event to validate and handle errors/faults. If bound, this will be triggered as the first event and passed anext
callback, which can be passed a fault code to trigger a fault response, otherwise it will continue handling the pingback. Arguments:source
,target
,next
.fault
: Emitted when a fault occurs. Passed the fault code and string. Arguments:code
,msg
.error
: Emitted for non-fault related errors. Calls the next middleware layer in the bundled connect/express middleware function. Arguments:err
.end
: Emitted if noping
listeners have been bound, and after a pingback has been received and verified. Arguments:source
,target
,next
.next
has the same effect as the callback passed forping
.success
: Emitted if aping
listener was bound, and after the pingback has been received and handled. Arguments:source
,target
.
License
(c) Copyright 2011, Christopher Jeffrey (MIT License). See LICENSE for more info.