join: migrate registration form to Forgejo backend #22

Merged
ayakael merged 1 commit from migrate-registration-forgejo into main 2025-04-03 22:41:46 +00:00
7 changed files with 103 additions and 21 deletions

View file

@ -46,6 +46,7 @@ add_plugins:
- typography - typography
- sidebar2 - sidebar2
- po - po
- inline
# plugins to disable # plugins to disable
disable_plugins: disable_plugins:
- htmlscrubber - htmlscrubber

Binary file not shown.

View file

@ -7,19 +7,20 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: ilot.io\n" "Project-Id-Version: ilot.io\n"
"POT-Creation-Date: 2024-10-08 11:35-0400\n" "POT-Creation-Date: 2025-04-03 18:26-0400\n"
"PO-Revision-Date: 2024-10-08 11:29-0400\n" "PO-Revision-Date: 2025-04-03 18:36-0400\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: dev@ayakael.net\n" "Language-Team: dev@ayakael.net\n"
"Language: fr\n" "Language: fr\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.4.3\n" "X-Generator: Poedit 3.5\n"
#. type: Content of: outside any tag (error?) #. type: Content of: outside any tag (error?)
msgid "[[!meta title=\"Join\"]]" msgid "[[!meta title=\"Join\"]] [[!inline pages=\"join/join-en\" raw=\"yes\"]]"
msgstr "[[!meta title=\"Se joindre\"]]" msgstr ""
"[[!meta title=\"Se joindre\"]] [[!inline pages=\"join/join-fr\" raw=\"yes\"]]"
#. type: Content of: <header><h1> #. type: Content of: <header><h1>
msgid "Registration Form" msgid "Registration Form"
@ -220,6 +221,9 @@ msgstr ""
"maxlength=\"50\"></p> <input type=\"button\" value=\"Soumettre\" id = " "maxlength=\"50\"></p> <input type=\"button\" value=\"Soumettre\" id = "
"\"submit\" onClick = \"createIssue()\"> </form>" "\"submit\" onClick = \"createIssue()\"> </form>"
#~ msgid "[[!meta title=\"Join\"]]"
#~ msgstr "[[!meta title=\"Se joindre\"]]"
#~ msgid "" #~ msgid ""
#~ "async function checkDuplicate() { var url='https://lab.ilot.io/api/v4/" #~ "async function checkDuplicate() { var url='https://lab.ilot.io/api/v4/"
#~ "projects/99/issues'; var email = document.getElementById(\"email\")." #~ "projects/99/issues'; var email = document.getElementById(\"email\")."

View file

@ -1,6 +1,6 @@
[[!meta title="Join"]] [[!meta title="Join"]]
<script src="../js/join.js"></script> [[!inline pages="join/join-en" raw="yes"]]
<header class="text-center"> <header class="text-center">
<h1 class="post-title">Registration Form</h1> <h1 class="post-title">Registration Form</h1>

View file

@ -7,7 +7,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-10-08 11:35-0400\n" "POT-Creation-Date: 2025-04-03 18:27-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,7 +17,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#. type: Content of: outside any tag (error?) #. type: Content of: outside any tag (error?)
msgid "[[!meta title=\"Join\"]]" msgid "[[!meta title=\"Join\"]] [[!inline pages=\"join/join-en\" raw=\"yes\"]]"
msgstr "" msgstr ""
#. type: Content of: <header><h1> #. type: Content of: <header><h1>

View file

