Action pURL

Posted by mph, Last update over 1 year ago


over 1 year ago

Built-in icon

show all updates...

over 1 year ago

Built-in icon

over 1 year ago

Corrects a hard-coded variable in the final url.

over 1 year ago

Crediting podiboq for their status action, which provided the scaffold. I just had to twiddle some variables and add a little input processing.

over 1 year ago

Seems to work well enough so making it public.

Makes a pURL out of selected text using a name|urlpattern:

  • homepage|
  • google|


Select the name|url pair, run the action, selected text is replaced.

(Thanks to podiboq:


  • script

    // Storing the credentials in Draft's Credential instead of the action code directly
    // Thank you podiboq:
    var credential = Credential.create(" pURLs", "Store your API key username privately");
    credential.addTextField("omg_username", "Your username");
    credential.addPasswordField("omg_api_key", "API Key");
    // 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": "" + omg_username + "/purl",
    	"method": "POST",
    	"data": {
    	  "name": name,
    	  "url": url,
    	"headers": {
    	  "Authorization": "Bearer " + omg_api_key
    editor.setSelectedText("https://" + omg_username + "" + name)


  • 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.