A Drafts App URL action combined with a python script for creating quick gists on iOS.
- Drafts App
- Pythonista App
- Git Hub OAuth token
Since this script runs on an iOS app, a GitHub OAuth token must be created prior to use. It's easy to create a token using curl from the terminal. Make sure to add your GitHub username to the following command:
curl https://api.github.com/authorizations \
--user "YOUR_GITHUB_USERNAME" \
--data '{"scopes":["gist"],"note":"Drafts"}'
The response will contain a line: "token" : foo
where foo is the token string.
Add the token to line 14.
There is also an option for creating public or private gists on line 17.
You can verify the token is enabled at: https://github.com/settings/applications
##Step 2: Create a Drafts URL Action
Paste the following URL into Mobile Safari to a create an URL action in Drafts:
drafts://x-callback-url/import_action?type=URL&name=Gist&url=pythonista%3A%2F%2FDraftsGist%3Faction%3Drun%26args%3D%2522%5B%5Btitle%5D%5D%2522%2520%2522%5B%5Bbody%5D%5D%2522
Or manually create a URL Action:
pythonista://DraftsGist?action=run&args=%22[[title]]%22%20%22[[body]]%22
Paste the contents of Drafts.py into a new Pythonista file. It must have the title: DraftsGist.
Easy peasy. Format your note as such:
This is the first line of the note and the gist's title
Everything else is the content of the note. This is the 1st paragraph.
Line breaks are preserved.
This will be the third paragraph of the note.
Use the Gist action to send the note to Pythonista. Once gist is created, a web browser will open to show the raw contents of the gist.