├── .gitignore ├── LICENSE ├── README.md ├── index.js ├── package-lock.json ├── package.json └── screenshots ├── app.png └── settings.png /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 The Devs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Alfred workflow for Kutt 2 | [Kutt](https://kutt.it) is a modern open source URL shortener. With this workflow, you can kutt your links shorter right from your Alfred app. 3 | 4 | **[Download](https://github.com/thedevs-network/alfred-kutt/releases/download/1.0.0/kutt.alfredworkflow)** 5 | 6 | ![Workflow Screenshot](screenshots/app.png) 7 | 8 | ## Requirements 9 | - [Alfred app](https://www.alfredapp.com) 10 | - [Alfred powerpack](https://www.alfredapp.com/powerpack/) 11 | - [Node.js](https://nodejs.org/) 12 | 13 | ## Setup 14 | Login to [Kutt](https://kutt.it), go to settings and generate an API key. 15 | Open `Alfred prefrences > Workflows > Kutt` and add the API key in workflow's environment variables settings. 16 | 17 | ![Workflow Settings](screenshots/settings.png) 18 | 19 | ## Commands 20 | ``` 21 | kutt {url} 22 | ``` -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const p = require('phin'); 2 | 3 | const target = process.argv[process.argv.length - 1]; 4 | const key = process.env.API_KEY; 5 | 6 | if (!key) { 7 | return console.log('Please set an API key first.'); 8 | } 9 | 10 | function getErrorMessage(message) { 11 | if (message === 'reCAPTCHA is not valid. Try again.') { 12 | return 'API key is invalid.' 13 | } 14 | return message; 15 | }; 16 | 17 | (async function() { 18 | try { 19 | const { body = {} } = await p({ 20 | url: 'https://kutt.it/api/url/submit', 21 | method: 'POST', 22 | data: { target }, 23 | core: { 24 | headers: { 25 | 'X-API-KEY': key, 26 | 'Content-Type': 'application/json' 27 | }, 28 | }, 29 | parse: 'json' 30 | }); 31 | const message = body.shortUrl || getErrorMessage(body.error) 32 | console.log(message) 33 | } catch (error) { 34 | console.log(error.message); 35 | } 36 | })(); 37 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "alfred-kutt", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "centra": { 8 | "version": "2.4.0", 9 | "resolved": "https://registry.npmjs.org/centra/-/centra-2.4.0.tgz", 10 | "integrity": "sha512-AWmF3EHNe/noJHviynZOrdnUuQzT5AMgl9nJPXGvnzGXrI2ZvNDrEcdqskc4EtQwt2Q1IggXb0OXy7zZ1Xvvew==" 11 | }, 12 | "phin": { 13 | "version": "3.4.0", 14 | "resolved": "https://registry.npmjs.org/phin/-/phin-3.4.0.tgz", 15 | "integrity": "sha512-wueoW9X6HbzBN4AqV3Etv9kkgYyaObwPTsIYsUEmgDWiLI6SzYozEsOZ5e3Hd/9H0mrIUbqUuvOTA6SCqErJrQ==", 16 | "requires": { 17 | "centra": "^2.2.1" 18 | } 19 | }, 20 | "run-node": { 21 | "version": "1.0.0", 22 | "resolved": "https://registry.npmjs.org/run-node/-/run-node-1.0.0.tgz", 23 | "integrity": "sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A==" 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "alfred-kutt", 3 | "version": "1.0.0", 4 | "description": "Alfred workflow for Kutt", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/thedevs-network/alfred-kutt.git" 12 | }, 13 | "keywords": [ 14 | "alfred", 15 | "alfred-workflow", 16 | "kutt" 17 | ], 18 | "author": "poeti8", 19 | "license": "MIT", 20 | "bugs": { 21 | "url": "https://github.com/thedevs-network/alfred-kutt/issues" 22 | }, 23 | "homepage": "https://github.com/thedevs-network/alfred-kutt#readme", 24 | "dependencies": { 25 | "phin": "^3.4.0", 26 | "run-node": "^1.0.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /screenshots/app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedevs-network/alfred-kutt/25ba6cc02ecf48e2a5905505ea0ff10c673d6e23/screenshots/app.png -------------------------------------------------------------------------------- /screenshots/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedevs-network/alfred-kutt/25ba6cc02ecf48e2a5905505ea0ff10c673d6e23/screenshots/settings.png --------------------------------------------------------------------------------