From a13daa7ced666f10a262ba2e206f35ccb44ae5d7 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Fri, 19 Jun 2020 17:45:51 +1200 Subject: [PATCH] Add onion location --- package-lock.json | 10 +++++----- package.json | 2 +- src/lib/constants.js | 3 +++ src/site/api/routes.js | 3 ++- src/site/api/stats.js | 7 ++++++- src/site/pug/home.pug | 4 +++- src/site/server.js | 3 ++- 7 files changed, 22 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8ae5adb..24daabb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2738,8 +2738,8 @@ "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==" }, "pinski": { - "version": "github:cloudrac3r/pinski#b062547bc0dcebb82c3aa7da36c13988a68b8acc", - "from": "github:cloudrac3r/pinski#b062547bc0dcebb82c3aa7da36c13988a68b8acc", + "version": "github:cloudrac3r/pinski#7152d86dbf40d8dd9448f9a918d3e6fb76428c6a", + "from": "github:cloudrac3r/pinski#7152d86dbf40d8dd9448f9a918d3e6fb76428c6a", "requires": { "mime": "^2.4.4", "pug": "^2.0.3", @@ -3129,9 +3129,9 @@ "dev": true }, "sass": { - "version": "1.26.7", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.26.7.tgz", - "integrity": "sha512-xgNazdkr6yvgHEfNaOjKtZzhDZmKYMCmoRKMPrTDo7YvjaITIzU2DDYsIUuN/atAg7/JOxPeCQHH7TtCo5Tq2g==", + "version": "1.26.8", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.26.8.tgz", + "integrity": "sha512-yvtzyrKLGiXQu7H12ekXqsfoGT/aTKeMDyVzCB675k1HYuaj0py63i8Uf4SI9CHXj6apDhpfwbUr3gGOjdpu2Q==", "requires": { "chokidar": ">=2.0.0 <4.0.0" } diff --git a/package.json b/package.json index 846238f..3975983 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "mixin-deep": "^2.0.1", "node-dir": "^0.1.17", "node-fetch": "^2.6.0", - "pinski": "github:cloudrac3r/pinski#b062547bc0dcebb82c3aa7da36c13988a68b8acc", + "pinski": "github:cloudrac3r/pinski#7152d86dbf40d8dd9448f9a918d3e6fb76428c6a", "pug": "^2.0.4", "semver": "^7.2.1", "sharp": "^0.25.2", diff --git a/src/lib/constants.js b/src/lib/constants.js index 3a0127f..166ce7a 100644 --- a/src/lib/constants.js +++ b/src/lib/constants.js @@ -20,6 +20,9 @@ let constants = { port: 10407, // You MUST read /src/site/pug/privacy.pug.template before changing has_privacy_policy! has_privacy_policy: false, + // If your instance is also available as an onion site, add the onion URL here. + // It should look something like "http://3gldbgtv5e4god56.onion" (no trailing slash). + onion_location: "http://3gldbgtv5e4god56.onion", // Things that server owners _could_ change if they want to. tor: { diff --git a/src/site/api/routes.js b/src/site/api/routes.js index 84ed6fc..096c877 100644 --- a/src/site/api/routes.js +++ b/src/site/api/routes.js @@ -21,7 +21,8 @@ module.exports = [ rssEnabled: constants.feeds.enabled, allUnblocked: history.testNoneBlocked() || assistantSwitcher.displaySomeUnblocked(), torAvailable: switcher.canUseTor(), - hasPrivacyPolicy: constants.has_privacy_policy + hasPrivacyPolicy: constants.has_privacy_policy, + onionLocation: constants.onion_location }) } }, diff --git a/src/site/api/stats.js b/src/site/api/stats.js index 160a54e..1d66dc5 100644 --- a/src/site/api/stats.js +++ b/src/site/api/stats.js @@ -28,7 +28,7 @@ let commit = "" // Set up inner versioning -const displayVersions = ["1.0", "1.1", "1.2", "1.3", "1.4"] +const displayVersions = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5"] const versions = new Map(displayVersions.map(v => [v, semver.coerce(v)])) const features = [ "PAGE_PROFILE", @@ -78,6 +78,11 @@ const innerMap = new Map() canonicalOrigin: constants.website_origin } }) + addVersion("1.5", { + settings: { + onionLocation: constants.onion_location + } + }) } module.exports = [ diff --git a/src/site/pug/home.pug b/src/site/pug/home.pug index fde8a0c..b5ec2b9 100644 --- a/src/site/pug/home.pug +++ b/src/site/pug/home.pug @@ -1,4 +1,4 @@ -//- Needs rssEnabled, allUnblocked, torAvailable, hasPrivacyPolicy +//- Needs rssEnabled, allUnblocked, torAvailable, hasPrivacyPolicy, onionLocation doctype html html @@ -36,6 +36,8 @@ html h2 About this instance ul + if onionLocation + li: a(href=onionLocation) Onion site available li: a(href=settingsReferrer) Settings if hasPrivacyPolicy li: a(href="/privacy") Privacy policy diff --git a/src/site/server.js b/src/site/server.js index a74b019..f2d0445 100644 --- a/src/site/server.js +++ b/src/site/server.js @@ -22,7 +22,8 @@ const pinski = new Pinski({ "Feature-Policy": deniedFeatures.map(feature => `${feature} 'none'`).join("; "), "Referrer-Policy": "strict-origin", "X-Content-Type-Options": "nosniff" - } + }, + onionLocation: constants.onion_location }) subdirs("pug", async (err, dirs) => {