Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pastery Action #18

Open
extratone opened this issue Oct 12, 2022 · 2 comments
Open

Pastery Action #18

extratone opened this issue Oct 12, 2022 · 2 comments
Assignees
Labels
actions Regarding Taio Actions. api Using APIs. documentation Improvements or additions to documentation

Comments

@extratone
Copy link
Owner

extratone commented Oct 12, 2022

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
}
@extratone extratone added documentation Improvements or additions to documentation actions Regarding Taio Actions. api Using APIs. labels Oct 12, 2022
@extratone extratone self-assigned this Oct 12, 2022
extratone added a commit that referenced this issue Oct 12, 2022
@extratone
Copy link
Owner Author

FullSizeRender.MOV

extratone added a commit that referenced this issue Oct 12, 2022
extratone added a commit that referenced this issue Oct 29, 2022
extratone added a commit that referenced this issue Oct 29, 2022
@extratone
Copy link
Owner Author

Updated Video Demo

IMG_5834.MOV

extratone added a commit that referenced this issue Oct 29, 2022
extratone added a commit that referenced this issue Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actions Regarding Taio Actions. api Using APIs. documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant