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"),
|
let elFormVerify = document.body.querySelector("#form-verify"),
|
||||||
elFormEncrypt = document.body.querySelector("#form-encrypt"),
|
elFormEncrypt = document.body.querySelector("#form-encrypt"),
|
||||||
elFormProofs = document.body.querySelector("#form-proofs"),
|
elFormProofs = document.body.querySelector("#form-proofs"),
|
||||||
elProfileUid = document.body.querySelector("#profileUid");
|
elProfileUid = document.body.querySelector("#profileUid"),
|
||||||
|
elProfileMode = document.body.querySelector("#profileMode");
|
||||||
|
|
||||||
if (elFormVerify) {
|
if (elFormVerify) {
|
||||||
elFormVerify.onsubmit = function (evt) {
|
elFormVerify.onsubmit = function (evt) {
|
||||||
|
@ -583,18 +584,31 @@ if (elFormProofs) {
|
||||||
|
|
||||||
if (elProfileUid) {
|
if (elProfileUid) {
|
||||||
let match, opts, profileUid = elProfileUid.innerHTML;
|
let match, opts, profileUid = elProfileUid.innerHTML;
|
||||||
if (/.*@.*/.test(profileUid)) {
|
switch (elProfileMode.innerHTML) {
|
||||||
// Match email for wkd
|
default:
|
||||||
opts = {
|
case "auto":
|
||||||
input: profileUid,
|
if (/.*@.*/.test(profileUid)) {
|
||||||
mode: "wkd"
|
// Match email for wkd
|
||||||
}
|
opts = {
|
||||||
} else {
|
input: profileUid,
|
||||||
// Match fingerprint for hkp
|
mode: "wkd"
|
||||||
opts = {
|
}
|
||||||
input: profileUid,
|
} else {
|
||||||
mode: "hkp"
|
// Match fingerprint for hkp
|
||||||
}
|
opts = {
|
||||||
|
input: profileUid,
|
||||||
|
mode: "hkp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case: "hkp":
|
||||||
|
case: "wkd":
|
||||||
|
opts = {
|
||||||
|
input: profileUid,
|
||||||
|
mode: elProfileMode.innerHTML
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
displayProfile(opts);
|
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', '/guides/[:id]', function() {}, 'guideId');
|
||||||
$router->map('GET', '/faq', function() {}, 'faq');
|
$router->map('GET', '/faq', function() {}, 'faq');
|
||||||
$router->map('GET', '/[**:uid]', function() {}, 'profile');
|
$router->map('GET', '/[**:uid]', function() {}, 'profile');
|
||||||
|
$router->map('GET', '/hkp/[**:uid]', function() {}, 'profile/HKP');
|
||||||
|
$router->map('GET', '/wkd/[**:uid]', function() {}, 'profileWKD');
|
||||||
|
|
||||||
// Router matching
|
// Router matching
|
||||||
$match = $router->match();
|
$match = $router->match();
|
||||||
|
@ -93,6 +95,23 @@ if(is_array($match) && is_callable($match['target'])) {
|
||||||
case 'profile':
|
case 'profile':
|
||||||
$content = file_get_contents('pages/profile.html');
|
$content = file_get_contents('pages/profile.html');
|
||||||
$content = str_replace('%UID%', $match['params']['uid'], $content);
|
$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');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
echo($content);
|
echo($content);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
<h1 id="profileName"></h1>
|
<h1 id="profileName"></h1>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<span id="profileUid" style="display: none;">%UID%</span>
|
<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 id="profileData"><p>Loading keys & verifying proofs…</p></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue