mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2024-12-22 23:09:29 -07:00
Allow overriding of profile mode
This commit is contained in:
parent
d8a5a0dd4a
commit
f451619fda
3 changed files with 47 additions and 13 deletions
|
@ -492,7 +492,8 @@ async function fetchKeys(opts) {
|
|||
let elFormVerify = document.body.querySelector("#form-verify"),
|
||||
elFormEncrypt = document.body.querySelector("#form-encrypt"),
|
||||
elFormProofs = document.body.querySelector("#form-proofs"),
|
||||
elProfileUid = document.body.querySelector("#profileUid");
|
||||
elProfileUid = document.body.querySelector("#profileUid"),
|
||||
elProfileMode = document.body.querySelector("#profileMode");
|
||||
|
||||
if (elFormVerify) {
|
||||
elFormVerify.onsubmit = function (evt) {
|
||||
|
@ -583,18 +584,31 @@ if (elFormProofs) {
|
|||
|
||||
if (elProfileUid) {
|
||||
let match, opts, profileUid = elProfileUid.innerHTML;
|
||||
if (/.*@.*/.test(profileUid)) {
|
||||
// Match email for wkd
|
||||
opts = {
|
||||
input: profileUid,
|
||||
mode: "wkd"
|
||||
}
|
||||
} else {
|
||||
// Match fingerprint for hkp
|
||||
opts = {
|
||||
input: profileUid,
|
||||
mode: "hkp"
|
||||
}
|
||||
switch (elProfileMode.innerHTML) {
|
||||
default:
|
||||
case "auto":
|
||||
if (/.*@.*/.test(profileUid)) {
|
||||
// Match email for wkd
|
||||
opts = {
|
||||
input: profileUid,
|
||||
mode: "wkd"
|
||||
}
|
||||
} else {
|
||||
// Match fingerprint for hkp
|
||||
opts = {
|
||||
input: profileUid,
|
||||
mode: "hkp"
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case: "hkp":
|
||||
case: "wkd":
|
||||
opts = {
|
||||
input: profileUid,
|
||||
mode: elProfileMode.innerHTML
|
||||
}
|
||||
break;
|
||||
}
|
||||
displayProfile(opts);
|
||||
}
|
||||
|
|
19
index.php
19
index.php
|
@ -25,6 +25,8 @@ $router->map('GET', '/guides', function() {}, 'guides');
|
|||
$router->map('GET', '/guides/[:id]', function() {}, 'guideId');
|
||||
$router->map('GET', '/faq', function() {}, 'faq');
|
||||
$router->map('GET', '/[**:uid]', function() {}, 'profile');
|
||||
$router->map('GET', '/hkp/[**:uid]', function() {}, 'profile/HKP');
|
||||
$router->map('GET', '/wkd/[**:uid]', function() {}, 'profileWKD');
|
||||
|
||||
// Router matching
|
||||
$match = $router->match();
|
||||
|
@ -93,6 +95,23 @@ if(is_array($match) && is_callable($match['target'])) {
|
|||
case 'profile':
|
||||
$content = file_get_contents('pages/profile.html');
|
||||
$content = str_replace('%UID%', $match['params']['uid'], $content);
|
||||
$content = str_replace('%MODE%', "auto", $content);
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
echo($content);
|
||||
break;
|
||||
|
||||
case 'profileHKP':
|
||||
$content = file_get_contents('pages/profile.html');
|
||||
$content = str_replace('%UID%', $match['params']['uid'], $content);
|
||||
$content = str_replace('%MODE%', "hkp", $content);
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
echo($content);
|
||||
break;
|
||||
|
||||
case 'profileWKD':
|
||||
$content = file_get_contents('pages/profile.html');
|
||||
$content = str_replace('%UID%', $match['params']['uid'], $content);
|
||||
$content = str_replace('%MODE%', "wkd", $content);
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
echo($content);
|
||||
break;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<h1 id="profileName"></h1>
|
||||
<div class="content">
|
||||
<span id="profileUid" style="display: none;">%UID%</span>
|
||||
<span id="profileMode" style="display: none;">%MODE%</span>
|
||||
<div id="profileData"><p>Loading keys & verifying proofs…</p></div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue