Skip to content

Commit

Permalink
Merge pull request #22 from hiddenfigs/20-create-level-ranking-system
Browse files Browse the repository at this point in the history
20 create level ranking system
  • Loading branch information
jmduarte authored Sep 3, 2024
2 parents 7d1769f + 9eb2ee4 commit c29ea12
Show file tree
Hide file tree
Showing 20 changed files with 202 additions and 70 deletions.
55 changes: 55 additions & 0 deletions assets/img/logos/level.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 13 additions & 20 deletions assets/js/utils/search-people.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ async function debouncedSearch(
options = {},
debounceTimeoutMs = 300,
) {
if (
options.filters.relevantCourses.length === 0 &&
options.filters.researchAreas.length === 0
) {
const searchResult = await pf.search(term);
return searchResult;
if (!options.filters.level) {
delete options.filters.level;
}
if (options.filters && options.filters.type) {
delete options.filters.type;
}

options.filters.relevantCourses = options.filters.relevantCourses.map(
(course) => course.toLowerCase(),
);
Expand All @@ -34,11 +32,6 @@ async function debouncedSearch(
if (thisSearchID !== currentSearchID) {
return null;
}

if (options.filters && options.filters.type) {
delete options.filters.type;
}

const searchResult = await pf.search(term, options);
if (thisSearchID !== currentSearchID) {
return null;
Expand All @@ -52,6 +45,7 @@ export default function searchPeople() {
filterType: "scientist",
filterResearchAreas: [],
filterRelevantCourses: [],
filterLevel: [],
query: "",
pagefind: null,
error: null,
Expand All @@ -76,6 +70,7 @@ export default function searchPeople() {
"filterType",
"filterResearchAreas",
"filterRelevantCourses",
"filterLevel",
]) {
this.$watch(param, () => this.search());
}
Expand All @@ -87,18 +82,14 @@ export default function searchPeople() {
let timeout = query ? 300 : 0;
this.isLoading = true;
this.resultCount = 0;

let options = {};
if (this.filterType) {
options.filters = {
type: this.filterType,
researchAreas: this.filterResearchAreas.map((f) => f.value),
relevantCourses: this.filterRelevantCourses.map((f) => f.value),
level: this.filterLevel,
};
options.filters.researchAreas = this.filterResearchAreas.map(
(f) => f.value,
);
options.filters.relevantCourses = this.filterRelevantCourses.map(
(f) => f.value,
);
}

if (this.hasFilters && !query) {
Expand Down Expand Up @@ -151,6 +142,7 @@ export default function searchPeople() {
role: data.meta.role || "",
researchAreas: data.filters.researchAreas || [],
relevantCourses: data.filters.relevantCourses || [],
level: data.filters.level || [],
image: data.meta.image,
alt: data.meta.image_alt,
srcset: data.meta.image_srcset,
Expand All @@ -163,7 +155,8 @@ export default function searchPeople() {
get hasFilters() {
return (
this.filterResearchAreas.length > 0 ||
this.filterRelevantCourses.length > 0
this.filterRelevantCourses.length > 0 ||
this.filterLevel.length > 0
);
},

Expand Down
3 changes: 2 additions & 1 deletion content/scientist/Al-Kindi.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
}
,
"citations": ["https://doi.org/10.1017/CCOL0521817439.003"],
"layout": "person"
"layout": "person",
"level" : ["K12"]
}
5 changes: 3 additions & 2 deletions content/scientist/Arthur Bertram Cuthbert Walker Jr.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "name",
"title": "Arthur Bertram Cuthbert Walker Jr.",
"name": "Arthur Bertram Cuthbert Walker Jr.",
"linktitle": "Arthur Bertram Cuthbert Walker Jr.",
"last": "Walker",
Expand Down Expand Up @@ -27,5 +27,6 @@
"http://www.math.buffalo.edu/mad/physics/walker_arthurbc.html",
"https://web.archive.org/web/20130826152433/https://aas.org/obituaries/arthur-b-c-walker-1936-2001"
],
"layout": "person"
"layout": "person",
"level" : ["UGLD"]
}
3 changes: 2 additions & 1 deletion content/scientist/Chien-Shiung Wu.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
"citations": [
"https://doi.org/10.1007/978-3-319-19204-8_8"
],
"layout": "person"
"layout": "person",
"level" : ["K12", "UGUD"]
}
3 changes: 2 additions & 1 deletion content/scientist/Donna Strickland.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
"https://www.nobelprize.org/prizes/physics/2018/strickland/biographical/",
"https://www.optica.org/history/biographies/bios/donna-t-strickland/"
],
"layout": "person"
"layout": "person",
"level" : ["K12", "G"]
}
3 changes: 2 additions & 1 deletion content/scientist/Henrietta Swan Leavitt.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@
"https://www.nytimes.com/2024/03/27/obituaries/henrietta-leavitt-overlooked.html",
"https://www.atnf.csiro.au/outreach/education/senior/astrophysics/variable_cepheids.html"
],
"layout": "person"
"layout": "person",
"level" : ["G"]
}
3 changes: 2 additions & 1 deletion content/scientist/J Ernest Wilkins Jr.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"Gamma Radiation Shielding": "Developed mathematical models to explain gamma radiation, which was critical to the development of shielding against gamma radiation emitted by nuclear sources and the sun and thus key to the design of safe nuclear reactors and space probes."
},
"citations":["https://doi.org/10.1007/978-3-642-77425-6_33"],
"layout":"person"
"layout":"person",
"level" : ["UGLD", "UGUD"]
}
3 changes: 2 additions & 1 deletion content/scientist/Jocelyn Bell Burnell.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
"https://doi.org/10.1093/ww/9780199540884.013.U7157",
"https://www.allesoversterrenkunde.nl/!/!/!/actueel/artikelen/_detail/gli/50-years-pulsars/"
],
"layout": "person"
"layout": "person",
"level" : ["K12", "UGLD"]
}
3 changes: 2 additions & 1 deletion content/scientist/Katharine Burr Blodgett.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
"https://www.pbs.org/video/katharine-burr-blodgett-she-inspires-marl6o/",
"https://www.sciencehistory.org/stories/magazine/the-invisible-woman/"
],
"layout": "person"
"layout": "person",
"level" : ["UGUD", "G"]
}
3 changes: 2 additions & 1 deletion content/scientist/Katherine Johnson.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
"citations": [
"https://doi.org/10.1093/anb/9780198606697.article.1302346"
],
"layout": "person"
"layout": "person",
"level" : ["K12", "UGLD"]
}
3 changes: 2 additions & 1 deletion content/scientist/Lene Hau.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
"https://www.thecrimson.com/article/1999/10/13/hau-receives-tenure-physics-professor-slowed/",
"https://doi.org/10.1103/PhysRevLett.104.133002"
],
"layout": "person"
"layout": "person",
"level" : ["UGUD"]
}
3 changes: 2 additions & 1 deletion content/scientist/Mary Chilton Noyes.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"Elasticity of a Piano Wire": "Recorded the elasticity of a piano wire, expanding the temperature range to 200 degrees celsius. Prior work on the elasticity of piano wire only recorded work up to 100 degrees celsius. Noyes concluded that elasticity decreased linearly as temperature increased. Additionally, there was no maximum of elasticity at 100 degrees celsius."
},
"citations": ["https://doi.org/10.1103/PhysRevSeriesI.2.277"],
"layout": "person"
"layout": "person",
"level" : ["K12", "UGUD"]
}
3 changes: 2 additions & 1 deletion content/scientist/Robert A. Ellis Jr.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"https://www.economist.com/science-and-technology/2015/10/24/stellar-work",
"https://www.energy.gov/science/doe-explainsfusion-energy-science"
],
"layout": "person"
"layout": "person",
"level" : ["K12"]
}
3 changes: 2 additions & 1 deletion content/scientist/Ruby Payne-Scott.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
"https://www.swpc.noaa.gov/phenomena/solar-flares-radio-blackouts",
"https://www.nrao.edu/astrores/gbsrbs/Pubs/AJP_07.pdf"
],
"layout": "person"
"layout": "person",
"level" : ["UGUD", "G"]
}
2 changes: 1 addition & 1 deletion layouts/_default/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ <h2 class="{{ $secHedClass }}" id="by-beat">
>&minus;</span
>
<span x-show="!isOpen" aria-hidden="true" class=""> &plus; </span>
<span>Scientist by area</span>
<span>Scientist by research area</span>
</button>
</h2>
<div x-cloak x-show="isOpen" x-collapse>
Expand Down
58 changes: 55 additions & 3 deletions layouts/_default/person.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,25 @@ <h1 class="break-word font-bold leading-tight">
>
</span>
</p>
<p class=" flex items-center sm:w-1/2">
<span class="mr-5 text-g-6">
<svg class="inline-block h-4 w-4 fill-current align-text-bottom">
<title>level</title>
<use xlink:href="#level"></use>
</svg>
</span>
<span class="overflow-hidden break-words">
{{ range $index, $level := .Params.level }}
{{- if ne $index 0 }},{{ end }}
<span
data-pagefind-filter="level"
data-pagefind-filter-value="{{ $level }}"
>
{{ $level }}
</span>
{{- end }}
</span>
</p>
</div>

