diff --git a/src/routes/main.js b/src/routes/main.js index 34fb518..d4b165b 100644 --- a/src/routes/main.js +++ b/src/routes/main.js @@ -30,6 +30,7 @@ more information on this, and how to apply and follow the GNU AGPL, see { } } - res.render('index', { highlights }) + res.render('index', { highlights, meta: getMetaFromReq(req) }) }) router.get('/privacy', (req, res) => { const rawContent = readFileSync('./content/privacy-policy.md', 'utf8') const content = md.render(rawContent) - res.render('article', { title: 'Privacy policy', content }) + res.render('article', { title: 'Privacy policy', content, meta: getMetaFromReq(req) }) }) router.get('/.well-known/webfinger', (req, res) => { diff --git a/src/routes/profile.js b/src/routes/profile.js index 78149f5..9211bc5 100644 --- a/src/routes/profile.js +++ b/src/routes/profile.js @@ -31,12 +31,13 @@ import express from 'express' import bodyParserImport from 'body-parser' import { generateSignatureProfile, utils, generateWKDProfile, generateHKPProfile, generateAutoProfile, generateKeybaseProfile } from '../server/index.js' import { Profile } from 'doipjs' +import { getMetaFromReq } from '../server/utils.js' const router = express.Router() const bodyParser = bodyParserImport.urlencoded({ extended: false }) router.get('/sig', (req, res) => { - res.render('profile', { isSignature: true, signature: null }) + res.render('profile', { isSignature: true, signature: null, meta: getMetaFromReq(req) }) }) router.post('/sig', bodyParser, async (req, res) => { @@ -49,7 +50,8 @@ router.post('/sig', bodyParser, async (req, res) => { isSignature: true, signature: req.body.signature, enable_message_encryption: false, - enable_signature_verification: false + enable_signature_verification: false, + meta: getMetaFromReq(req) }) }) @@ -61,7 +63,8 @@ router.get('/wkd/:id', async (req, res) => { title, data: data instanceof Profile ? data.toJSON() : data, enable_message_encryption: false, - enable_signature_verification: false + enable_signature_verification: false, + meta: getMetaFromReq(req) }) }) @@ -73,7 +76,8 @@ router.get('/hkp/:id', async (req, res) => { title, data: data instanceof Profile ? data.toJSON() : data, enable_message_encryption: false, - enable_signature_verification: false + enable_signature_verification: false, + meta: getMetaFromReq(req) }) }) @@ -85,7 +89,8 @@ router.get('/hkp/:server/:id', async (req, res) => { title, data: data instanceof Profile ? data.toJSON() : data, enable_message_encryption: false, - enable_signature_verification: false + enable_signature_verification: false, + meta: getMetaFromReq(req) }) }) @@ -97,7 +102,8 @@ router.get('/keybase/:username/:fingerprint', async (req, res) => { title, data: data instanceof Profile ? data.toJSON() : data, enable_message_encryption: false, - enable_signature_verification: false + enable_signature_verification: false, + meta: getMetaFromReq(req) }) }) @@ -109,7 +115,8 @@ router.get('/:id', async (req, res) => { title, data: data instanceof Profile ? data.toJSON() : data, enable_message_encryption: false, - enable_signature_verification: false + enable_signature_verification: false, + meta: getMetaFromReq(req) }) }) diff --git a/src/routes/util.js b/src/routes/util.js index 84412f6..bc5d207 100644 --- a/src/routes/util.js +++ b/src/routes/util.js @@ -28,52 +28,53 @@ if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . */ import express from 'express' +import { getMetaFromReq } from '../server/utils.js' const router = express.Router() router.get('/', function (req, res) { - res.render('util/index') + res.render('util/index', { meta: getMetaFromReq(req) }) }) router.get('/profile-url', function (req, res) { - res.render('util/profile-url') + res.render('util/profile-url', { meta: getMetaFromReq(req) }) }) router.get('/profile-url/:input', function (req, res) { - res.render('util/profile-url', { input: req.params.input }) + res.render('util/profile-url', { input: req.params.input, meta: getMetaFromReq(req) }) }) router.get('/qr', function (req, res) { - res.render('util/qr') + res.render('util/qr', { meta: getMetaFromReq(req) }) }) router.get('/qr/:input', function (req, res) { - res.render('util/qr', { input: req.params.input }) + res.render('util/qr', { input: req.params.input, meta: getMetaFromReq(req) }) }) router.get('/qrfp', function (req, res) { - res.render('util/qrfp') + res.render('util/qrfp', { meta: getMetaFromReq(req) }) }) router.get('/qrfp/:input', function (req, res) { - res.render('util/qrfp', { input: req.params.input }) + res.render('util/qrfp', { input: req.params.input, meta: getMetaFromReq(req) }) }) router.get('/wkd', function (req, res) { - res.render('util/wkd') + res.render('util/wkd', { meta: getMetaFromReq(req) }) }) router.get('/wkd/:input', function (req, res) { - res.render('util/wkd', { input: req.params.input }) + res.render('util/wkd', { input: req.params.input, meta: getMetaFromReq(req) }) }) router.get('/argon2', function (req, res) { - res.render('util/argon2') + res.render('util/argon2', { meta: getMetaFromReq(req) }) }) router.get('/argon2/:input', function (req, res) { - res.render('util/argon2', { input: req.params.input }) + res.render('util/argon2', { input: req.params.input, meta: getMetaFromReq(req) }) }) router.get('/bcrypt', function (req, res) { - res.render('util/bcrypt') + res.render('util/bcrypt', { meta: getMetaFromReq(req) }) }) router.get('/bcrypt/:input', function (req, res) { - res.render('util/bcrypt', { input: req.params.input }) + res.render('util/bcrypt', { input: req.params.input, meta: getMetaFromReq(req) }) }) export default router diff --git a/src/server/utils.js b/src/server/utils.js index 30884e2..7f0b6e0 100644 --- a/src/server/utils.js +++ b/src/server/utils.js @@ -78,3 +78,12 @@ export function encodeZBase32 (data) { } return result } + +export function getMetaFromReq (req) { + return { + env: req.app.get('env'), + keyoxide: { + version: req.app.get('keyoxide_version') + } + } +} \ No newline at end of file diff --git a/views/partials/footer.pug b/views/partials/footer.pug index 4552fd4..85b7d88 100644 --- a/views/partials/footer.pug +++ b/views/partials/footer.pug @@ -27,4 +27,9 @@ footer br a(href="https://ariadne.id") ariadne.id - p.copyright © 2022 Keyoxide project contributors \ No newline at end of file + p.copyright + | Version #{meta.keyoxide.version} + if (meta.env === "development") + | -dev + br + | © 2023 Keyoxide project contributors \ No newline at end of file