From 06bc36762d0172a5e11537563744f8949a146e7c Mon Sep 17 00:00:00 2001 From: George <31376482+george-gca@users.noreply.github.com> Date: Sun, 28 Jan 2024 19:10:42 -0300 Subject: [PATCH] Move libs versions to config (#2139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moved libs versions and hashes to `_config.yml`. Fixes #2067. Deferring everything possible to keep pages loads fast. --------- Signed-off-by: George Araújo --- _config.yml | 48 ++++++++++++++++++ _includes/head.liquid | 52 +++++++++++++------ _includes/metadata.liquid | 10 ++-- _includes/scripts/chartjs.liquid | 2 +- _includes/scripts/codeDiff.liquid | 26 ---------- _includes/scripts/diff2html.liquid | 31 ++++++++++++ _includes/scripts/echarts.liquid | 52 ++++++++++--------- _includes/scripts/imageLayouts.liquid | 7 +-- _includes/scripts/leaflet.liquid | 44 ++++++++-------- _includes/scripts/masonry.liquid | 7 ++- _includes/scripts/mermaid.liquid | 72 +++++++++++++++------------ _includes/scripts/tikzjax.liquid | 3 ++ _includes/scripts/vega.liquid | 47 +++++++++-------- _layouts/default.liquid | 3 +- _posts/2023-07-04-jupyter-notebook.md | 15 ++++-- 15 files changed, 269 insertions(+), 150 deletions(-) delete mode 100644 _includes/scripts/codeDiff.liquid create mode 100644 _includes/scripts/diff2html.liquid create mode 100644 _includes/scripts/tikzjax.liquid diff --git a/_config.yml b/_config.yml index 10c8f11..6c3f3ce 100644 --- a/_config.yml +++ b/_config.yml @@ -380,9 +380,40 @@ enable_progressbar: true # enables a horizontal progress bar linked to the verti bootstrap-table: version: "1.22.1" +chartjs: + version: "4.4.1" +d3: + version: "7.8.5" + integrity: "sha256-1rA678n2xEx7x4cTZ5x4wpUCj6kUMZEZ5cxLSVSFWxw=" +diff2html: + version: "3.4.47" + integrity: + css: "sha256-IMBK4VNZp0ivwefSn51bswdsrhk0HoMTLc2GqFHFBXg=" + js: "sha256-eU2TVHX633T1o/bTQp6iIJByYJEtZThhF9bKz/DcbbY=" +echarts: + version: "5.4.3" + integrity: + library: "sha256-EVZCmhajjLhgTcxlGMGUBtQiYULZCPjt0uNTFEPFTRk=" + dark_theme: "sha256-UmFIP/4VvOqBDIl2QWl1HBuAJ1XWs/iFZxT5yJRZOKo=" +highlightjs: + version: "11.9.0" + integrity: + css: + light: "sha256-Oppd74ucMR5a5Dq96FxjEzGF7tTw2fZ/6ksAqDCM8GY=" + dark: "sha256-nyCNAiECsdDHrr/s2OQsp5l9XeY2ZJ0rMepjCT2AkBk=" +imagesloaded: + version: "5.0.0" + integrity: "sha256-htrLFfZJ6v5udOG+3kNLINIKh2gvoKqwEhHYfTTMICc=" +img-comparison-slider: + version: "8.0.6" jquery: version: "3.6.0" integrity: "sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" +leaflet: + version: "1.9.4" + integrity: + css: "sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" + js: "sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" mathjax: version: "3.2.0" masonry: @@ -396,6 +427,23 @@ mdb: medium_zoom: version: "1.1.0" integrity: "sha256-ZgMyDAIYDYGxbcpJcfUnYwNevG/xi9OHKaR/8GK+jWc=" +mermaid: + version: "10.7.0" + integrity: "sha256-TtLOdUA8mstPoO6sGvHIGx2ceXrrX4KgIItO06XOn8A=" +swiper: + version: "11.0.5" + integrity: + css: "sha256-yUoNxsvX+Vo8Trj3lZ/Y5ZBf8HlBFsB6Xwm7rH75/9E=" + js: "sha256-BPrwikijIybg9OQC5SYFFqhBjERYOn97tCureFgYH1E=" +vega: + version: "5.27.0" + integrity: "sha256-Yot/cfgMMMpFwkp/5azR20Tfkt24PFqQ6IQS+80HIZs=" +vega-embed: + version: "6.24.0" + integrity: "sha256-FPCJ9JYCC9AZSpvC/t/wHBX7ybueZhIqOMjpWqfl3DU=" +vega-lite: + version: "5.16.3" + integrity: "sha256-TvBvIS5jUN4BSy009usRjNzjI1qRrHPYv7xVLJyjUyw=" # ----------------------------------------------------------------------------- # Get external JSON data diff --git a/_includes/head.liquid b/_includes/head.liquid index 1035e72..b8c27ab 100644 --- a/_includes/head.liquid +++ b/_includes/head.liquid @@ -17,8 +17,9 @@ {% endif %} - + - -{% endif %} -{% if page.tikzjax %} - - + {% endif %} @@ -56,6 +54,7 @@ {% if site.enable_darkmode %} {% if page.map %} {% endif %} @@ -77,29 +77,51 @@ {% if page.code_diff %} - + {% endif %} - {% if page.images %} + {% if page.images.compare %} - + {% endif %} + {% if page.images.slider %} {% endif %} {% endif %} + +{% if page.tikzjax %} + +{% endif %} diff --git a/_includes/metadata.liquid b/_includes/metadata.liquid index b1c7ccb..b737370 100644 --- a/_includes/metadata.liquid +++ b/_includes/metadata.liquid @@ -14,13 +14,15 @@ {% endif %} +{% capture author_name %}{{ site.first_name }}{% if site.middle_name %} {{ site.middle_name }}{% endif %} {{ site.last_name }}{% endcapture %} + {% if site.title == 'blank' %} - {% capture title %}{{ site.first_name }} {{ site.middle_name }} {{ site.last_name }}{% endcapture %} + {% capture title %}{{ author_name }}{% endcapture %} {% else %} {% capture title %}{{ site.title }}{% endcapture %} {% endif %} @@ -36,7 +38,7 @@ {{ title }} {% endif %} - + {% if page.keywords or site.keywords %} @@ -223,7 +225,7 @@ "author": { "@type": "Person", - "name": "{{ site.first_name }} {{ site.middle_name }} {{ site.last_name }}" + "name": "{{ author_name }}" }, "url": "{{ page.url | prepend: site.baseurl | prepend: site.url }}", "@type": "{% if is_blog_post %}BlogPosting{% else %}WebSite{% endif %}", @@ -232,7 +234,7 @@ {% if sameaslinks != blank %} "sameAs": {{ sameaslinks }}, {% endif %} - "name": "{{ site.first_name }} {{ site.middle_name }} {{ site.last_name }}", + "name": "{{ author_name }}", "@context": "https://schema.org" } diff --git a/_includes/scripts/chartjs.liquid b/_includes/scripts/chartjs.liquid index 4f43933..8574f74 100644 --- a/_includes/scripts/chartjs.liquid +++ b/_includes/scripts/chartjs.liquid @@ -1,5 +1,5 @@ {% if page.chart and page.chart.chartjs %} - + - -{% endif %} diff --git a/_includes/scripts/diff2html.liquid b/_includes/scripts/diff2html.liquid new file mode 100644 index 0000000..e3add88 --- /dev/null +++ b/_includes/scripts/diff2html.liquid @@ -0,0 +1,31 @@ +{% if page.code_diff %} + + + +{% endif %} diff --git a/_includes/scripts/echarts.liquid b/_includes/scripts/echarts.liquid index cbac2be..8b61abd 100644 --- a/_includes/scripts/echarts.liquid +++ b/_includes/scripts/echarts.liquid @@ -1,13 +1,15 @@ {% if page.chart and page.chart.echarts %} {% if site.enable_darkmode %} {% endif %} @@ -16,26 +18,30 @@ /* Create echarts chart as another node and hide the code block, appending the echarts node after it this is done to enable retrieving the code again when changing theme between light/dark */ - document.querySelectorAll('pre>code.language-echarts').forEach((elem) => { - const jsonData = elem.textContent; - const backup = elem.parentElement; - backup.classList.add('unloaded'); - /* create echarts node */ - let chartElement = document.createElement('div'); - chartElement.classList.add('echarts'); - backup.after(chartElement); + document.onreadystatechange = () => { + if (document.readyState === 'complete') { + document.querySelectorAll('pre>code.language-echarts').forEach((elem) => { + const jsonData = elem.textContent; + const backup = elem.parentElement; + backup.classList.add('unloaded'); + /* create echarts node */ + let chartElement = document.createElement('div'); + chartElement.classList.add('echarts'); + backup.after(chartElement); - /* create echarts */ - if (theme === 'dark') { - var chart = echarts.init(chartElement, 'dark-fresh-cut'); - } else { - var chart = echarts.init(chartElement); + /* create echarts */ + if (theme === 'dark') { + var chart = echarts.init(chartElement, 'dark-fresh-cut'); + } else { + var chart = echarts.init(chartElement); + } + + chart.setOption(JSON.parse(jsonData)); + window.addEventListener('resize', function () { + chart.resize(); + }); + }); } - - chart.setOption(JSON.parse(jsonData)); - window.addEventListener('resize', function () { - chart.resize(); - }); - }); + }; {% endif %} diff --git a/_includes/scripts/imageLayouts.liquid b/_includes/scripts/imageLayouts.liquid index 131fcbc..bb8c5a2 100644 --- a/_includes/scripts/imageLayouts.liquid +++ b/_includes/scripts/imageLayouts.liquid @@ -1,11 +1,12 @@ {% if page.images %} {% if page.images.compare %} - + {% endif %} {% if page.images.slider %} {% endif %} diff --git a/_includes/scripts/leaflet.liquid b/_includes/scripts/leaflet.liquid index 516f239..13b2bda 100644 --- a/_includes/scripts/leaflet.liquid +++ b/_includes/scripts/leaflet.liquid @@ -1,28 +1,32 @@ {% if page.map %} {% endif %} diff --git a/_includes/scripts/masonry.liquid b/_includes/scripts/masonry.liquid index c82f774..cbc3c9a 100644 --- a/_includes/scripts/masonry.liquid +++ b/_includes/scripts/masonry.liquid @@ -6,6 +6,11 @@ integrity="{{ site.masonry.integrity }}" crossorigin="anonymous" > - + {% endif %} diff --git a/_includes/scripts/mermaid.liquid b/_includes/scripts/mermaid.liquid index ebfd577..e4f1839 100644 --- a/_includes/scripts/mermaid.liquid +++ b/_includes/scripts/mermaid.liquid @@ -1,45 +1,55 @@ {% if page.mermaid and page.mermaid.enabled %} {% if page.mermaid.zoomable %} - + {% endif %} {% endif %} diff --git a/_includes/scripts/tikzjax.liquid b/_includes/scripts/tikzjax.liquid new file mode 100644 index 0000000..aa2a3c1 --- /dev/null +++ b/_includes/scripts/tikzjax.liquid @@ -0,0 +1,3 @@ +{% if page.tikzjax %} + +{% endif %} diff --git a/_includes/scripts/vega.liquid b/_includes/scripts/vega.liquid index 1e8c397..c870cf3 100644 --- a/_includes/scripts/vega.liquid +++ b/_includes/scripts/vega.liquid @@ -1,17 +1,20 @@ {% if page.chart and page.chart.vega_lite %} @@ -20,21 +23,25 @@ /* Create vega lite chart as another node and hide the code block, appending the vega lite node after it this is done to enable retrieving the code again when changing theme between light/dark */ - document.querySelectorAll('pre>code.language-vega_lite').forEach((elem) => { - const jsonData = elem.textContent; - const backup = elem.parentElement; - backup.classList.add('unloaded'); - /* create vega lite node */ - let chartElement = document.createElement('div'); - chartElement.classList.add('vega-lite'); - backup.after(chartElement); + document.onreadystatechange = () => { + if (document.readyState === 'complete') { + document.querySelectorAll('pre>code.language-vega_lite').forEach((elem) => { + const jsonData = elem.textContent; + const backup = elem.parentElement; + backup.classList.add('unloaded'); + /* create vega lite node */ + let chartElement = document.createElement('div'); + chartElement.classList.add('vega-lite'); + backup.after(chartElement); - /* Embed the visualization in the container */ - if (theme === 'dark') { - vegaEmbed(chartElement, JSON.parse(jsonData), { theme: 'dark' }); - } else { - vegaEmbed(chartElement, JSON.parse(jsonData)); + /* Embed the visualization in the container */ + if (theme === 'dark') { + vegaEmbed(chartElement, JSON.parse(jsonData), { theme: 'dark' }); + } else { + vegaEmbed(chartElement, JSON.parse(jsonData)); + } + }); } - }); + }; {% endif %} diff --git a/_layouts/default.liquid b/_layouts/default.liquid index c5a7fab..6809a73 100644 --- a/_layouts/default.liquid +++ b/_layouts/default.liquid @@ -48,11 +48,12 @@ {% include scripts/bootstrap.liquid %} {% include scripts/masonry.liquid %} {% include scripts/mermaid.liquid %} - {% include scripts/codeDiff.liquid %} + {% include scripts/diff2html.liquid %} {% include scripts/leaflet.liquid %} {% include scripts/chartjs.liquid %} {% include scripts/echarts.liquid %} {% include scripts/vega.liquid %} + {% include scripts/tikzjax.liquid %} {% include scripts/misc.liquid %} {% include scripts/badges.liquid %} {% include scripts/mathjax.liquid %} diff --git a/_posts/2023-07-04-jupyter-notebook.md b/_posts/2023-07-04-jupyter-notebook.md index 80fce4b..8c1a1fc 100644 --- a/_posts/2023-07-04-jupyter-notebook.md +++ b/_posts/2023-07-04-jupyter-notebook.md @@ -13,11 +13,16 @@ To include a jupyter notebook in a post, you can use the following code: {% raw %} -```html -{::nomarkdown} {% assign jupyter_path = "assets/jupyter/blog.ipynb" | relative_url %} {% capture notebook_exists %}{% file_exists -assets/jupyter/blog.ipynb %}{% endcapture %} {% if notebook_exists == "true" %} {% jupyter_notebook jupyter_path %} {% else %} -

Sorry, the notebook you are looking for does not exist.

-{% endif %} {:/nomarkdown} +```liquid +{::nomarkdown} +{% assign jupyter_path = 'assets/jupyter/blog.ipynb' | relative_url %} +{% capture notebook_exists %}{% file_exists assets/jupyter/blog.ipynb %}{% endcapture %} +{% if notebook_exists == 'true' %} + {% jupyter_notebook jupyter_path %} +{% else %} +

Sorry, the notebook you are looking for does not exist.

+{% endif %} +{:/nomarkdown} ``` {% endraw %}