Skip to content

Commit d92d5b0

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 581c41a commit d92d5b0

File tree

4 files changed

+29
-26
lines changed

4 files changed

+29
-26
lines changed

portal/_extensions/gallery_generator.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import itertools
22
import pathlib
33
import re
4+
45
from truncatehtml import truncate
56

67

@@ -12,8 +13,10 @@ def _generate_sorted_tag_keys(all_items):
1213
def _title_case_preserve(s):
1314
return re.sub(r'\b(\w)', lambda m: m.group(1).upper(), s)
1415

16+
1517
def _make_class(s):
16-
return re.sub(r'^\d+', '', s.replace(" ", "-").lower())
18+
return re.sub(r'^\d+', '', s.replace(' ', '-').lower())
19+
1720

1821
def _generate_tag_set(all_items, tag_key=None):
1922
tag_set = set()
@@ -35,7 +38,7 @@ def _generate_tag_menu(all_items, tag_key):
3538
options = ''.join(
3639
f'<li><label class="dropdown-item checkbox {tag_key}"><input type="checkbox" rel={_make_class(tag)} onchange="change();">&nbsp;{tag}</label></li>'
3740
for tag in tag_list
38-
)
41+
)
3942

4043
return f"""
4144
:::{{dropdown}} {tag_key}
@@ -78,7 +81,7 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, subtext=No
7881

7982
tags = [f'<span class="badge bg-primary mybadges">{_title_case_preserve(tag)}</span>' for tag in tag_list_f]
8083
tags = '\n'.join(tags)
81-
tag_classes = " ".join(tag_list_f)
84+
tag_classes = ' '.join(tag_list_f)
8285

8386
author_strs = set()
8487
affiliation_strs = set()
@@ -157,7 +160,7 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, subtext=No
157160
stitle = f'#### {subtitle}' if subtitle else ''
158161
stext = subtext if subtext else ''
159162

160-
grid_body = "\n".join(grid_body)
163+
grid_body = '\n'.join(grid_body)
161164
grid = f"""\
162165
{title}
163166
{'=' * len(title)}

portal/_static/custom.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,4 @@ main.bd-content #main-content a {
197197

198198
.sd-col.sd-d-flex-row.docutils.has-visible-card {
199199
margin-bottom: 1rem;
200-
}
200+
}

portal/_static/custom.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,47 @@ function getClassOfCheckedCheckboxes(checkboxes) {
77
});
88
return tags;
99
}
10-
10+
1111
function change() {
1212
console.log("Change event fired.");
1313
var affiliationsCbs = document.querySelectorAll(".affiliation input[type='checkbox']");
1414
var domainsCbs = document.querySelectorAll(".domains input[type='checkbox']");
1515
var formatsCbs = document.querySelectorAll(".formats input[type='checkbox']");
1616
var packagesCbs = document.querySelectorAll(".packages input[type='checkbox']");
17-
17+
1818
var affiliatioinTags = getClassOfCheckedCheckboxes(affiliationsCbs);
1919
var domainTags = getClassOfCheckedCheckboxes(domainsCbs);
2020
var formatTags = getClassOfCheckedCheckboxes(formatsCbs);
2121
var packageTags = getClassOfCheckedCheckboxes(packagesCbs);
22-
22+
2323
var filters = {
2424
affiliations: affiliatioinTags,
2525
domains: domainTags,
2626
formats: formatTags,
2727
packages: packageTags
2828
};
29-
29+
3030
filterResults(filters);
3131
}
32-
32+
3333
function filterResults(filters) {
3434
console.log("Filtering results...");
3535
var rElems = document.querySelectorAll(".tagged-card");
36-
36+
3737
rElems.forEach(function (el) {
3838
var isVisible = true; // Assume visible by default
39-
39+
4040
// Check if the element has any domain or package filter
4141
if (filters.affiliations.length > 0 || filters.domains.length > 0 || filters.formats.length > 0 || filters.packages.length > 0) {
4242
var hasMatchingAffiliation = filters.affiliations.length === 0 || filters.affiliations.some(affiliation => el.classList.contains(affiliation));
4343
var hasMatchingDomain = filters.domains.length === 0 || filters.domains.some(domain => el.classList.contains(domain));
4444
var hasMatchingFormat = filters.formats.length === 0 || filters.formats.some(format => el.classList.contains(format));
4545
var hasMatchingPackage = filters.packages.length === 0 || filters.packages.some(package => el.classList.contains(package));
46-
46+
4747
// The element should be visible if it matches any filter within each category
4848
isVisible = hasMatchingAffiliation && hasMatchingDomain && hasMatchingFormat && hasMatchingPackage;
4949
}
50-
50+
5151
// Toggle visibility based on the result
5252
if (isVisible) {
5353
el.classList.remove("d-none");
@@ -57,23 +57,23 @@ function getClassOfCheckedCheckboxes(checkboxes) {
5757
el.classList.add("d-none");
5858
}
5959
});
60-
60+
6161
// Update the margins after filtering
6262
updateMargins();
6363
}
64-
64+
6565
var checkboxes = document.querySelectorAll('input[type="checkbox"]');
6666
checkboxes.forEach(function (checkbox) {
6767
checkbox.addEventListener("change", change);
6868
});
69-
69+
7070
function updateMargins() {
7171
const columns = document.querySelectorAll('.sd-col.sd-d-flex-row.docutils');
72-
72+
7373
columns.forEach(column => {
7474
// Check if this column has any visible cards
7575
const hasVisibleCard = Array.from(column.children).some(child => !child.classList.contains('d-none'));
76-
76+
7777
// Toggle a class based on whether there are visible cards
7878
if (hasVisibleCard) {
7979
column.classList.add('has-visible-card');
@@ -82,18 +82,18 @@ function getClassOfCheckedCheckboxes(checkboxes) {
8282
}
8383
});
8484
}
85-
85+
8686
function clearCbs() {
8787
// Select all checkbox inputs and uncheck them
8888
var checkboxes = document.querySelectorAll('input[type="checkbox"]');
8989
checkboxes.forEach(function(checkbox) {
9090
checkbox.checked = false;
9191
});
92-
93-
change();
92+
93+
change();
9494
}
95-
95+
9696
// Initial call to set up correct margins when the page loads
9797
document.addEventListener('DOMContentLoaded', updateMargins);
98-
99-
console.log("Script loaded.");
98+
99+
console.log("Script loaded.");

portal/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
extensions = [
3535
'resource_gallery_generator',
3636
'myst_nb',
37-
"sphinx_design",
37+
'sphinx_design',
3838
'ablog',
3939
'sphinx.ext.intersphinx',
4040
]

0 commit comments

Comments
 (0)