From 1ceb7cccb62e1ddef47575dd6b00fa82e2240ad5 Mon Sep 17 00:00:00 2001
From: Julia Kent <46687291+jukent@users.noreply.github.com>
Date: Wed, 12 Jun 2024 13:52:40 -0600
Subject: [PATCH 1/7] dropdown gallery changes
---
portal/_extensions/gallery_generator.py | 99 ++++-----
portal/_static/custom.css | 54 +++++
portal/_static/custom.js | 263 ++++++++----------------
portal/conf.py | 4 +-
4 files changed, 197 insertions(+), 223 deletions(-)
diff --git a/portal/_extensions/gallery_generator.py b/portal/_extensions/gallery_generator.py
index 61a033b9..264127aa 100644
--- a/portal/_extensions/gallery_generator.py
+++ b/portal/_extensions/gallery_generator.py
@@ -1,6 +1,6 @@
import itertools
import pathlib
-
+import re
from truncatehtml import truncate
@@ -9,13 +9,20 @@ def _generate_sorted_tag_keys(all_items):
return sorted(key_set)
+def _title_case_preserve(s):
+ return re.sub(r'\b(\w)', lambda m: m.group(1).upper(), s)
+
+def _make_class(s):
+ return re.sub(r'^\d+', '', s.replace(" ", "-").lower())
+
def _generate_tag_set(all_items, tag_key=None):
tag_set = set()
for item in all_items:
for k, e in item['tags'].items():
+ tags = [_title_case_preserve(t) for t in e]
if tag_key and k != tag_key:
continue
- for t in e:
+ for t in tags:
tag_set.add(t)
return tag_set
@@ -26,20 +33,18 @@ def _generate_tag_menu(all_items, tag_key):
tag_list = sorted(tag_set)
options = ''.join(
- f'
-
-
-
{item["title"]}
-
{authors_str}
{affiliations_str}
-
{short_description}
-
+
+ new_card = f"""
+ :::{{grid-item-card}}
+ :shadow: md
+ :class-footer: card-footer
+ :class-card: tagged-card {tag_classes}
+
+
+
+
- {modal_str}
+
+ {modal_str}
- +++
+ +++
- {tags}
+ {tags}
- :::
+ :::
- """
+ """
grid_body.append('\n'.join([m.lstrip() for m in new_card.split('\n')]))
From d92d5b04340db4499c693a1a0e2b09bf7a662dac Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Wed, 12 Jun 2024 19:56:59 +0000
Subject: [PATCH 3/7] [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---
portal/_extensions/gallery_generator.py | 11 ++++---
portal/_static/custom.css | 2 +-
portal/_static/custom.js | 40 ++++++++++++-------------
portal/conf.py | 2 +-
4 files changed, 29 insertions(+), 26 deletions(-)
diff --git a/portal/_extensions/gallery_generator.py b/portal/_extensions/gallery_generator.py
index 56583f7d..922f2365 100644
--- a/portal/_extensions/gallery_generator.py
+++ b/portal/_extensions/gallery_generator.py
@@ -1,6 +1,7 @@
import itertools
import pathlib
import re
+
from truncatehtml import truncate
@@ -12,8 +13,10 @@ def _generate_sorted_tag_keys(all_items):
def _title_case_preserve(s):
return re.sub(r'\b(\w)', lambda m: m.group(1).upper(), s)
+
def _make_class(s):
- return re.sub(r'^\d+', '', s.replace(" ", "-").lower())
+ return re.sub(r'^\d+', '', s.replace(' ', '-').lower())
+
def _generate_tag_set(all_items, tag_key=None):
tag_set = set()
@@ -35,7 +38,7 @@ def _generate_tag_menu(all_items, tag_key):
options = ''.join(
f'
'
for tag in tag_list
- )
+ )
return f"""
:::{{dropdown}} {tag_key}
@@ -78,7 +81,7 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, subtext=No
tags = [f'
{_title_case_preserve(tag)}' for tag in tag_list_f]
tags = '\n'.join(tags)
- tag_classes = " ".join(tag_list_f)
+ tag_classes = ' '.join(tag_list_f)
author_strs = set()
affiliation_strs = set()
@@ -157,7 +160,7 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, subtext=No
stitle = f'#### {subtitle}' if subtitle else ''
stext = subtext if subtext else ''
- grid_body = "\n".join(grid_body)
+ grid_body = '\n'.join(grid_body)
grid = f"""\
{title}
{'=' * len(title)}
diff --git a/portal/_static/custom.css b/portal/_static/custom.css
index a35c408f..7920fe73 100644
--- a/portal/_static/custom.css
+++ b/portal/_static/custom.css
@@ -197,4 +197,4 @@ main.bd-content #main-content a {
.sd-col.sd-d-flex-row.docutils.has-visible-card {
margin-bottom: 1rem;
-}
\ No newline at end of file
+}
diff --git a/portal/_static/custom.js b/portal/_static/custom.js
index 449db0d6..139a1454 100644
--- a/portal/_static/custom.js
+++ b/portal/_static/custom.js
@@ -7,47 +7,47 @@ function getClassOfCheckedCheckboxes(checkboxes) {
});
return tags;
}
-
+
function change() {
console.log("Change event fired.");
var affiliationsCbs = document.querySelectorAll(".affiliation input[type='checkbox']");
var domainsCbs = document.querySelectorAll(".domains input[type='checkbox']");
var formatsCbs = document.querySelectorAll(".formats input[type='checkbox']");
var packagesCbs = document.querySelectorAll(".packages input[type='checkbox']");
-
+
var affiliatioinTags = getClassOfCheckedCheckboxes(affiliationsCbs);
var domainTags = getClassOfCheckedCheckboxes(domainsCbs);
var formatTags = getClassOfCheckedCheckboxes(formatsCbs);
var packageTags = getClassOfCheckedCheckboxes(packagesCbs);
-
+
var filters = {
affiliations: affiliatioinTags,
domains: domainTags,
formats: formatTags,
packages: packageTags
};
-
+
filterResults(filters);
}
-
+
function filterResults(filters) {
console.log("Filtering results...");
var rElems = document.querySelectorAll(".tagged-card");
-
+
rElems.forEach(function (el) {
var isVisible = true; // Assume visible by default
-
+
// Check if the element has any domain or package filter
if (filters.affiliations.length > 0 || filters.domains.length > 0 || filters.formats.length > 0 || filters.packages.length > 0) {
var hasMatchingAffiliation = filters.affiliations.length === 0 || filters.affiliations.some(affiliation => el.classList.contains(affiliation));
var hasMatchingDomain = filters.domains.length === 0 || filters.domains.some(domain => el.classList.contains(domain));
var hasMatchingFormat = filters.formats.length === 0 || filters.formats.some(format => el.classList.contains(format));
var hasMatchingPackage = filters.packages.length === 0 || filters.packages.some(package => el.classList.contains(package));
-
+
// The element should be visible if it matches any filter within each category
isVisible = hasMatchingAffiliation && hasMatchingDomain && hasMatchingFormat && hasMatchingPackage;
}
-
+
// Toggle visibility based on the result
if (isVisible) {
el.classList.remove("d-none");
@@ -57,23 +57,23 @@ function getClassOfCheckedCheckboxes(checkboxes) {
el.classList.add("d-none");
}
});
-
+
// Update the margins after filtering
updateMargins();
}
-
+
var checkboxes = document.querySelectorAll('input[type="checkbox"]');
checkboxes.forEach(function (checkbox) {
checkbox.addEventListener("change", change);
});
-
+
function updateMargins() {
const columns = document.querySelectorAll('.sd-col.sd-d-flex-row.docutils');
-
+
columns.forEach(column => {
// Check if this column has any visible cards
const hasVisibleCard = Array.from(column.children).some(child => !child.classList.contains('d-none'));
-
+
// Toggle a class based on whether there are visible cards
if (hasVisibleCard) {
column.classList.add('has-visible-card');
@@ -82,18 +82,18 @@ function getClassOfCheckedCheckboxes(checkboxes) {
}
});
}
-
+
function clearCbs() {
// Select all checkbox inputs and uncheck them
var checkboxes = document.querySelectorAll('input[type="checkbox"]');
checkboxes.forEach(function(checkbox) {
checkbox.checked = false;
});
-
- change();
+
+ change();
}
-
+
// Initial call to set up correct margins when the page loads
document.addEventListener('DOMContentLoaded', updateMargins);
-
- console.log("Script loaded.");
\ No newline at end of file
+
+ console.log("Script loaded.");
diff --git a/portal/conf.py b/portal/conf.py
index e4dd3584..79cbb61e 100644
--- a/portal/conf.py
+++ b/portal/conf.py
@@ -34,7 +34,7 @@
extensions = [
'resource_gallery_generator',
'myst_nb',
- "sphinx_design",
+ 'sphinx_design',
'ablog',
'sphinx.ext.intersphinx',
]
From 275a1ed82d0f55bd024002ab49421254acb3ccb9 Mon Sep 17 00:00:00 2001
From: Julia Kent <46687291+jukent@users.noreply.github.com>
Date: Wed, 12 Jun 2024 14:04:12 -0600
Subject: [PATCH 4/7] dark theme changes
---
portal/_static/custom.css | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/portal/_static/custom.css b/portal/_static/custom.css
index a35c408f..a8dde5b2 100644
--- a/portal/_static/custom.css
+++ b/portal/_static/custom.css
@@ -197,4 +197,17 @@ main.bd-content #main-content a {
.sd-col.sd-d-flex-row.docutils.has-visible-card {
margin-bottom: 1rem;
+}
+
+html[data-theme="dark"] h1.display-1 {
+ color: white;
+}
+
+html[data-them="dark"] h4.display-4.p-0 {
+ color: black !important;
+}
+
+html[data-theme="dark"] .sd-card-body.docutils {
+ background-color: white;
+ color: black;
}
\ No newline at end of file
From fefca7a279aa66db82931b76ff3367ac3786055a Mon Sep 17 00:00:00 2001
From: Julia Kent <46687291+jukent@users.noreply.github.com>
Date: Wed, 12 Jun 2024 14:22:39 -0600
Subject: [PATCH 5/7] dark theme cards
---
portal/_static/custom.css | 3 +++
1 file changed, 3 insertions(+)
diff --git a/portal/_static/custom.css b/portal/_static/custom.css
index 1e1189cc..04ffb6f1 100644
--- a/portal/_static/custom.css
+++ b/portal/_static/custom.css
@@ -209,5 +209,8 @@ html[data-them="dark"] h4.display-4.p-0 {
html[data-theme="dark"] .sd-card-body.docutils {
background-color: white;
+}
+
+html[data-them="dark"] container .p {
color: black;
}
From b12183ebeaef2d8864446325a57530511592c68c Mon Sep 17 00:00:00 2001
From: Julia Kent <46687291+jukent@users.noreply.github.com>
Date: Wed, 12 Jun 2024 14:27:55 -0600
Subject: [PATCH 6/7] them to theme
---
portal/_static/custom.css | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/portal/_static/custom.css b/portal/_static/custom.css
index 04ffb6f1..e6a48630 100644
--- a/portal/_static/custom.css
+++ b/portal/_static/custom.css
@@ -211,6 +211,6 @@ html[data-theme="dark"] .sd-card-body.docutils {
background-color: white;
}
-html[data-them="dark"] container .p {
- color: black;
+html[data-theme="dark"] .container p {
+ color: black !important;
}
From 3097e172abb7ac7620270fcb65cb2954c35423df Mon Sep 17 00:00:00 2001
From: Julia Kent <46687291+jukent@users.noreply.github.com>
Date: Thu, 13 Jun 2024 12:14:50 -0600
Subject: [PATCH 7/7] rm accidental link color chagne
---
portal/_static/custom.css | 4 ----
1 file changed, 4 deletions(-)
diff --git a/portal/_static/custom.css b/portal/_static/custom.css
index e6a48630..bb94f5ab 100644
--- a/portal/_static/custom.css
+++ b/portal/_static/custom.css
@@ -191,10 +191,6 @@ p {
color: black;
}
-main.bd-content #main-content a {
- color: #1a648f;
-}
-
.sd-col.sd-d-flex-row.docutils.has-visible-card {
margin-bottom: 1rem;
}