<!-- Content Switch Buttons -->
Expand Down Expand Up @@ -202,7 +221,7 @@ <h2 class="sr-only" data-pagefind-ignore>
<span class="align-middle">
{{ range $index, $area := .Params.relevant_concepts }}
{{- if ne $index 0 }},{{ end }}
<span class="hover:underline">{{ $area -}}</span>
<span>{{ $area -}}</span>
{{- end }}
</span>
</div>
Expand Down Expand Up @@ -311,7 +330,7 @@ <h2 class="text-lg font-bold">Citations</h2>
class="citation-item overflow-hidden break-words"
>
<a href="{{ $citation }}" target="_blank"
>[{{ add $index 1 }}]{{ $citation }}</a
>[{{ add $index 1 }}] {{ $citation }}</a
>
</li>
{{ end }}
Expand All @@ -323,7 +342,7 @@ <h2 class="text-lg font-bold">Citations</h2>
<!-- Hidden Meta Information for Pagefind -->
<div hidden data-pagefind-meta="title">{{ .Params.linktitle }}</div>

<!-- JavaScript for scroll and highlight -->
<!-- CODE FOR CITATION, JavaScript for scroll and highlight-->
<script>
document.addEventListener("DOMContentLoaded", function () {
const citationLinks = document.querySelectorAll(".citation-link");
Expand Down Expand Up @@ -361,6 +380,39 @@ <h2 class="text-lg font-bold">Citations</h2>
});
</script>

<!-- CODE FOR CONVERTING ENCODING LEVEL TO NORMAL WORDING, JavaScript for scroll and highlight-->
<script>
document.addEventListener("DOMContentLoaded", function () {
// Map of levels to their descriptive text
const levelDescriptions = {
K12: "K-12",
UGLD: "Undergraduate - Lower Division",
UGUD: "Undergraduate - Upper Division",
G: "Graduate",
};

// Function to update the innerHTML of elements with data-pagefind-filter="level"
const updateLevelDescriptions = () => {
// Select all elements with the data-pagefind-filter attribute set to "level"
const levelElements = document.querySelectorAll(
'[data-pagefind-filter="level"]',
);

// Loop through each element and update its innerHTML
levelElements.forEach((element) => {
const level = element.getAttribute("data-pagefind-filter-value");
const description = levelDescriptions[level];
if (description) {
element.innerHTML = description;
}
});
};

// Call the function to update level descriptions
updateLevelDescriptions();
});
</script>

<!-- CSS for highlighting -->
<style>
.citation-item.highlight {
Expand Down
Loading

0 comments on commit c29ea12

Please sign in to comment.