5

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

dreeves
  • 26,430
  • 45
  • 154
  • 229

5 Answers5

3

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.

dreeves
  • 26,430
  • 45
  • 154
  • 229
  • Argh, John McLear updated this for the latest version of Etherpad (thank you!) but someone else rejected it and now it's not letting me accept it. – dreeves May 26 '13 at 20:24
3

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.
ari
  • 56
  • 1
2

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()
Akshay Agarwal
  • 1,959
  • 1
  • 16
  • 14
2

You can get the plaintext content of etherpad using jQuery as:

jQuery(document).ready(function(){
    jQuery('#export').click(function(){
        var padId = 'examplePadIntense';//Id of the div in which etherpad lite is integrated
        var epframeId = 'epframe'+ padId;
        var frameUrl = $('#'+ epframeId).attr('src').split('?')[0];
        var contentsUrl = frameUrl + "/export/txt";
        jQuery.get(contentsUrl, function(data) {
            var textContent = data;
        });
    });
});
Arvind Bhardwaj
  • 5,231
  • 5
  • 35
  • 49
0

You can also use the getText HTTP api to retrieve the contents of a pad.

See my other answer for more details.

Shoan
  • 4,003
  • 1
  • 26
  • 29