Skip to content

Commit

Permalink
Improvements for Provider File Generator page
Browse files Browse the repository at this point in the history
  • Loading branch information
cal0pteryx committed Dec 5, 2023
1 parent 2ea6c43 commit 4fb8b88
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 57 deletions.
2 changes: 1 addition & 1 deletion content/provider-file-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ https://example.org/.well-known/provider-v1.json

If you are an admin of a provider, and you plan to make additional data available to the XMPP Providers project, this generator is for you.

Fill out the form below and click 'Generate' at the bottom to create and download your own Provider File.
Fill out the form below and click **Generate Provider File** at the bottom to create and download your own provider file.

{{< provider-file-generator >}}
109 changes: 53 additions & 56 deletions themes/xmpp-providers/static/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
// SPDX-License-Identifier: AGPL-3.0-or-later

const providers_data_form_properties = [
{
name: "website",
type: "dictionary-language-website",
title: "Website",
dataDescription:
"Provider website (per language). Language codes are two-letter (639-1).",
},
{
name: "busFactor",
type: "integer",
Expand All @@ -17,24 +24,11 @@ const providers_data_form_properties = [
dataDescription: "True if company, otherwise false.",
},
{
name: "freeOfCharge",
type: "boolean",
title: "Free of Charge",
dataDescription: "True if unpaid service, otherwise false.",
},
{
name: "legalNotice",
name: "passwordReset",
type: "dictionary-language-website",
title: "Legal Notice",
dataDescription:
"Legal notice website (per language). Language codes are two-letter (639-1).",
},
{
name: "maximumHttpFileUploadStorageTime",
type: "integer",
title: "Maximum HTTP File Upload Storage Time",
title: "Password Reset",
dataDescription:
"Number in days, 0 for no limit or -1 for less than 1 day.",
"Password reset website (per language). Language codes are two-letter (639-1). Website should contain infos about automatic password reset (e.g., via email) / web page describing how to manually reset password (e.g., by contacting the provider).",
},
{
name: "maximumHttpFileUploadTotalSize",
Expand All @@ -44,18 +38,18 @@ const providers_data_form_properties = [
"Number in megabytes (MB), 0 for no limit or -1 for less than 1 MB.",
},
{
name: "maximumMessageArchiveManagementStorageTime",
name: "maximumHttpFileUploadStorageTime",
type: "integer",
title: "Maximum Message Archive Management Storage Time",
title: "Maximum HTTP File Upload Storage Time",
dataDescription:
"Number in days, 0 for no limit or -1 for less than 1 day.",
},
{
name: "passwordReset",
type: "dictionary-language-website",
title: "Password Reset",
name: "maximumMessageArchiveManagementStorageTime",
type: "integer",
title: "Maximum Message Archive Management Storage Time",
dataDescription:
"Password reset website (per language). Language codes are two-letter (639-1). Website should contain infos about automatic password reset (e.g., via email) / web page describing how to manually reset password (e.g., by contacting the provider).",
"Number in days, 0 for no limit or -1 for less than 1 day.",
},
{
name: "professionalHosting",
Expand All @@ -64,6 +58,19 @@ const providers_data_form_properties = [
dataDescription:
"True if hosted with good internet connection speed, uninterruptible power supply, access protection and regular backups, otherwise false.",
},
{
name: "freeOfCharge",
type: "boolean",
title: "Free of Charge",
dataDescription: "True if unpaid service, otherwise false.",
},
{
name: "legalNotice",
type: "dictionary-language-website",
title: "Legal Notice",
dataDescription:
"Legal notice website (per language). Language codes are two-letter (639-1).",
},
{
name: "serverLocations",
type: "list-language-string",
Expand All @@ -76,13 +83,6 @@ const providers_data_form_properties = [
title: "Since",
dataDescription: "Date since the provider is available or listed for.",
},
{
name: "website",
type: "dictionary-language-website",
title: "Website",
dataDescription:
"Provider website (per language). Language codes are two-letter (639-1).",
},
];

document.addEventListener("DOMContentLoaded", (event) => {
Expand Down Expand Up @@ -206,7 +206,7 @@ function _on_add_language_entry_clicked(event) {

function _add_language_entry(property_name) {
const input_row = document.createElement("div");
input_row.classList.add("row", "align-items-end", "mb-3");
input_row.classList.add("row", "g-2", "align-items-end", "mb-3");

const language_col = document.createElement("div");
language_col.classList.add("col-4");
Expand All @@ -219,7 +219,7 @@ function _add_language_entry(property_name) {

const language_select = document.createElement("select");
language_select.id = `property-language-${property_name}-${language_select_id}`;
language_select.classList.add("form-select");
language_select.classList.add("form-select", "form-select-sm");

const default_option = document.createElement("option");
default_option.value = "placeholder";
Expand Down Expand Up @@ -248,7 +248,7 @@ function _add_language_entry(property_name) {

const website_input = document.createElement("input");
website_input.id = `property-website-${property_name}-${website_input_id}`;
website_input.classList.add("form-control");
website_input.classList.add("form-control", "form-control-sm");
website_input.placeholder = "https://example.org/page";
website_input.type = "url";
website_input.pattern = "https://.*";
Expand All @@ -262,7 +262,7 @@ function _add_language_entry(property_name) {
const remove_button = document.createElement("button");
const random_id = _get_random_id();
remove_button.id = `remove_button_${random_id}`;
remove_button.classList.add("btn", "btn-secondary");
remove_button.classList.add("btn", "btn-sm", "btn-secondary");
remove_button.title = "Remove Entry";
remove_button.setAttribute("data-bs-toggle", "tooltip");
remove_button.addEventListener("click", _remove_language_entry);
Expand Down Expand Up @@ -386,38 +386,37 @@ function initialize_provider_data_form() {
const container = document.getElementById(
"provider_file_generator_container"
);
const list_group = document.createElement("ul");
list_group.classList.add("list-group", "pb-3");
container.append(list_group);

for (const property of providers_data_form_properties) {
const list_group_item = document.createElement("li");
list_group_item.classList.add(
"list-group-item",
"pt-3",
"pb-4",
"list-group-item-light"
);
list_group.append(list_group_item);

const heading = document.createElement("b");
heading.classList.add("me-3");
heading.innerHTML = property.title;
list_group_item.append(heading);
const card = document.createElement("div")
card.classList.add("card", "mb-3")

const card_header = document.createElement("div")
card_header.classList.add("card-header")
const heading = document.createElement("b")
heading.innerHTML = property.title
card_header.append(heading)
card.append(card_header)

const card_body = document.createElement("div")
card_body.classList.add("card-body")
card.append(card_body)

container.append(card)

const property_name = document.createElement("code");
property_name.innerHTML = property.name;
list_group_item.append(property_name);
card_body.append(property_name);

const data_description = document.createElement("p");
data_description.classList.add("text-muted", "small");
data_description.innerHTML = property.dataDescription;
list_group_item.append(data_description);
card_body.append(data_description);

const outer_div = document.createElement("div");
outer_div.id = `container-${property.name}`;
outer_div.classList.add("mb-3");
list_group_item.append(outer_div);
card_body.append(outer_div);

if (property.type === "boolean") {
const div = document.createElement("div");
Expand Down Expand Up @@ -455,7 +454,7 @@ function initialize_provider_data_form() {
input.classList.add("form-control");
input.placeholder = "1";
input.type = "number";
input.min = "1";
input.min = "-1";

outer_div.append(label);
outer_div.append(input);
Expand Down Expand Up @@ -493,9 +492,7 @@ function initialize_provider_data_form() {
}

if (property.type === "dictionary-language-website") {
const inner_div = document.createElement("div");
_add_language_entry(property.name);
outer_div.append(inner_div);

// "Add Entry" button
const button_row = document.createElement("div");
Expand All @@ -519,7 +516,7 @@ function initialize_provider_data_form() {
}

const generate_button = document.createElement("button");
generate_button.innerHTML = "Generate JSON File";
generate_button.innerHTML = "Generate Provider File";
generate_button.classList.add("btn", "btn-primary");
generate_button.addEventListener("click", _on_generate_json_file_clicked);
container.append(generate_button);
Expand Down

0 comments on commit 4fb8b88

Please sign in to comment.