Send editor content RESTfully; then render response?

30 views
Skip to first unread message

Alec Taylor

unread,
Nov 18, 2012, 2:10:20 AM11/18/12
to etherpad...@googlegroups.com
I have many novel ideas on how to increase the number of use-cases Etherpad caters for.

In order to explore these ideas though, I need to know how to:
  1. Create a button which on-click will send the editor's content as JSON—{'id': 'untitled', 'body':'hello world', 'revision': 3432}—in POST to a server
  2. Display the output from the server where the POST message was sent in a "wide" status-bar at the bottom of the screen

Thanks for all suggestions,

Alec Taylor

BTW: I will open-source this project when it's Beta ready

Marcel Klehr

unread,
Nov 18, 2012, 5:52:57 AM11/18/12
to etherpad...@googlegroups.com
Hey Alec,

afaik it's rather difficult to get the pad contents directly out of the client-side editor. It is possible to retrieve the current pad contents through our (not yet RESTful...) HTTP API, though. Have a look at http://etherpad.org/doc/v1.2.0/#index_http_api for a list of all supported endpoints and a quick introduction on how to use the API.
In order to display something om the screen you can just use some jquery and css. You'd want to write all this as a plugin, of course. Insert css <link>s and a toolbar button using an eejs Block hook for the 'styles' block and the 'editbarMenuLeft' / 'editbarMenuRight' blocks respectively. The documentReady hook will call you once the document is ready... ;)

good luck!
marcel

John McLear

unread,
Nov 18, 2012, 1:15:11 PM11/18/12
to etherpad...@googlegroups.com
var url = document.href + "/export/txt";

$.get(url, function(data) {
alert(data);
});

Marcel is right, make sure you right it as a plugin and try to use git
so we can review the code and suggest improvements.
> --
> You received this message because you are subscribed to the Google Groups "etherpad-lite-dev" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/etherpad-lite-dev/-/keClwvs59oYJ.
>
> To post to this group, send email to etherpad...@googlegroups.com.
> To unsubscribe from this group, send email to etherpad-lite-...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/etherpad-lite-dev?hl=en.
Reply all
Reply to author
Forward
0 new messages