Skip to content

Commit

Permalink
Merge branch 'al-folio-main'
Browse files Browse the repository at this point in the history
  • Loading branch information
george-gca committed Jul 10, 2024
2 parents 92d6784 + d019fc0 commit 2543f00
Show file tree
Hide file tree
Showing 11 changed files with 224 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/broken-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ jobs:
with:
fail: true
# removed md files that include liquid tags
args: --user-agent 'curl/7.54' --exclude-path README.md --exclude-path _pages/en-us/404.md --exclude-path _pages/pt-br/404.md --exclude-path _pages/en-us/blog.md --exclude-path _pages/pt-br/blog.md --exclude-path _posts/en-us/2018-12-22-distill.md --exclude-path _posts/pt-br/2018-12-22-distill.md --verbose --no-progress './**/*.md' './**/*.html'
args: --user-agent 'curl/7.54' --exclude-path README.md --exclude-path _pages/en-us/404.md --exclude-path _pages/pt-br/404.md --exclude-path _pages/en-us/blog.md --exclude-path _pages/pt-br/blog.md --exclude-path _posts/en-us/2018-12-22-distill.md --exclude-path _posts/pt-br/2018-12-22-distill.md --exclude-path _posts/en-us/2023-04-24-videos.md --exclude-path _posts/pt-br/2023-04-24-videos.md --verbose --no-progress './**/*.md' './**/*.html'
7 changes: 4 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ navbar_fixed: true
footer_fixed: true
search_enabled: true
socials_in_search: true
bib_search: true

# Dimensions
max_width: 1000px
Expand Down Expand Up @@ -534,13 +535,13 @@ third_party_libraries:
version: "1.9.4"
mathjax:
integrity:
js: "sha256-rjmgmaB99riUNcdlrDtcAiwtLIojSxNyUFdl+Qh+rB4="
js: "sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="
local:
fonts: "output/chtml/fonts/woff-v2/"
url:
fonts: "https://cdn.jsdelivr.net/npm/mathjax@{{version}}/es5/output/chtml/fonts/woff-v2/"
js: "https://cdn.jsdelivr.net/npm/mathjax@{{version}}/es5/tex-mml-chtml.min.js"
version: "3.2.0"
js: "https://cdn.jsdelivr.net/npm/mathjax@{{version}}/es5/tex-mml-chtml.js"
version: "3.2.2"
masonry:
integrity:
js: "sha256-Nn1q/fx0H7SNLZMQ5Hw5JLaTRZp0yILA/FRexe19VdI="
Expand Down
5 changes: 5 additions & 0 deletions _includes/scripts/misc.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
<script defer src="{{ '/assets/js/common.js' | relative_url | bust_file_cache }}"></script>
<script defer src="{{ '/assets/js/copy_code.js' | relative_url | bust_file_cache }}" type="text/javascript"></script>

<!-- Bibsearch Feature -->
{% if site.search_enabled %}
<script src="{{ '/assets/js/bibsearch.js' | relative_url | bust_file_cache }}" type="module"></script>
{% endif %}

<!-- Jupyter Open External Links New Tab -->
<script defer src="{{ '/assets/js/jupyter_new_tab.js' | relative_url | bust_file_cache }}"></script>

