aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-09-08 10:33:47 +0200
committerLibravatar GitHub <noreply@github.com>2021-09-08 10:33:47 +0200
commitb94c29c9890c46bb6388d53bc549cc24f19f0649 (patch)
treeed38a70538414db7e8f6091d6ce5b85e50728354 /docs
parentRemove dependency on 'require' of 'electron' and 'electron/remote' modules. (diff)
downloadferdium-recipes-b94c29c9890c46bb6388d53bc549cc24f19f0649.tar.gz
ferdium-recipes-b94c29c9890c46bb6388d53bc549cc24f19f0649.tar.zst
ferdium-recipes-b94c29c9890c46bb6388d53bc549cc24f19f0649.zip
build: migrate from npm to pnpm (#603)
Diffstat (limited to 'docs')
-rw-r--r--docs/integration.md63
1 files changed, 31 insertions, 32 deletions
diff --git a/docs/integration.md b/docs/integration.md
index 769bde7..38a5a32 100644
--- a/docs/integration.md
+++ b/docs/integration.md
@@ -38,30 +38,28 @@ We have also created a nice script that already does 50% of the work for you - y
383. (Optional, if you want to use our creation script) Install its dependencies via the terminal: 383. (Optional, if you want to use our creation script) Install its dependencies via the terminal:
39 39
40```Bash 40```Bash
41npm install 41pnpm install
42``` 42```
43 43
444. You can now run our automatic recipe wizard that creates and opens the new recipe for you: 444. You can now run our automatic recipe wizard that creates and opens the new recipe for you:
45 45
46```Bash 46```Bash
47# Make sure you are still in the repository's folder 47# Make sure you are still in the repository's folder
48npm run create "Service Name" 48pnpm run create "Service Name"
49``` 49```
50 50
51Replace `Service Name` with the name of your service, e.g. `npm run create "Google Hangouts"`. 51Replace `Service Name` with the name of your service, e.g. `pnpm run create "Google Hangouts"`.
52This command will automatically create the development recipe in the correct folder, prepares it for your service and opens the new recipe in your file explorer or Finder. 52This command will automatically create the development recipe in the correct folder, prepares it for your service and opens the new recipe in your file explorer or Finder. 5. Reload Ferdi (`CMD/CTRL + SHIFT + R`) in order for it to register the new recipe 6. You can now develop your recipe as described below. Please continue down below with "[Publishing](#Publishing)" after you are done creating your recipe.
535. Reload Ferdi (`CMD/CTRL + SHIFT + R`) in order for it to register the new recipe
546. You can now develop your recipe as described below. Please continue down below with "[Publishing](#Publishing)" after you are done creating your recipe.
55 53
56## Recipe structure 54## Recipe structure
57 55
58Every recipe needs a specific file structure in order to work as a Ferdi recipe 56Every recipe needs a specific file structure in order to work as a Ferdi recipe
59 57
60* icon.svg - Icon for the service in SVG form (must be square) 58- icon.svg - Icon for the service in SVG form (must be square)
61* index.js - Backend script, this script is NOT included in the service webview but only in Ferdi itself 59- index.js - Backend script, this script is NOT included in the service webview but only in Ferdi itself
62* package.json - Information about the recipe 60- package.json - Information about the recipe
63* webview.js - Frontend script, this script is injected into the service itself but still has access to all NodeJS APIs 61- webview.js - Frontend script, this script is injected into the service itself but still has access to all NodeJS APIs
64* darkmode.css - CSS File that gets included when dark mode is activated 62- darkmode.css - CSS File that gets included when dark mode is activated
65 63
66### package.json 64### package.json
67 65
@@ -89,32 +87,33 @@ Please note that the fields `id`, `name`, `version` and `config` are mandatory.
89This is your "backend" code. Right now the options are very limited and most of the services don't need a custom handling here. If your service is relatively straight forward and has a static URL eg. _messenger.com_, _`[TEAMID]`.slack.com_ or _web.skype.com_ all you need to do to return the Ferdi Class: 87This is your "backend" code. Right now the options are very limited and most of the services don't need a custom handling here. If your service is relatively straight forward and has a static URL eg. _messenger.com_, _`[TEAMID]`.slack.com_ or _web.skype.com_ all you need to do to return the Ferdi Class:
90 88
91```js 89```js
92module.exports = Ferdi => Ferdi; 90module.exports = (Ferdi) => Ferdi;
93``` 91```
94 92
95If your service can be hosted on custom servers, you can validate the given URL to detect if it's your server and not e.g. google.com. To enable validation you can override the function `validateServer` 93If your service can be hosted on custom servers, you can validate the given URL to detect if it's your server and not e.g. google.com. To enable validation you can override the function `validateServer`
96 94
97```js 95```js
98// RocketChat integration 96// RocketChat integration
99module.exports = Ferdi => class RocketChat extends Ferdi { 97module.exports = (Ferdi) =>
100 async validateUrl(url) { 98 class RocketChat extends Ferdi {
101 try { 99 async validateUrl(url) {
102 const resp = await window.fetch(`${url}/api/info`, { 100 try {
103 method: 'GET', 101 const resp = await window.fetch(`${url}/api/info`, {
104 headers: { 102 method: "GET",
105 'Content-Type': 'application/json', 103 headers: {
106 }, 104 "Content-Type": "application/json",
107 }); 105 },
108 const data = await resp.json(); 106 });
109 107 const data = await resp.json();
110 return Object.hasOwnProperty.call(data, 'version'); 108
111 } catch (err) { 109 return Object.hasOwnProperty.call(data, "version");
112 console.error(err); 110 } catch (err) {
111 console.error(err);
112 }
113
114 return false;
113 } 115 }
114 116 };
115 return false;
116 }
117};
118``` 117```
119 118
120`validateServer` needs to return a [`Promise`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise), otherwise validation will fail. 119`validateServer` needs to return a [`Promise`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise), otherwise validation will fail.
@@ -156,7 +155,7 @@ module.exports = (Ferdi) => {
156 function getMessages() { 155 function getMessages() {
157 let direct = 0; 156 let direct = 0;
158 let indirect = 0; 157 let indirect = 0;
159 const FerdiData = document.querySelector('#FerdiMessages').dataset; 158 const FerdiData = document.querySelector("#FerdiMessages").dataset;
160 if (FerdiData) { 159 if (FerdiData) {
161 direct = FerdiData.direct; 160 direct = FerdiData.direct;
162 indirect = FerdiData.indirect; 161 indirect = FerdiData.indirect;
@@ -166,7 +165,7 @@ module.exports = (Ferdi) => {
166 } 165 }
167 166
168 Ferdi.loop(getMessages); 167 Ferdi.loop(getMessages);
169} 168};
170``` 169```
171 170
172To get more information about the provided functions, check the [API docs](frontend_api.md). 171To get more information about the provided functions, check the [API docs](frontend_api.md).