M README.md => README.md +3 -0
@@ 37,6 37,9 @@ For the JID romeo@xmpp.example, it will create the following page ([live example
* [xmpp:romeo@xmpp.example](https://zachdecook.com/chat?romeo@xmpp.example)
* [xmpp:name@muc.example.com?join](https://zachdecook.com/chat?xmpp:name@muc.example.com?join)
+* Registration with pre-defined account name ([XEP-0445](https://xmpp.org/extensions/xep-0445.html#sect-idm46085194296336)): [xmpp:juliet@example.com?register;preauth=TOKEN](https://zachdecook.com/chat?xmpp:juliet@example.com?register;preauth=TOKEN)
+* Registration on a server ([XEP-0445](https://xmpp.org/extensions/xep-0445.html#sect-idm46085194293584)): [xmpp:example.com?register;preauth=TOKEN](https://zachdecook.com/chat?xmpp:example.com?register;preauth=TOKEN)
+
## Design decisions
M index.php => index.php +11 -1
@@ 22,13 22,23 @@
$action = $lang->chat;
if ( str_contains($uri, '?join') ) {
$action = $lang->muc;
+ } elseif ( str_contains($uri, '?register;') ) {
+ $action = $lang->register;
+ if ( str_contains($uri, "@") ) {
+ $action = $lang->register_name;
+ }
}
- $name = ucfirst(explode("@", substr($uri, 5))[0]);
+ $parsed = parse_url($uri);
+ $name = explode("@", $parsed['path'])[0];
+ $server = explode("@", $parsed['path'])[1] ?? $name;
function t($template) {
GLOBAL $name;
GLOBAL $os;
+ GLOBAL $server;
$template = str_replace('{{name}}', $name, $template);
+ $template = str_replace('{{Name}}', ucfirst($name), $template);
$template = str_replace('{{os}}', $os, $template);
+ $template = str_replace('{{server}}', $server, $template);
return $template;
}
?>
M lang/en.json => lang/en.json +18 -6
@@ 1,14 1,26 @@
{
"chat": {
- "title": "Invitation from {{name}}",
- "heading": "{{name}} has invited you to chat",
- "button": "Add {{name}} to contact list",
+ "title": "Invitation from {{Name}}",
+ "heading": "{{Name}} has invited you to chat",
+ "button": "Add {{Name}} to contact list",
"":""
},
"muc": {
- "title": "Invitation to {{name}}",
- "heading": "You have been invited to {{name}}",
- "button": "Join the chat room {{name}}",
+ "title": "Invitation to {{Name}}",
+ "heading": "You have been invited to {{Name}}",
+ "button": "Join the chat room {{Name}}",
+ "":""
+ },
+ "register": {
+ "title": "Invitation to {{server}}",
+ "heading": "You have been invited to {{server}}",
+ "button": "Register an account on {{server}}",
+ "":""
+ },
+ "register_name": {
+ "title": "Invitation to {{server}}",
+ "heading": "{{Name}}, you have been invited to {{server}}",
+ "button": "Register as {{name}}@{{server}}",
"":""
},
"clients": "You need to install an XMPP client to access the XMPP network.",
M stylesheets/styles.css => stylesheets/styles.css +1 -1
@@ 4,7 4,7 @@
margin-bottom: 0;
font-weight: normal;
text-align: center;
- vertical-align: middle; text-transform: uppercase;
+ vertical-align: middle;
border-right: none;
border-bottom: none;
color: #666;