Action
Add Pinboard Note
Pinboard doesn’t natively support adding to notes (you can list a single or all notes with their API. More information at [https://pinboard.in/api/(https://pinboard.in/api/)])
This shortcut takes your draft and adds it to a new note in Pinboard.
The inspiration for this was from HyShai’s Pinote module which does something similar using python to make a request.
Steps
-
script
// See online documentation for examples // http://getdrafts.com/scripting // get username and password from credentials var credential = Credential.create("Pinboard", "Allow Login to the Pinboard Site for Requests. ONLY USE FOR ACTIONS NOT COVERED BY THE PINBOARD API") credential.addTextField("username", "Username"); credential.addPasswordField("password", "Password"); credential.authorize(); http = HTTP.create() var response = http.request({ 'url': 'https://pinboard.in/auth/', 'method': 'POST', 'data': { 'username': credential.getValue('username'), 'password': credential.getValue('password')}, 'encoding': 'form' }) menu = Prompt.create() menu.title = "New Pinboard Note" menu.message = "Add a new note to your Pinboard Account" menu.addTextField('title','Title', draft.processTemplate('[[title]]')) menu.addTextField('tags', 'Tags', draft.tags.join(', '), {'placeholder': 'Enter Tags: comma-separated'}) menu.addTextView('note', 'Note', draft.processTemplate('[[body]]')) menu.addSwitch('markdown', 'Markdown', true) menu.addSwitch('private','Private', true) menu.addButton('Add Note','ok') m = menu.show() if (m) { title = menu.fieldValues['title'] tags = menu.fieldValues['tags'] note = menu.fieldValues['note'] if (menu.fieldValues['markdown']) { var markdown = '1' } else { var markdown = '0' } if (menu.fieldValues['private']) { var set_private = 'private' } else { var set_private = 'public' } var response2 = http.request({ 'url': 'https://pinboard.in/note/add/', 'method': 'POST', 'data': { 'title': title, 'tags': tags, 'note': note, 'use_markdown': markdown, 'submit': 'save_ ' + set_private, 'action': 'save_' + set_private }, 'username': credential.getValue('username'), 'password': credential.getValue('password'), 'headers': {'User-Agent': 'Drafts for IOS'}, 'encoding': 'form' }) console.log(response.statusCode); console.log(response.responseData); console.log(response2.statusCode); console.log(response2.responseData); }
Options
-
After Success Archive , Tags: pinboard Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.