@ -1,10 +1,11 @@
<script>
async function checkDuplicate() { async function checkDuplicate() {
var url='https://lab.ilot.io/api/v4/projects/99/issues'; var url='https://forge.ilot.io/api/v1/repos/ilot/registration/issues';
var email = document.getElementById("email").value; var email = document.getElementById("email").value;
const response = await fetch(url, { const response = await fetch(url, {
headers: { headers: {
'PRIVATE-TOKEN': 'glpat-RaoZSW_3XMhkGr19k6Wv', 'authorization': 'token b8d8617bb6049c0e47b7bba5cd0931799f54609c',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
}) })
@ -20,28 +21,28 @@
} }
async function createIssue() { async function createIssue() {
var baseurl = 'https://lab.ilot.io/api/v4/projects/99/issues?&labels=Request'; var url = 'https://forge.ilot.io/api/v1/repos/ilot/registration/issues';
var mathspamtrap = document.getElementById("math-spam-trap").value; var mathspamtrap = document.getElementById("math-spam-trap").value;
var agreetoterms = document.getElementById("agree-to-terms").checked; var agreetoterms = document.getElementById("agree-to-terms").checked;
var email = document.getElementById("email").value; var email = document.getElementById("email").value;
if(!agreetoterms) { if(!agreetoterms) {
alert("Registration requires agreement of Code of Conduct"); alert("Registration requires agreement of Code of Conduct.");
return false; return false;
} }
if(!email) { if(!email) {
alert("Email cannot be empty"); alert("Email cannot be empty.");
return false; return false;
} }
if(mathspamtrap != "9") { if(mathspamtrap != "9") {
alert("Wrong math answer"); alert("Wrong math answer.");
return false; return false;
} }
if(await checkDuplicate(email) === true) { if(await checkDuplicate(email) === true) {
alert("This email address has already requested an account"); alert("This email address has already requested an account.");
return false; return false;
} }
@ -49,29 +50,28 @@
var name = name.replace (/^/,'Name: '); var name = name.replace (/^/,'Name: ');
var aboutme = document.getElementById("about-me").value; var aboutme = document.getElementById("about-me").value;
var aboutme = aboutme.replace (/^/,'About me: '); var aboutme = aboutme.replace (/^/,'About me: ');
var aboutme = aboutme.replace(/\r?\n/g, "%0A%0A");
var howfound = document.getElementById("how-found").value; var howfound = document.getElementById("how-found").value;
var howfound = howfound.replace (/^/,'How I found ilot: '); var howfound = howfound.replace (/^/,'How I found ilot: ');
var howfound = howfound.replace(/\r?\n/g, "%0A%0A");
var ocuser = document.getElementById("oc-user").value; var ocuser = document.getElementById("oc-user").value;
var ocuser = ocuser.replace (/^/,'OpenCollective Profile: '); var ocuser = ocuser.replace (/^/,'OpenCollective Profile: ');
var description = name + "%0A%0A" + aboutme + "%0A%0A" + howfound + "%0A%0A" + ocuser; var description = name + "\n\n" + aboutme + "\n\n" + howfound + "\n\n" + ocuser;
var url = baseurl.concat("&title=", email, "&description=", description);
console.log('Description:', description); console.log('Description:', description);
fetch(url, { fetch(url, {
method: 'POST', method: 'POST',
headers: { headers: {
'PRIVATE-TOKEN': 'glpat-RaoZSW_3XMhkGr19k6Wv', 'authorization': 'token b8d8617bb6049c0e47b7bba5cd0931799f54609c',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify({ title: email, body: description }),
}) })
.then(response => response.json()) .then(response => response.json())
.then(result => { .then(result => {
console.log('Success:', result); console.log('Success:', result);
alert("Request submitted. A working group member will process your registration shortly. If you receive no contact within seven days of registration, please send an email to support@ilot.io"); alert("Request submitted. A working group member will process your registration shortly. If you receive no contact within seven days of registration, please send an email to support@ilot.io.");
}) })
.catch(error => { .catch(error => {
console.error('Error:', error) console.error('Error:', error)
}); });
} }
</script>

77
join/join-fr.html Normal file
View file

@ -0,0 +1,77 @@
<script>
async function checkDuplicate() {
var url='https://forge.ilot.io/api/v1/repos/ilot/registration/issues';
var email = document.getElementById("email").value;
const response = await fetch(url, {
headers: {
'authorization': 'token b8d8617bb6049c0e47b7bba5cd0931799f54609c',
'Content-Type': 'application/json',
},
})
const result = await response.json();
let index = result
.findIndex(item => item.title === email);
if (index !== -1) {
return true;
} else {
return false;
}
}
async function createIssue() {
var url = 'https://forge.ilot.io/api/v1/repos/ilot/registration/issues';
var mathspamtrap = document.getElementById("math-spam-trap").value;
var agreetoterms = document.getElementById("agree-to-terms").checked;
var email = document.getElementById("email").value;
if(!agreetoterms) {
alert("Vous devez être en accord avec notre code de conduite.");
return false;
}
if(!email) {
alert("Le courriel ne peut pas être vide.");
return false;
}
if(mathspamtrap != "9") {
alert("Ceci n'est pas la bonne réponse à l'exercise mathématique.");
return false;
}
if(await checkDuplicate(email) === true) {
alert("Ce courriel a déjà fait l'objet d'une demande de compte.");
return false;
}
var name = document.getElementById("name").value;
var name = name.replace (/^/,'Name: ');
var aboutme = document.getElementById("about-me").value;
var aboutme = aboutme.replace (/^/,'About me: ');
var howfound = document.getElementById("how-found").value;
var howfound = howfound.replace (/^/,'How I found ilot: ');
var ocuser = document.getElementById("oc-user").value;
var ocuser = ocuser.replace (/^/,'OpenCollective Profile: ');
var description = name + "\n\n" + aboutme + "\n\n" + howfound + "\n\n" + ocuser;
console.log('Description:', description);
fetch(url, {
method: 'POST',
headers: {
'authorization': 'token b8d8617bb6049c0e47b7bba5cd0931799f54609c',
'Content-Type': 'application/json',
},
body: JSON.stringify({ title: email, body: description }),
})
.then(response => response.json())
.then(result => {
console.log('Success:', result);
alert("Votre demande a été soumise. Un membre d'un groupe de travail va traiter votre demande sous peu. Si vous ne recevez pas de nouvelle d'ici sept jours, contactez-vous via support@ilot.io.");
})
.catch(error => {
console.error('Error:', error)
});
}
</script>