Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I programatically fetch the live plaintext contents of an etherpad?

Tags:

etherpad

This question came up on the etherpad-open-source-discuss mailing list and I thought it would be useful to have it here.

like image 443
dreeves Avatar asked Oct 28 '10 02:10

dreeves


3 Answers

Just construct a URL like so and fetch it:

http://dtherpad.com/ep/pad/export/foo/latest?format=txt

That will get the live, plaintext contents of http://dtherpad.com/foo

For example, in PHP you can grab it with

file_get_contents("http://dtherpad.com/ep/pad/export/foo/latest?format=txt")

Note that that's just the "export to plain text" link that's provided in the Import/Export menu of every pad.

like image 89
dreeves Avatar answered Oct 14 '22 06:10

dreeves


A few other possibilities:

  • From a browser, you can hit http://your-etherpad-server.com/ep/pad/view/padId/latest?pt=1
  • From within the code of the collaborative editor (ace2_inner.js), use rep.alltext
  • Within the Etherpad's javascript, use pad.text for the most recent version of pad.getRevisionText(rev.revNum) for a specified previous revision.
like image 43
ari Avatar answered Oct 14 '22 07:10

ari


It seems that the javascript functions mentioned by Ari in his response are no longer present in the current versions of Etherpad as implemented on sites like http://etherpad.mozilla.org

However you can now simply use the following javascript function, within eherpad's javascript to get the text of the latest revision

padeditor.ace.exportText()
like image 21
Akshay Agarwal Avatar answered Oct 14 '22 06:10

Akshay Agarwal