XMPP invitation landing page, without javascript
URIs: Add register URIs
Zach DeCook 2022-06-06
parent 7c1b0f6 · commit dd106c0
-rw-r--r--README.md3
-rw-r--r--index.php12
-rw-r--r--lang/en.json24
-rw-r--r--stylesheets/styles.css2
4 files changed, 33 insertions, 8 deletions
diff --git a/README.md b/README.md
index 76dce38..7213759 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/index.php b/index.php
index b7a0024..6b37a18 100644
--- a/index.php
+++ b/index.php
@@ -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;
}
?>
diff --git a/lang/en.json b/lang/en.json
index 34ba4f8..e5e0677 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -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.",
diff --git a/stylesheets/styles.css b/stylesheets/styles.css
index abdd5f7..9bb82a0 100644
--- a/stylesheets/styles.css
+++ b/stylesheets/styles.css
@@ -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;