Skip to content

Pastery Action #18

Description

@extratone

Updated 10122022-084424


Social

Another simple API action for @TaioApp... This time, for the greatest pastebin in the world.


Pastery Taio Action

<script>(function(d, s, id) {var js, pastejs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src ='https://www.pastery.net/static/js/embed.js';pastejs.parentNode.insertBefore(js, pastejs);}(document, 'script', 'pastery-jssdk'));</script>

Description

Create a Pastery paste via API with the current document's contents. The result's URL will be passed to the system clipboard.

You'll need to change the value of the apikey variable to your own Pastery API key.

See Pastery's API documentation: https://www.pastery.net/api

Video Demo

JSON

<script>(function(d, s, id) {var js, pastejs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src ='https://www.pastery.net/static/js/embed.js';pastejs.parentNode.insertBefore(js, pastejs);}(document, 'script', 'pastery-jssdk'));</script>
{
  "actions" : [
    {
      "type" : "@flow.set-variable",
      "parameters" : {
        "value" : {
          "value" : "YOURAPIKEY"
        },
        "name" : {
          "value" : "apikey"
        }
      }
    },
    {
      "type" : "@editor.filename",
      "parameters" : {
        "mode" : 0,
        "includeExtension" : false
      }
    },
    {
      "type" : "@text.encode",
      "parameters" : {
        "mode" : 0,
        "decode" : false,
        "text" : {
          "value" : "$",
          "tokens" : [
            {
              "location" : 0,
              "value" : "@input"
            }
          ]
        },
        "base64Options" : 0
      }
    },
    {
      "type" : "@flow.set-variable",
      "parameters" : {
        "value" : {
          "value" : "$",
          "tokens" : [
            {
              "location" : 0,
              "value" : "@input"
            }
          ]
        },
        "name" : {
          "value" : "filename"
        }
      }
    },
    {
      "type" : "@text.encode",
      "parameters" : {
        "mode" : 0,
        "decode" : false,
        "text" : {
          "value" : "$",
          "tokens" : [
            {
              "location" : 0,
              "value" : "@editor.full-text"
            }
          ]
        },
        "base64Options" : 0
      }
    },
    {
      "type" : "@flow.set-variable",
      "parameters" : {
        "value" : {
          "value" : "$",
          "tokens" : [
            {
              "location" : 0,
              "value" : "@editor.full-text"
            }
          ]
        },
        "name" : {
          "value" : "body"
        }
      }
    },
    {
      "type" : "@util.request",
      "parameters" : {
        "body" : {
          "value" : "$",
          "tokens" : [
            {
              "location" : 0,
              "value" : "body"
            }
          ]
        },
        "url" : {
          "value" : "https:\/\/www.pastery.net\/api\/paste\/?title=$&api_key=$&language=markdown",
          "tokens" : [
            {
              "location" : 51,
              "value" : "apikey"
            },
            {
              "location" : 41,
              "value" : "filename"
            }
          ]
        },
        "method" : 1,
        "headers" : {
          "value" : "{\"Content-Type\": \"text\/plain\"}"
        }
      }
    },
    {
      "type" : "@flow.javascript",
      "parameters" : {
        "script" : {
          "value" : "\/\/ Get input\nconst text = $actions.inputValue;\n\nlet data = JSON.parse(text)\n\n\/\/ Resolve with output\n$actions.resolve(data.url);\n\n\/\/ Exception handling:\n\/\/  $actions.reject(\"Error\");\n\/\/  $actions.finish();"
        }
      }
    },
    {
      "type" : "@flow.set-variable",
      "parameters" : {
        "value" : {
          "value" : "$",
          "tokens" : [
            {
              "location" : 0,
              "value" : "@input"
            }
          ]
        },
        "name" : {
          "value" : "url"
        }
      }
    },
    {
      "type" : "@ui.toast",
      "parameters" : {
        "style" : 1,
        "waitUntilDone" : true,
        "title" : {
          "value" : "Paste created - URL passed to system clipboard"
        }
      }
    },
    {
      "type" : "@util.set-clipboard",
      "parameters" : {
        "mode" : 0,
        "localOnly" : false,
        "text" : {
          "value" : "$",
          "tokens" : [
            {
              "location" : 0,
              "value" : "url"
            }
          ]
        },
        "expireAfter" : {
          "value" : "0"
        }
      }
    },
    {
      "type" : "@util.open-url",
      "parameters" : {
        "url" : {
          "value" : "$",
          "tokens" : [
            {
              "location" : 0,
              "value" : "url"
            }
          ]
        },
        "fullScreen" : false,
        "browser" : 2
      }
    }
  ],
  "buildVersion" : 1,
  "name" : "Pastery",
  "clientMinVersion" : 1,
  "summary" : "Create a Pastery paste via API with the current document's contents. The result's URL will be passed to the system clipboard.\n\nYou'll need to change the value of the `apikey` variable to your own Pastery API key.\n\nSee Pastery's API documentation: https:\/\/www.pastery.net\/api",
  "icon" : {
    "glyph" : "arrow.triangle.2.circlepath.doc.on.clipboard",
    "color" : "#FB6666"
  },
  "clientVersion" : 842
}

Metadata

Metadata

Assignees

Labels

actionsRegarding Taio Actions.apiUsing APIs.documentationImprovements or additions to documentation

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions