mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2025-01-08 14:39:28 -07:00
Put profile name in page title
This commit is contained in:
parent
c36196ef05
commit
ae422ca837
3 changed files with 30 additions and 6 deletions
|
@ -37,27 +37,32 @@ router.get('/sig', (req, res) => {
|
|||
|
||||
router.post('/sig', bodyParser, async (req, res) => {
|
||||
const data = await kx.generateSignatureProfile(req.body.signature)
|
||||
res.render('profile', { data: data, isSignature: true, signature: req.body.signature })
|
||||
const title = kx.utils.generatePageTitle('profile', data)
|
||||
res.render('profile', { title: title, data: data, isSignature: true, signature: req.body.signature })
|
||||
})
|
||||
|
||||
router.get('/wkd/:id', async (req, res) => {
|
||||
const data = await kx.generateWKDProfile(req.params.id)
|
||||
res.render('profile', { data: data })
|
||||
const title = kx.utils.generatePageTitle('profile', data)
|
||||
res.render('profile', { title: title, data: data })
|
||||
})
|
||||
|
||||
router.get('/hkp/:id', async (req, res) => {
|
||||
const data = await kx.generateHKPProfile(req.params.id)
|
||||
res.render('profile', { data: data })
|
||||
const title = kx.utils.generatePageTitle('profile', data)
|
||||
res.render('profile', { title: title, data: data })
|
||||
})
|
||||
|
||||
router.get('/hkp/:server/:id', async (req, res) => {
|
||||
const data = await kx.generateHKPProfile(req.params.id, req.params.server)
|
||||
res.render('profile', { data: data })
|
||||
const title = kx.utils.generatePageTitle('profile', data)
|
||||
res.render('profile', { title: title, data: data })
|
||||
})
|
||||
|
||||
router.get('/keybase/:username/:fingerprint', async (req, res) => {
|
||||
const data = await kx.generateKeybaseProfile(req.params.username, req.params.fingerprint)
|
||||
res.render('profile', { data: data })
|
||||
const title = kx.utils.generatePageTitle('profile', data)
|
||||
res.render('profile', { title: title, data: data })
|
||||
})
|
||||
|
||||
router.get('/:id', async (req, res) => {
|
||||
|
@ -67,7 +72,8 @@ router.get('/:id', async (req, res) => {
|
|||
} else {
|
||||
data = await kx.generateHKPProfile(req.params.id)
|
||||
}
|
||||
res.render('profile', { data: data })
|
||||
const title = kx.utils.generatePageTitle('profile', data)
|
||||
res.render('profile', { title: title, data: data })
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
|
|
|
@ -175,3 +175,5 @@ exports.generateWKDProfile = generateWKDProfile
|
|||
exports.generateHKPProfile = generateHKPProfile
|
||||
exports.generateKeybaseProfile = generateKeybaseProfile
|
||||
exports.generateSignatureProfile = generateSignatureProfile
|
||||
|
||||
exports.utils = require('./utils')
|
||||
|
|
|
@ -34,3 +34,19 @@ exports.computeWKDLocalPart = async (message) => {
|
|||
const hash = await openpgp.crypto.hash.sha1(data);
|
||||
return openpgp.util.encodeZBase32(hash);
|
||||
}
|
||||
|
||||
exports.generatePageTitle = (type, data) => {
|
||||
switch (type) {
|
||||
case 'profile':
|
||||
try {
|
||||
return `${data.keyData.users[data.keyData.primaryUserIndex].userData.name} - Keyoxide`
|
||||
} catch (error) {
|
||||
return 'Profile - Keyoxide'
|
||||
}
|
||||
break
|
||||
|
||||
default:
|
||||
return 'Keyoxide'
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue