From 13b4730b00d4e7186b407984d85ffd66a909d743 Mon Sep 17 00:00:00 2001 From: Ravnoor Gill Date: Fri, 11 Sep 2020 19:38:10 +0000 Subject: [PATCH] Added support for self-hosted instances (#1) * added support for self-hosted instances * replace subdomain variable with domain Co-authored-by: Tom Moor --- README.md | 6 +++--- index.js | 10 ++++++---- info.plist | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f80c048..bd3330b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # alfred-outline -An Alfred workflow to search your team Outline from the comfort of your desktop. +An Alfred workflow to search your team Outline from the comfort of your desktop. Simply type your keyword into Alfred (default: ou) to see instant search results from your Outline knowledge base. Selecting a search result takes you directly to that Outline document in your default web browser. @@ -20,8 +20,8 @@ $ npm install --global alfred-outline ## Workflow Variables -- `apiToken`: Grab a personal API token from the settings page in Outline: https://www.getoutline.com/settings/tokens -- `subdomain`: This should be your just your teams Outline subdomain, whatever is listed between the protocol and getoutline.com in your browsers address bar: https://\.getoutline.com +- `apiToken`: Grab a personal API token from the settings page in Outline: `https://www.getoutline.com/settings/tokens` or `https://\/settings/tokens` +- `domain`: This should be your just your teams Outline domain (`\.getoutline.com`) for getoutline.com managed instances and `https://\` for self-hosted instances. ## Usage diff --git a/index.js b/index.js index a43f916..6cf473f 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,9 @@ const path = require('path'); const alfy = require('alfy'); -const results = await alfy.fetch(`https://www.getoutline.com/api/documents.search`, { +const protocolAndHost = `https://${process.env.domain || "app.getoutline.com"}`; + +const results = await alfy.fetch(`${protocolAndHost}/api/documents.search`, { method: "POST", headers: { Authorization: `Bearer ${process.env.apiToken}`, @@ -15,7 +17,7 @@ const results = await alfy.fetch(`https://www.getoutline.com/api/documents.searc let items = results.data.map(result => ({ title: result.document.title, subtitle: result.context.replace(/\<\/?b\>/g, ''), - arg: `https://${process.env.subdomain || "www"}.getoutline.com${result.document.url}`, + arg: `${protocolAndHost}${result.document.url}`, icon: { path: path.join(__dirname, "document.png") } @@ -24,8 +26,8 @@ let items = results.data.map(result => ({ if (!items.length) { items = [{ title: "No results - go to Outline homepage", - arg: `https://${process.env.subdomain || "www"}.getoutline.com/home` + arg: `${protocolAndHost}/home` }]; } -alfy.output(items); \ No newline at end of file +alfy.output(items); diff --git a/info.plist b/info.plist index 41caa62..fc18ff9 100644 --- a/info.plist +++ b/info.plist @@ -125,12 +125,12 @@ apiToken - subdomain + domain variablesdontexport - subdomain + domain apiToken version