Skip to content

Instantly share code, notes, and snippets.

@maphew
Forked from anonymous/push_to_Gist.txt
Last active April 19, 2020 16:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maphew/5500565 to your computer and use it in GitHub Desktop.
Save maphew/5500565 to your computer and use it in GitHub Desktop.
=== Leo editor script to publish from a node to Gist === At present everything is done anonymously, so there's no way to delete an old push, or make the next a push a revision to a previous one. In other words it's trivial to create **many** duplicates. So I wouldn't actually use this yet; it's just proof of concept (and wickedly easy!).
import requests
import json
description = "published from Leo" # todo: derive from docstring, if present, otherwise 1st para
public = True
filename = p.h # node headline
content = p.b # node body
api_url = 'https://api.github.com/gists'
user = '' # todo: derive from... parent node? leoID?
password = '' # todo: derive from... ???
g.es(filename)
print('\n\n--- %s ---' % filename)
payload = {
'description': description,
'public': public,
'files': {
filename: {'content': content}
}
}
#print (payload)
#r = requests.post(api_url, data=json.dumps(payload), auth=(user, password))
r = requests.post(api_url, data=json.dumps(payload))
print (r.status_code)
#print (r.text)
# capture and save request results
p = c.p
nd = p.insertAsLastChild()
nd.h = 'Push result: text'
nd.b = r.text
c.redraw()
#todo: parse text result and return clickable urls
# c.createLastChildNode(p.h, 'testing...', r.text)
@maphew
Copy link
Author

maphew commented May 2, 2013

look at Python CLI interface for managing gists - https://github.com/jdevesa/gists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment