peer-pad icon indicating copy to clipboard operation
peer-pad copied to clipboard

Snippet request: get the current pad state as a string.

Open mikeal opened this issue 5 years ago • 3 comments

I've been looking at doing some workflow automation and one thing I'd like to do is take a peerpad (the user will give me the URL to the pad) and commit it to GitHub.

In order to do that I just need a JS code snippet that can get the current pad state as a string for any pad given identifiers I can pull out of the URL. I went through the current docs and didn't quite see how I could do that easily.

mikeal avatar Jan 15 '19 18:01 mikeal

I'll see if I can code up an example quickly... doing it with Node is easier as I can avoid bundling...

jimpick avatar Jan 15 '19 18:01 jimpick

Any code sample you do in Node.js that will "just work" if I did that same thing bundled through webpack would be fine :)

If there's something about the browser environment that makes this inherently difficult, let me know and I can use the Node.js snippet to create a simple service instead :)

mikeal avatar Jan 15 '19 19:01 mikeal

https://github.com/jimpick/peer-pad-tool

Usage: node index.js <url>

$ node index.js https://dev.peerpad.net/#/w/markdown/HGUcFHKPCe6Wvv2KNLP1fTU867CySJC5zC9SddV1Rhf5/4XTTMCuCB6aTCYz2Py3g7kea382Mi3MvisqtqawmLRMHnb7W8-K3TgUV8e7o7h8epS5efRWQZLTsB8A9TGwR1ByAFq7yrzthCHoFrJdyg5KBDsCZW7JS3as7T24nXHkv5kYgt7MvoAvc4CP7qEtSh9MSmQg3x4P918TgVqVdBxqGmNi1KTbnDLVxj2
Starting...
(node:16284) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 start listeners added. Use emitter.setMaxListeners() to increase limit
Swarm listening on /dns4/ws-star1.par.dwebops.pub/tcp/443/wss/p2p-websocket-star/ipfs/QmULDVgVNTo7RxvMjfyEbCJ5cbjpKyp3sYVTjH9PBvHFMY
Fetching content...
Fetching title...
Title: Demo for peer-pad-tool

This is the document content..

This is a first pass. I'm finding it to be really flakey at the moment. Sometimes it works, sometimes it gets stuck. Sometimes it returns too early with only a partial document. I'm going to investigate further. The "sub-collaborations" we use for the title of the PeerPad document seem to be syncing less reliably than the content ... and the replication lifecycle events don't seem to be firing on an initial sync.

I'd love to get @pgte and @satazor to look at this client example and see if we can come up with something more idiomatic...

The currently deployed version at https://dev.peerpad.net/ is old ... I need to bug @victorb (the Jenkins CD setup is in a broken state)

Right now, our libraries are not silent - I'd like to see the 'Swarm listening' and 'EventEmitter' messages go away.

jimpick avatar Jan 15 '19 20:01 jimpick