feat: display version

This commit is contained in:
Yarmo Mackenbach 2023-09-14 12:31:44 +02:00
parent aeee377ea3
commit 8eb90beda2
No known key found for this signature in database
GPG key ID: 3C57D093219103A3
5 changed files with 46 additions and 23 deletions

View file

@ -30,6 +30,7 @@ more information on this, and how to apply and follow the GNU AGPL, see <https:/
import express from 'express' import express from 'express'
import markdownImport from 'markdown-it' import markdownImport from 'markdown-it'
import { readFileSync } from 'fs' import { readFileSync } from 'fs'
import { getMetaFromReq } from '../server/utils.js'
const router = express.Router() const router = express.Router()
const md = markdownImport({ typographer: true }) const md = markdownImport({ typographer: true })
@ -47,13 +48,13 @@ router.get('/', (req, res) => {
} }
} }
res.render('index', { highlights }) res.render('index', { highlights, meta: getMetaFromReq(req) })
}) })
router.get('/privacy', (req, res) => { router.get('/privacy', (req, res) => {
const rawContent = readFileSync('./content/privacy-policy.md', 'utf8') const rawContent = readFileSync('./content/privacy-policy.md', 'utf8')
const content = md.render(rawContent) 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) => { router.get('/.well-known/webfinger', (req, res) => {

View file

@ -31,12 +31,13 @@ import express from 'express'
import bodyParserImport from 'body-parser' import bodyParserImport from 'body-parser'
import { generateSignatureProfile, utils, generateWKDProfile, generateHKPProfile, generateAutoProfile, generateKeybaseProfile } from '../server/index.js' import { generateSignatureProfile, utils, generateWKDProfile, generateHKPProfile, generateAutoProfile, generateKeybaseProfile } from '../server/index.js'
import { Profile } from 'doipjs' import { Profile } from 'doipjs'
import { getMetaFromReq } from '../server/utils.js'
const router = express.Router() const router = express.Router()
const bodyParser = bodyParserImport.urlencoded({ extended: false }) const bodyParser = bodyParserImport.urlencoded({ extended: false })
router.get('/sig', (req, res) => { 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) => { router.post('/sig', bodyParser, async (req, res) => {
@ -49,7 +50,8 @@ router.post('/sig', bodyParser, async (req, res) => {
isSignature: true, isSignature: true,
signature: req.body.signature, signature: req.body.signature,
enable_message_encryption: false, 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, title,
data: data instanceof Profile ? data.toJSON() : data, data: data instanceof Profile ? data.toJSON() : data,
enable_message_encryption: false, 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, title,
data: data instanceof Profile ? data.toJSON() : data, data: data instanceof Profile ? data.toJSON() : data,
enable_message_encryption: false, 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, title,
data: data instanceof Profile ? data.toJSON() : data, data: data instanceof Profile ? data.toJSON() : data,
enable_message_encryption: false, 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, title,
data: data instanceof Profile ? data.toJSON() : data, data: data instanceof Profile ? data.toJSON() : data,
enable_message_encryption: false, 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, title,
data: data instanceof Profile ? data.toJSON() : data, data: data instanceof Profile ? data.toJSON() : data,
enable_message_encryption: false, enable_message_encryption: false,
enable_signature_verification: false enable_signature_verification: false,
meta: getMetaFromReq(req)
}) })
}) })

View file

@ -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 <https://www.gnu.org/licenses/>. more information on this, and how to apply and follow the GNU AGPL, see <https://www.gnu.org/licenses/>.
*/ */
import express from 'express' import express from 'express'
import { getMetaFromReq } from '../server/utils.js'
const router = express.Router() const router = express.Router()
router.get('/', function (req, res) { router.get('/', function (req, res) {
res.render('util/index') res.render('util/index', { meta: getMetaFromReq(req) })
}) })
router.get('/profile-url', function (req, res) { 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) { 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) { router.get('/qr', function (req, res) {
res.render('util/qr') res.render('util/qr', { meta: getMetaFromReq(req) })
}) })
router.get('/qr/:input', function (req, res) { 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) { router.get('/qrfp', function (req, res) {
res.render('util/qrfp') res.render('util/qrfp', { meta: getMetaFromReq(req) })
}) })
router.get('/qrfp/:input', function (req, res) { 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) { router.get('/wkd', function (req, res) {
res.render('util/wkd') res.render('util/wkd', { meta: getMetaFromReq(req) })
}) })
router.get('/wkd/:input', function (req, res) { 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) { router.get('/argon2', function (req, res) {
res.render('util/argon2') res.render('util/argon2', { meta: getMetaFromReq(req) })
}) })
router.get('/argon2/:input', function (req, res) { 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) { router.get('/bcrypt', function (req, res) {
res.render('util/bcrypt') res.render('util/bcrypt', { meta: getMetaFromReq(req) })
}) })
router.get('/bcrypt/:input', function (req, res) { 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 export default router

View file

@ -78,3 +78,12 @@ export function encodeZBase32 (data) {
} }
return result return result
} }
export function getMetaFromReq (req) {
return {
env: req.app.get('env'),
keyoxide: {
version: req.app.get('keyoxide_version')
}
}
}

View file

@ -27,4 +27,9 @@ footer
br br
a(href="https://ariadne.id") ariadne.id a(href="https://ariadne.id") ariadne.id
p.copyright &copy; 2022 Keyoxide project contributors p.copyright
| Version #{meta.keyoxide.version}
if (meta.env === "development")
| -dev
br
| &copy; 2023 Keyoxide project contributors