From de0c0c0bcbb0c3a31e001263e026efa6a81a1603 Mon Sep 17 00:00:00 2001 From: Iris System Date: Mon, 13 Sep 2021 19:20:42 +1200 Subject: [PATCH 01/11] phonebook: add kayw@tilde.team --- _data/phonebook.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/_data/phonebook.yml b/_data/phonebook.yml index 292f1ff..e1f923d 100644 --- a/_data/phonebook.yml +++ b/_data/phonebook.yml @@ -63,6 +63,9 @@ community: - tilde: tilde.team ext: 2013116 name: xfnw + - tilde: tilde.team + ext: 2013121 + name: kayw - tilde: tilde.team ext: 2013123 name: rawktucc From dddbaf8b34a964fb9fb1afa5d45519869469129a Mon Sep 17 00:00:00 2001 From: Iris System Date: Mon, 13 Sep 2021 19:41:02 +1200 Subject: [PATCH 02/11] misc: update gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index a285669..f448bd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ +.env* +.bundle/ +vendor/bundle/ .jekyll-cache/ _site/ From 082f7a99e4659cdf3f4b84af4037577dd9fe0960 Mon Sep 17 00:00:00 2001 From: Iris System Date: Mon, 13 Sep 2021 19:41:38 +1200 Subject: [PATCH 03/11] Add links to registration form --- _includes/nav.html | 3 ++- index.html | 3 ++- phonebook/index.html | 11 ++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/_includes/nav.html b/_includes/nav.html index 2cef319..5f58903 100644 --- a/_includes/nav.html +++ b/_includes/nav.html @@ -1,7 +1,8 @@ diff --git a/index.html b/index.html index 1dd7fd6..a509960 100644 --- a/index.html +++ b/index.html @@ -2,11 +2,12 @@ layout: base --- -
+

☎️ {{ site.name }} ☎️

diff --git a/phonebook/index.html b/phonebook/index.html index f8fb450..0e201a7 100644 --- a/phonebook/index.html +++ b/phonebook/index.html @@ -27,13 +27,10 @@ title: phonebook

The community

- To get a tel.tilde.org.nz number, please message darcy - in #tildetel on the tilde.chat IRC. -

-

- If you had a tilde.tel number, in most cases, you can use that number - on tel.tilde.org.nz! Just let darcy know when asking for - an account. + Want a tel.tilde.org.nz number? + + Click here for the registration form! +

