Action
omg.lol pURL
UPDATES
almost 2 years ago
Built-in icon
almost 2 years ago
Built-in icon
almost 2 years ago
Corrects a hard-coded variable in the final url.
almost 2 years ago
Crediting podiboq for their omg.lol status action, which provided the scaffold. I just had to twiddle some variables and add a little input processing.
almost 2 years ago
Seems to work well enough so making it public.
Makes a pURL out of selected text using a name|url
pattern:
homepage|https://homepage.com
google|https://google.com
etc.
Select the name|url
pair, run the action, selected text is replaced.
(Thanks to podiboq: https://actions.getdrafts.com/a/2DT)
Steps
-
script
// Storing the omg.lol credentials in Draft's Credential instead of the action code directly // Thank you podiboq: https://actions.getdrafts.com/a/2DT var credential = Credential.create("omg.lol pURLs", "Store your omg.lol API key username privately"); credential.addTextField("omg_username", "Your username"); credential.addPasswordField("omg_api_key", "API Key"); credential.authorize(); // Get the values and store them: let omg_api_key = credential.getValue("omg_api_key") let omg_username = credential.getValue("omg_username") // Operate on the selected text. // Default: #{name}|#{url} // switch the list indexes in url and name if you prefer url|name let url_pair=editor.getSelectedText(); var list=url_pair.split("|"); let url = list[1] let name = list[0] var http = HTTP.create(); var response = http.request({ "url": "https://api.omg.lol/address/" + omg_username + "/purl", "method": "POST", "data": { "name": name, "url": url, }, "headers": { "Authorization": "Bearer " + omg_api_key } }); editor.setSelectedText("https://" + omg_username + ".url.lol/" + name)
Options
-
After Success Nothing , Tags: omg, purl Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.