Skip to content

Commit

Permalink
moving thebelab config to within the page instead of head
Browse files Browse the repository at this point in the history
  • Loading branch information
choldgraf committed Dec 5, 2019
1 parent fd76efa commit 826b3f5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
32 changes: 32 additions & 0 deletions jupyter_book/book_template/_includes/js/thebelab-page-config.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script type="text/x-thebe-config">
{%- if page.kernel_name %}
{% assign kernelName = page.kernel_name %}
{% else %}
{% assign kernelName = "python3" %}
{% endif -%}

{%- if page.kernel_name %}
{% if page.kernel_name contains "python" %}
{% assign cm_language="python" %}
{% else %}
{% assign cm_language={{ page.kernel_name }} %}
{% endif %}
{% else %}
{% assign cm_language="python" %}
{% endif -%}
{
requestKernel: true,
binderOptions: {
repo: "{{ site.binder_repo_org }}/{{ site.binder_repo_name }}",
ref: "{{ site.binder_repo_branch }}",
},
codeMirrorConfig: {
theme: "{{ site.codemirror_theme }}",
mode: "{{ cm_language }}"
},
kernelOptions: {
kernelName: "{{ kernelName }}",
path: "{{ page.kernel_path }}"
}
}
</script>
34 changes: 0 additions & 34 deletions jupyter_book/book_template/_includes/js/thebelab.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,6 @@

<!-- Display Thebelab button in each code cell -->
{% include js/thebelab-cell-button.html %}

<script type="text/x-thebe-config">
{% if page.kernel_name %}
{% assign kernelName = page.kernel_name %}
{% else %}
{% assign kernelName = "python3" %}
{% endif %}

{% if page.kernel_name %}
{% if page.kernel_name contains "python" %}
{% assign cm_language="python" %}
{% else %}
{% assign cm_language={{ page.kernel_name }} %}
{% endif %}
{% else %}
{% assign cm_language="python" %}
{% endif %}
{
requestKernel: true,
binderOptions: {
repo: '{{ site.binder_repo_org }}/{{ site.binder_repo_name }}',
ref: '{{ site.binder_repo_branch }}',
},
codeMirrorConfig: {
theme: "{{ site.codemirror_theme }}",
mode: "{{ cm_language }}"
},
kernelOptions: {
kernelName: '{{ kernelName }}',
path: "{{ page.kernel_path }}"
}
}
</script>
<script src="https://unpkg.com/thebelab@latest/lib/index.js" async></script>
<script>
/**
Expand Down Expand Up @@ -124,6 +91,5 @@
}
return language;
}

</script>
{% endif %}
3 changes: 3 additions & 0 deletions jupyter_book/book_template/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<html lang="en">
{% include head.html %}
<body>
<!-- Include the ThebeLab config so it gets reloaded on each page -->
{% include js/thebelab-page-config.html %}

<!-- .js-show-sidebar shows sidebar by default -->
<div id="js-textbook" class="c-textbook {% if site.show_sidebar %}js-show-sidebar{% endif %}">
{% include sidebar.html %}
Expand Down

0 comments on commit 826b3f5

Please sign in to comment.