Skip to content

Commit

Permalink
Fix issues with loading scripts (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
alshedivat committed Sep 26, 2020
1 parent adfbe18 commit dacac74
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 68 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fontawesome:
integrity: "sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog=="
jquery:
version: "3.5.1"
integrity: "sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g=="
integrity: "sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg=="
mathjax:
version: "3.1.2"
mansory:
Expand Down
79 changes: 12 additions & 67 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,6 @@
<title>{% if site.title == blank %}{{ site.title }}{% else %}{{ site.first_name }} {{ site.middle_name }} {{ site.last_name }}{% endif %}{% if page.title and page.url != "/" %} | {{ page.title }}{% endif %}</title>
<meta name="description" content="{{ site.description }}">

<!-- Bootstrap & MDB -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/{{ site.bootstrap.version }}/css/bootstrap.min.css" rel="stylesheet" integrity="{{ site.bootstrap.integrity.css }}" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/{{ site.mdb.version }}/css/mdb.min.css" integrity="{{ site.mdb.integrity.css }}" crossorigin="anonymous" />
<script defer src="https://code.jquery.com/jquery-{{ site.jquery.version }}.slim.min.js" integrity="{{ site.jquery.integrity }}" crossorigin="anonymous"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/{{ site.popper.version }}/umd/popper.min.js" integrity="{{ site.popper.integrity }}" crossorigin="anonymous"></script>
<script defer src="https://stackpath.bootstrapcdn.com/bootstrap/{{ site.bootstrap.version }}/js/bootstrap.min.js" integrity="{{ site.bootstrap.integrity.js }}" crossorigin="anonymous"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/{{ site.mdb.version }}/js/mdb.min.js" integrity="{{ site.mdb.integrity.js }}" crossorigin="anonymous"></script>

<!-- Fonts & Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/{{ site.fontawesome.version }}/css/all.min.css" integrity="{{ site.fontawesome.integrity }}" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/academicons/{{ site.academicons.version }}/css/academicons.min.css" integrity="{{ site.academicons.integrity }}" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:100,300,400,500,700|Material+Icons">

<!-- Styles -->
<link rel="shortcut icon" href="{{ '/assets/img/favicon.ico' | relative_url }}">
<link rel="stylesheet" href="{{ '/assets/css/main.css' | relative_url }}">

<link rel="canonical" href="{{ page.url | replace:'index.html','' | relative_url }}">

<!-- Open Graph -->
{% if site.serve_og_meta %}
<meta property="og:site_name" content="{{ site.description }}" />
Expand All @@ -34,56 +15,20 @@
<meta property="og:image" content="{%- if page.og_image -%}{{ page.og_image }}{%- else -%}{{ site.og_image }}{%- endif -%}" />
{% endif %}

<!-- Load Common JS -->
<script defer src="{{ '/assets/js/common.js' | relative_url }}"></script>
<!-- Bootstrap & MDB -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/{{ site.bootstrap.version }}/css/bootstrap.min.css" rel="stylesheet" integrity="{{ site.bootstrap.integrity.css }}" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/{{ site.mdb.version }}/css/mdb.min.css" integrity="{{ site.mdb.integrity.css }}" crossorigin="anonymous" />

<!-- Fonts & Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/{{ site.fontawesome.version }}/css/all.min.css" integrity="{{ site.fontawesome.integrity }}" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/academicons/{{ site.academicons.version }}/css/academicons.min.css" integrity="{{ site.academicons.integrity }}" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:100,300,400,500,700|Material+Icons">

<!-- Code Syntax Highlighting -->
<link rel="stylesheet" href="https://gitcdn.link/repo/jwarby/jekyll-pygments-themes/master/{{ site.highlight_theme }}.css" />

{% if site.enable_math %}
<!-- Load MathJax -->
<script defer type="text/javascript" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@{{ site.mathjax.version }}/es5/tex-mml-chtml.js"></script>
<script defer src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
{% endif %}

{% if site.enable_mansory %}
<!-- Load Mansory & imagesLoaded -->
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/masonry/{{ site.mansory.version }}/masonry.pkgd.min.js" integrity="{{ site.masonry.integrity }}" crossorigin="anonymous"></script>
<script defer src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>

<!-- Project Cards Layout -->
<script defer type="text/javascript">
// Init Masonry
var $grid = $('.grid').masonry({
gutter: 10,
horizontalOrder: true,
itemSelector: '.grid-item',
});
// layout Masonry after each image loads
$grid.imagesLoaded().progress( function() {
$grid.masonry('layout');
});
</script>
{% endif %}

{% if site.enable_tooltips %}
<!-- Enable Tooltips -->
<script defer type="text/javascript">
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
</script>
{% endif %}

{% if site.enable_google_analytics %}
<!-- Google Analytics -->
<script defer>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
<!-- Styles -->
<link rel="shortcut icon" href="{{ '/assets/img/favicon.ico' | relative_url }}">
<link rel="stylesheet" href="{{ '/assets/css/main.css' | relative_url }}">

ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}
<link rel="canonical" href="{{ page.url | replace:'index.html','' | relative_url }}">
4 changes: 4 additions & 0 deletions _includes/scripts/bootstrap.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- Bootsrap & MDB scripts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/{{ site.popper.version }}/umd/popper.min.js" integrity="{{ site.popper.integrity }}" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/{{ site.bootstrap.version }}/js/bootstrap.min.js" integrity="{{ site.bootstrap.integrity.js }}" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/{{ site.mdb.version }}/js/mdb.min.js" integrity="{{ site.mdb.integrity.js }}" crossorigin="anonymous"></script>
2 changes: 2 additions & 0 deletions _includes/scripts/jquery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/{{ site.jquery.version }}/jquery.min.js" integrity="{{ site.jquery.integrity }}" crossorigin="anonymous"></script>
6 changes: 6 additions & 0 deletions _includes/scripts/mansory.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% if site.enable_mansory %}
<!-- Mansory & imagesLoaded -->
<script defer src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js"></script>
<script defer src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>
<script defer src="{{ '/assets/js/mansory.js' | relative_url }}" type="text/javascript"></script>
{% endif %}
5 changes: 5 additions & 0 deletions _includes/scripts/mathjax.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% if site.enable_math %}
<!-- MathJax -->
<script defer type="text/javascript" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@{{ site.mathjax.version }}/es5/tex-mml-chtml.js"></script>
<script defer src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
{% endif %}
22 changes: 22 additions & 0 deletions _includes/scripts/misc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% if site.enable_tooltips %}
<!-- Enable Tooltips -->
<script type="text/javascript">
$(function () {$('[data-toggle="tooltip"]').tooltip()})
</script>
{% endif %}