Expand Down
57 changes: 20 additions & 37 deletions _includes/scripts/search.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@
// add the home and posts menu items
ninja.data = [
{%- for page in site.pages -%}
{%- if page.permalink == '/' -%}{%- assign about_title = page.title -%}{%- endif -%}
{%- if page.permalink == '/' -%}{%- assign about_title = page.title | strip -%}{%- endif -%}
{%- endfor -%}
{
id: "nav-{{ about_title | slugify }}",
title: "{{ about_title }}",
title: "{{ about_title | truncatewords: 13 }}",
section: "{{ site.data[site.active_lang].strings.search.navigation }}",
handler: () => {
window.location.href = "{{ '/' | prepend: lang | relative_url }}";
Expand All @@ -106,11 +106,11 @@
{%- for child in p.children -%}
{%- unless child.title == 'divider' -%}
{
{%- assign title = child.title | escape -%}
{%- assign title = child.title | escape | strip -%}
{%- if child.permalink contains "/blog/" -%}{%- assign url = "/blog/" -%} {%- else -%}{%- assign url = child.url -%}{%- endif -%}
id: "dropdown-{{ title | slugify }}",
title: "{{ title }}",
description: "{{ child.description | strip_html | strip_newlines | escape }}",
title: "{{ title | truncatewords: 13 }}",
description: "{{ child.description | strip_html | strip_newlines | escape | strip }}",
section: "{{ site.data[site.active_lang].strings.search.dropdown }}",
handler: () => {
window.location.href = "{{ url | prepend: lang | relative_url }}";
Expand All @@ -120,11 +120,11 @@
{%- endfor -%}
{%- else -%}
{
{%- assign title = p.title | escape -%}
{%- assign title = p.title | escape | strip -%}
{%- if p.permalink contains "/blog/" -%}{%- assign url = "/blog/" -%} {%- else -%}{%- assign url = p.url -%}{%- endif -%}
id: "nav-{{ title | slugify }}",
title: "{{ title }}",
description: "{{ p.description | strip_html | strip_newlines | escape }}",
title: "{{ title | truncatewords: 13 }}",
description: "{{ p.description | strip_html | strip_newlines | escape | strip }}",
section: "{{ site.data[site.active_lang].strings.search.navigation }}",
handler: () => {
window.location.href = "{{ url | prepend: lang | relative_url }}";
Expand All @@ -135,17 +135,17 @@
{%- endfor -%}
{%- for post in site.posts -%}
{
{%- assign title = post.title | escape -%}
{%- assign title = post.title | escape | strip -%}
id: "post-{{ title | slugify }}",
{% if post.redirect == blank %}
title: "{{ title }}",
title: "{{ title | truncatewords: 13 }}",
{% elsif post.redirect contains '://' %}
// TODO: fix the svg icon position for external posts
title: '{{ title }} <svg width="1.2rem" height="1.2rem" top=".5rem" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><path d="M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9" class="icon_svg-stroke" stroke="#999" stroke-width="1.5" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg>',
title: '{{ title | truncatewords: 13 }} <svg width="1.2rem" height="1.2rem" top=".5rem" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><path d="M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9" class="icon_svg-stroke" stroke="#999" stroke-width="1.5" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg>',
{% else %}
title: "{{ title }}",
title: "{{ title | truncatewords: 13 }}",
{% endif %}
description: "{{ post.description | strip_html | strip_newlines | escape }}",
description: "{{ post.description | strip_html | strip_newlines | escape | strip }}",
section: "{{ site.data[site.active_lang].strings.search.posts }}",
handler: () => {
{% if post.redirect == blank %}
Expand All @@ -158,37 +158,18 @@
},
},
{%- endfor -%}
{%- assign news = site.news | reverse -%}
{%- for item in news -%}
{
{%- if item.inline -%}
{%- assign title = item.content | remove: '<p>' | remove: '</p>' | escape | strip -%}
{%- else -%}
{%- assign title = item.title | escape -%}
{%- endif -%}
id: "news-{{ title | slugify }}",
title: '{{ title | emojify }}',
description: "{{ item.description | strip_html | strip_newlines | escape }}",
section: "{{ site.data[site.active_lang].strings.search.news }}",
{%- unless item.inline -%}
handler: () => {
window.location.href = "{{ item.url | prepend: lang | relative_url }}";
},
{%- endunless -%}
},
{%- endfor -%}
{%- for collection in site.collections -%}
{%- if collection.label != 'news' and collection.label != 'posts' -%}
{%- if collection.label != 'posts' -%}
{%- for item in collection.docs -%}
{
{%- if item.inline -%}
{%- assign title = item.content | remove: '<p>' | remove: '</p>' | escape | strip -%}
{%- assign title = item.content | strip_html | strip_newlines | escape | strip -%}
{%- else -%}
{%- assign title = item.title | escape -%}
{%- assign title = item.title | strip_html | strip_newlines | escape | strip -%}
{%- endif -%}
id: "{{ collection.label }}-{{ title | slugify }}",
title: '{{ title | emojify }}',
description: "{{ item.description | strip_html | strip_newlines | escape }}",
title: '{{ title | emojify | truncatewords: 13 }}',
description: "{{ item.description | strip_html | strip_newlines | escape | strip }}",
section: "{{ site.data[site.active_lang].strings.search[collection.label] }}",
{%- unless item.inline -%}
handler: () => {
Expand Down Expand Up @@ -281,6 +262,7 @@
},
{%- endif -%}
{%- if site.osf_id -%}
{
id: 'socials-open-science-framework',
title: 'Open Science Framework',
section: '{{ site.data[site.active_lang].strings.search.socials }}',
Expand Down Expand Up @@ -678,4 +660,5 @@
{%- endif -%}
];
</script>
<script src="{{ '/assets/js/shortcut-key.js' | relative_url | bust_file_cache }}"></script>
{% endif %}
6 changes: 3 additions & 3 deletions _layouts/bib.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
{% assign more_authors_show = more_authors_show | append: ', ' %}
{% endunless %}
{%- endfor -%}
{% assign more_authors_show = more_authors_show | regex_replace: '([*∗†‡§¶‖&^]+)', '<sup>\1</sup>' %}
{%- assign more_authors_show = more_authors_show | regex_replace: '([*∗†‡§¶‖&^]+)', '<sup>\1</sup>' -%}
, and
<span
class="more-authors"
Expand Down Expand Up @@ -151,9 +151,9 @@
{% if entry.type == 'article' %}
{% capture entrytype %}<em>{{ entry.journal }}</em>{% endcapture %}
{% elsif proceedings contains entry.type %}
{% capture entrytype %}<em>In {{ entry.booktitle }}</em> {% endcapture %}
{% capture entrytype %}<em>In {{ entry.booktitle }}</em>{% endcapture %}
{% elsif thesis contains entry.type %}
{% capture entrytype %}<em>{{ entry.school }}</em> {% endcapture %}
{% capture entrytype %}<em>{{ entry.school }}</em>{% endcapture %}
{% else %}
{% capture entrytype %}{% endcapture %}
{% endif %}
Expand Down
1 change: 0 additions & 1 deletion _layouts/default.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,5 @@
{% include scripts/jekyll_tabs.liquid %}
{% include scripts/back_to_top.liquid %}
{% include scripts/search.liquid %}
<script src="{{ '/assets/js/shortcut-key.js' | relative_url }}"></script>
</body>
</html>
1 change: 1 addition & 0 deletions _layouts/distill.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@
{% include scripts/analytics.liquid %}
{% include scripts/progressBar.liquid %}
{% include scripts/back_to_top.liquid %}
{% include scripts/search.liquid %}
</body>
</html>
5 changes: 5 additions & 0 deletions _pages/en-us/publications.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ nav_order: 2
---

<!-- _pages/publications.md -->

{% if site.search_enabled %}
<input type="text" id="bibsearch" spellcheck="false" autocomplete="off" class="search bibsearch-form-input" placeholder="Type to filter">
{% endif %}

<div class="publications">

{% bibliography %}
Expand Down
9 changes: 8 additions & 1 deletion _sass/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,8 @@ ninja-keys::part(ninja-input-wrapper) {
width: 100%;
}

.newsletter-form-input {
.newsletter-form-input,
.bibsearch-form-input {
color: var(--global-newsletter-text-color);
background: var(--global-newsletter-bg-color);
border: 1px solid var(--global-newsletter-text-color);
Expand Down Expand Up @@ -1325,3 +1326,9 @@ ninja-keys::part(ninja-input-wrapper) {
border-bottom-color: var(--global-divider-color);
}
}

// highlight-search-term
::highlight(search) {
background-color: var(--global-theme-color);
color: var(--global-text-color);
}
67 changes: 67 additions & 0 deletions assets/js/bibsearch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { highlightSearchTerm } from "./highlight-search-term.js";

document.addEventListener("DOMContentLoaded", function () {
// actual bibsearch logic
const filterItems = (searchTerm) => {
document.querySelectorAll(".bibliography, .unloaded").forEach((element) => element.classList.remove("unloaded"));

// highlight-search-term
if (CSS.highlights) {
const nonMatchingElements = highlightSearchTerm({ search: searchTerm, selector: ".bibliography > li" });
nonMatchingElements.forEach((element) => {
element.classList.add("unloaded");
});
} else {
// Simply add unloaded class to all non-matching items if Browser does not support CSS highlights
document.querySelectorAll(".bibliography > li").forEach((element, index) => {
const text = element.innerText.toLowerCase();
if (text.indexOf(searchTerm) == -1) {
element.classList.add("unloaded");
}
});
}

document.querySelectorAll("h2.bibliography").forEach(function (element) {
let iterator = element.nextElementSibling; // get next sibling element after h2, which can be h3 or ol
let hideFirstGroupingElement = true;
// iterate until next group element (h2), which is already selected by the querySelectorAll(-).forEach(-)
while (iterator && iterator.tagName !== "H2") {
if (iterator.tagName === "OL") {
const ol = iterator;
const unloadedSiblings = ol.querySelectorAll(":scope > li.unloaded");
const totalSiblings = ol.querySelectorAll(":scope > li");

if (unloadedSiblings.length === totalSiblings.length) {
ol.previousElementSibling.classList.add("unloaded"); // Add the '.unloaded' class to the previous grouping element (e.g. year)
ol.classList.add("unloaded"); // Add the '.unloaded' class to the OL itself
} else {
hideFirstGroupingElement = false; // there is at least some visible entry, don't hide the first grouping element
}
}
iterator = iterator.nextElementSibling;
}
// Add unloaded class to first grouping element (e.g. year) if no item left in this group
if (hideFirstGroupingElement) {
element.classList.add("unloaded");
}
});
};

const updateInputField = () => {
const hashValue = decodeURIComponent(window.location.hash.substring(1)); // Remove the '#' character
document.getElementById("bibsearch").value = hashValue;
filterItems(hashValue);
};

// Sensitive search. Only start searching if there's been no input for 300 ms
let timeoutId;
document.getElementById("bibsearch").addEventListener("input", function () {
clearTimeout(timeoutId); // Clear the previous timeout
const searchTerm = this.value.toLowerCase();
timeoutId = setTimeout(filterItems(searchTerm), 300);
});

window.addEventListener("hashchange", updateInputField); // Update the filter when the hash changes

updateInputField(); // Update filter when page loads
});
Loading

0 comments on commit 2543f00

Please sign in to comment.