-
-
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!).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
look at Python CLI interface for managing gists - https://github.com/jdevesa/gists