{% if site.enable_google_analytics %}
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
{% endif %}

<!-- Load Common JS -->
<script src="{{ '/assets/js/common.js' | relative_url }}"></script>
6 changes: 6 additions & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<head>
{% include head.html %}
{% include scripts/mathjax.html %}
</head>

<body class="{% if site.navbar_fixed %}fixed-top-nav{% endif %} {% unless site.footer_fixed %}sticky-bottom-footer{% endunless %}">
Expand All @@ -23,4 +24,9 @@

</body>

{% include scripts/jquery.html %}
{% include scripts/bootstrap.html %}
{% include scripts/mansory.html %}
{% include scripts/misc.html %}

</html>
1 change: 1 addition & 0 deletions _layouts/distill.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
{% include head.html %}
{% include scripts/mathjax.html %}
<script src="{{ '/assets/js/distillpub/template.v2.js' | relative_url }}"></script>
<script src="{{ '/assets/js/distillpub/transforms.v2.js' | relative_url }}"></script>
{% if page._styles %}
Expand Down
12 changes: 12 additions & 0 deletions assets/js/mansory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$(document).ready(function() {
// Init Masonry
var $grid = $('.grid').masonry({
gutter: 10,
horizontalOrder: true,
itemSelector: '.grid-item',
});
// Layout Masonry after each image loads
$grid.imagesLoaded().progress( function() {
$grid.masonry('layout');
});
});

0 comments on commit dacac74

Please sign in to comment.