Skip to content

Commit

Permalink
Add greenwebcheck to Overview and Filters
Browse files Browse the repository at this point in the history
  • Loading branch information
cal0pteryx committed Aug 31, 2023
1 parent 072a373 commit f6a7e12
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions themes/xmpp-providers/layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ <h1 class="display-5 fw-bold">It’s Your Choice</h1>
<input class="form-check-input" type="checkbox" id="professional-hosting" name="professional-hosting">
<label class="form-check-label" for="professional-hosting">Professional Hosting</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="rating-green-web-check" name="rating-green-web-check">
<label class="form-check-label" for="rating-green-web-check">Green Hosting</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="in-band-registration" name="in-band-registration">
<label class="form-check-label" for="in-band-registration">Registration via App</label>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ range $index, $content := . }}
{{ $provider_id := replace .jid "." "-" }}
<div class="accordion-item" data-provider="{{ .jid }}" data-category="{{ .category }}" data-property-free="{{ .freeOfCharge }}" data-property-professional-hosting="{{ .professionalHosting }}" data-property-ibr="{{ .inBandRegistration }}" data-property-password-reset="{{ ne (len .passwordReset) 0 }}">
<div class="accordion-item" data-provider="{{ .jid }}" data-category="{{ .category }}" data-property-free="{{ .freeOfCharge }}" data-property-professional-hosting="{{ .professionalHosting }}" data-property-rating-green-web-check="{{ .ratingGreenWebCheck }}" data-property-ibr="{{ .inBandRegistration }}" data-property-password-reset="{{ ne (len .passwordReset) 0 }}">
<h2 class="accordion-header" id="heading-{{ $provider_id }}">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-{{ $provider_id }}" aria-expanded="false" aria-controls="collapse-{{ $provider_id }}">
<span class="badge rounded-1 {{ if eq .category "A" }}category-a{{ else if eq .category "B" }}category-b{{ else if eq .category "C" }}category-c{{ else }}category-d{{ end }}">{{ .category }}</span>
Expand Down
12 changes: 12 additions & 0 deletions themes/xmpp-providers/layouts/shortcodes/provider-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<th>
Professional<br>Hosting
</th>
<th>
Green<br>Hosting
</th>
<th>
Run by a<br>Company
</th>
Expand Down Expand Up @@ -78,6 +81,7 @@
</thead>
<tbody>
{{ range sort .Site.Data.filtered_providers "category" }}
{{ $providers_data := index $.Site.Data.providers .jid }}
<tr>
<td>
<a href="/provider/{{ .jid }}/">{{ .jid }}</a>
Expand Down Expand Up @@ -171,6 +175,14 @@
No
{{ end }}
</td>
<td>
{{ if .ratingGreenWebCheck }}
{{ $url := replace $providers_data.ratingGreenWebCheck.source "https://admin.thegreenwebfoundation.org/greencheck/" "" }}
<a href="https://www.thegreenwebfoundation.org/green-web-check/?url={{ $url }}" target="_blank">Yes</a>
{{ else }}
<a href="/faq/#green-hosting" class="abbr">No</a>
{{ end }}
</td>
<td>
{{ if .company }}
Yes
Expand Down
11 changes: 9 additions & 2 deletions themes/xmpp-providers/static/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later

window.addEventListener("load", function() {
document.addEventListener("DOMContentLoaded", (event) => {

// Provider filtering in overview
const checkboxes = document.querySelectorAll("#status-selector input");
const show_hide = function(checkbox) {
Expand All @@ -19,6 +20,12 @@ window.addEventListener("load", function() {
provider.hidden = checkbox.checked;
});
};
if (property == "rating-green-web-check") {
const relevant_providers = document.querySelectorAll("[data-property-rating-green-web-check=false]");
relevant_providers.forEach(function(provider) {
provider.hidden = checkbox.checked;
});
};
if (property == "in-band-registration") {
const relevant_providers = document.querySelectorAll("[data-property-ibr=false]");
relevant_providers.forEach(function(provider) {
Expand All @@ -41,7 +48,7 @@ window.addEventListener("load", function() {
const badge_link_copy = document.getElementById("badge_link_copy");
if (badge_link_copy) {
badge_link_copy.addEventListener("click", function() {
navigator.clipboard.writeText(document.getElementById("badge_link_input").value);
navigator.clipboard.writeText(document.getElementById("badge_link_input").value);
});
}

Expand Down

0 comments on commit f6a7e12

Please sign in to comment.