From ee30063de627f85c8497b7f590e14a35239e4e61 Mon Sep 17 00:00:00 2001 From: Iris System Date: Mon, 13 Sep 2021 19:41:59 +1200 Subject: [PATCH 04/11] styles: properly pin footer to page end --- _sass/index.scss | 5 ----- styles.scss | 6 ++++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/_sass/index.scss b/_sass/index.scss index 0dd8aa3..d7abe2c 100644 --- a/_sass/index.scss +++ b/_sass/index.scss @@ -1,10 +1,5 @@ .index-container { - height: 100%; - min-height: 100vh; - width: 100%; - max-width: 100vw; - display: flex; flex-flow: column wrap; align-items: center; diff --git a/styles.scss b/styles.scss index b1bef14..0790f6a 100644 --- a/styles.scss +++ b/styles.scss @@ -16,6 +16,9 @@ body max-width: 100vw; width: auto; + display: flex; + flex-direction: column; + margin: 0; padding: 0; @@ -35,10 +38,9 @@ a .container { - height: 100%; - min-height: 100vh; width: 100%; max-width: 100vw; + flex: 1; padding: 1rem; } From 460f4dcbb9d5b7d0d57989bfbc149275d8568530 Mon Sep 17 00:00:00 2001 From: Iris System Date: Fri, 1 Oct 2021 14:02:41 +1300 Subject: [PATCH 05/11] phonebook: add some more people! --- _data/phonebook.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/_data/phonebook.yml b/_data/phonebook.yml index e1f923d..4ffcceb 100644 --- a/_data/phonebook.yml +++ b/_data/phonebook.yml @@ -75,12 +75,18 @@ community: - tilde: tilde.team ext: 2013125 name: forero + - tilde: tilde.team + ext: 2013126 + name: r1k - tilde: cosmic.voyage ext: 2023101 name: tomasino - tilde: tilde.institute ext: 2033110 name: O4dco + - tilde: tilde.institute + ext: 2033130 + name: rnelson - tilde: thunix.net ext: 2043110 name: Loki @@ -99,12 +105,18 @@ community: - tilde: tilde.town ext: 2063110 name: login + - tilde: tilde.town + ext: 2063120 + name: kat - tilde: tilde.club ext: 2123103 name: deepend - tilde: tilde.club ext: 2123106 name: alex11 + - tilde: tilde.club + ext: 2123120 + name: dokoissho - tilde: tilde.org.nz ext: 2163101 name: darcy From 7549db936041e621c5cf73897e72a03fef6911f8 Mon Sep 17 00:00:00 2001 From: Iris System Date: Fri, 1 Oct 2021 14:26:59 +1300 Subject: [PATCH 06/11] nix: add shell.nix --- shell.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..7f014a9 --- /dev/null +++ b/shell.nix @@ -0,0 +1,27 @@ +{ pkgs ? import {}, lib ? pkgs.lib }: + +with lib; + +let + neededLibraries = with pkgs; [ + curl + libxml2 + libxslt + ]; + +in +pkgs.mkShell { + buildInputs = with pkgs; [ + ruby + bundler + + pkg-config + shared-mime-info + cacert + ] ++ neededLibraries; + + "LD_LIBRARY_PATH" = makeLibraryPath neededLibraries; + "SSL_CERT_DIR" = "${pkgs.cacert}/etc/ssl/certs"; + "SSL_CERT_FILE" = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; + "FREEDESKTOP_MIME_TYPES_PATH" = "${pkgs.shared-mime-info}/share/mime/packages/freedesktop.org.xml"; +} From d009b6e266e25cc9f48e0d5242aa472a0f554b04 Mon Sep 17 00:00:00 2001 From: Iris System Date: Fri, 15 Oct 2021 20:44:55 +1300 Subject: [PATCH 07/11] add placeholder registration page This page will only ever be displayed if the main registration subsite is unavailable for some reason (because the /register path is overridden in the nginx config on the actual ~tel server). --- register/index.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 register/index.md diff --git a/register/index.md b/register/index.md new file mode 100644 index 0000000..3e78f59 --- /dev/null +++ b/register/index.md @@ -0,0 +1,12 @@ +--- +layout: page +title: register for tel.tilde.org.nz +--- + +Registrations for `tel.tilde.org.nz` +are currently unavailable. + +Please check back later, +or ask in `#tildetel` +on [tilde.chat](https://tilde.chat) +for more details. From 1914b0d589c6784403d7f46cb5e3b000de9e2997 Mon Sep 17 00:00:00 2001 From: Iris System Date: Thu, 25 Nov 2021 21:13:05 +1300 Subject: [PATCH 08/11] misc: update dependencies --- Gemfile.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index aac5691..ea75b1a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,20 +1,20 @@ GEM remote: https://rubygems.org/ specs: - addressable (2.7.0) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) colorator (1.1.0) concurrent-ruby (1.1.9) - em-websocket (0.5.2) + em-websocket (0.5.3) eventmachine (>= 0.12.9) - http_parser.rb (~> 0.6.0) + http_parser.rb (~> 0) eventmachine (1.2.7) - ffi (1.15.1) + ffi (1.15.4) forwardable-extended (2.6.0) - http_parser.rb (0.6.0) - i18n (1.8.10) + http_parser.rb (0.8.0) + i18n (1.8.11) concurrent-ruby (~> 1.0) - jekyll (4.2.0) + jekyll (4.2.1) addressable (~> 2.4) colorator (~> 1.0) em-websocket (~> 0.5) @@ -38,7 +38,7 @@ GEM kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) liquid (4.0.3) - listen (3.5.1) + listen (3.7.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) mercenary (0.4.0) @@ -49,19 +49,19 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) rexml (3.2.5) - rouge (3.26.0) + rouge (3.26.1) safe_yaml (1.0.5) sassc (2.4.0) ffi (~> 1.9) terminal-table (2.0.0) unicode-display_width (~> 1.1, >= 1.1.1) - unicode-display_width (1.7.0) + unicode-display_width (1.8.0) PLATFORMS - ruby + x86_64-darwin-17 DEPENDENCIES jekyll BUNDLED WITH - 2.1.4 + 2.2.24 From 2ba153abac61aa6c415ef2033d6157ed5ec06be4 Mon Sep 17 00:00:00 2001 From: Iris System Date: Thu, 25 Nov 2021 21:13:21 +1300 Subject: [PATCH 09/11] styles: add form styling for upcoming registration page --- _sass/form.scss | 32 ++++++++++++++++++++++++++++++++ _sass/utils.scss | 8 ++++++++ styles.scss | 1 + 3 files changed, 41 insertions(+) create mode 100644 _sass/form.scss diff --git a/_sass/form.scss b/_sass/form.scss new file mode 100644 index 0000000..b1824e6 --- /dev/null +++ b/_sass/form.scss @@ -0,0 +1,32 @@ +.form +{ + width: 100%; + margin: 0 0 1rem 0; +} + +.form input:not([type = "checkbox"]), +.form select, +.form button, +.form textarea +{ + display: block; + width: 100%; + padding: 0.25rem; + margin-bottom: 0.5rem; + border: 1px solid #000; + border-radius: 3px; +} + +.form-captcha +{ + margin: 1rem 0; + padding: 1rem; + border: 1px solid #000; + border-radius: 3px; + + .form-captcha-img + { + display: block; + margin: 1rem 0; + } +} diff --git a/_sass/utils.scss b/_sass/utils.scss index 0edb8b7..c193adf 100644 --- a/_sass/utils.scss +++ b/_sass/utils.scss @@ -18,3 +18,11 @@ } } } + +.banner +{ + width: 100%; + padding: 0.5rem 1rem; + border: 1px solid #000; + border-radius: 3px; +} diff --git a/styles.scss b/styles.scss index 0790f6a..1c53e18 100644 --- a/styles.scss +++ b/styles.scss @@ -48,5 +48,6 @@ a @import 'nav'; @import 'footer'; @import 'table'; +@import 'form'; @import 'utils'; @import 'index'; From bfdcfd827e082ca0ebe86857dcb9d70530546aba Mon Sep 17 00:00:00 2001 From: Iris System Date: Thu, 25 Nov 2021 21:13:41 +1300 Subject: [PATCH 10/11] layouts: add support to base layout for starting a PHP session --- _layouts/base.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/_layouts/base.html b/_layouts/base.html index 25a61a9..5944d67 100644 --- a/_layouts/base.html +++ b/_layouts/base.html @@ -1,4 +1,7 @@ - +{%- if page.php_session -%}{%- endif -%} From 57326ec6c53db19105daa80648eed610bcb7661e Mon Sep 17 00:00:00 2001 From: Iris System Date: Thu, 25 Nov 2021 21:15:31 +1300 Subject: [PATCH 11/11] register: add registration PHP page --- _config.yml | 5 ++ register/register.php | 111 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 register/register.php diff --git a/_config.yml b/_config.yml index 2dce671..a279b27 100644 --- a/_config.yml +++ b/_config.yml @@ -3,6 +3,11 @@ description: neo-tildetel - a PBX for the tildeverse url: https://tel.tilde.org.nz baseurl: '' +smolcaptcha_url: "https://httpbin.org/status/418" +smolcaptcha_client: "" +register_hook: "https://httpbin.org/status/418" +register_hook_secret: "" + kramdown: smart_quotes: apos,apos,quot,quot typographic_symbols: diff --git a/register/register.php b/register/register.php new file mode 100644 index 0000000..6927a82 --- /dev/null +++ b/register/register.php @@ -0,0 +1,111 @@ +--- +layout: page +title: register for tel.tilde.org.nz +php_session: true +--- + +'; + if (!is_null($message)) { + echo "An error occurred: {$message}"; + } else { + echo "An unknown error occurred."; + } + echo ''; + exit; +} + +function verify_captcha(string $result): bool { + $ch = curl_init("{{ site.smolcaptcha_url }}/api/verify"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, [ + "client" => "{{ site.smolcaptcha_client }}", + "captcha" => $_SESSION['captcha'], + "result" => $result, + ]); + + $resp = curl_exec($ch); + curl_close($ch); + + return ($resp !== null && trim($resp) === "ok"); +} + +if (!array_key_exists("captcha", $_SESSION) || is_null($_SESSION['captcha'])) { + $ch = curl_init("{{ site.smolcaptcha_url }}/api/generate"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, [ + "client" => "{{ site.smolcaptcha_client }}", + ]); + + $resp = curl_exec($ch); + curl_close($ch); + + if ($resp === false) exit_with_banner("CAPTCHA request failed, please alert darcy in #tildetel"); + $_SESSION['captcha'] = $resp; +} + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $form_user = array_key_exists('user', $_POST) ? trim($_POST['user']) : null; + $form_tilde = array_key_exists('tilde', $_POST) ? trim($_POST['tilde']) : null; + $form_msg = array_key_exists('msg', $_POST) ? trim($_POST['msg']) : "(no message)"; + + if ($form_user === null || $form_user === "" || $form_tilde === null || $form_tilde === "") { + exit_with_banner("A required field was not provided."); + } + + $captcha = array_key_exists('captcha', $_POST) ? trim($_POST['captcha']) : ""; + if (!verify_captcha($captcha)) { + exit_with_banner("CAPTCHA verification failed"); + } + + $ch = curl_init("{{ site.register_hook }}"); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, [ + "secret" => "{{ site.register_hook_secret }}", + "user" => $form_user, + "tilde" => $form_tilde, + "msg" => $form_msg, + ]); + + $resp = curl_exec($ch); + curl_close($ch); + + unset($_SESSION['captcha']); + + if (!$resp) { + exit_with_banner("Couldn't submit registration request, please try again"); + } else { + echo ''; + } +} else { +?> + +

If you had an account on the old tilde.tel, please include your previous number in the message field.

+ +
+ + + + + + + + + +
+ + + +
+ + + + +