Add all in one lesson build with Javascript
authorRaniere Silva <raniere@rgaiacs.com>
Tue, 2 May 2017 10:41:18 +0000 (11:41 +0100)
committerRaniere Silva <raniere@rgaiacs.com>
Sat, 6 May 2017 08:25:35 +0000 (09:25 +0100)
_includes/episode_navbar.html
_includes/episode_title.html
_includes/navbar.html
_layouts/break.html
_layouts/episode.html
bin/lesson_initialize.py

index 1f6e033dc7825788fc159e3c5f085da20f61bef3..b9f85f6bda40c87832bdf1fdf2b137df35cd4d68 100644 (file)
@@ -14,7 +14,6 @@
   <div class="col-md-10">
     {% if include.episode_navbar_title %}
     <h3 class="maintitle"><a href="{{ page.root }}/">{{ site.title }}</a></h3>
   <div class="col-md-10">
     {% if include.episode_navbar_title %}
     <h3 class="maintitle"><a href="{{ page.root }}/">{{ site.title }}</a></h3>
-    <h1 class="maintitle">{{ page.title }}</h1>
     {% endif %}
   </div>
   <div class="col-md-1">
     {% endif %}
   </div>
   <div class="col-md-1">
index 5b9c821cae653b287ad995116b5af7dccf9a0572..d0abc654593423464e2082976e9b2c8879aa2b95 100644 (file)
@@ -1,42 +1,9 @@
-{% comment %}
-  Find previous and next episodes (if any).
-{% endcomment %}
-{% for episode in site.episodes  %}
-  {% if episode.url == page.url %}
-    {% unless forloop.first %}
-      {% assign prev_episode = prev %}
-    {% endunless %}
-    {% unless forloop.last %}
-      {% assign next_episode = site.episodes[forloop.index] %}
-    {% endunless %}
-  {% endif %}
-  {% assign prev = episode %}
-{% endfor %}
-
-{% comment %}
-  Display title and prev/next links.
-{% endcomment %}
 <div class="row">
   <div class="col-md-1">
 <div class="row">
   <div class="col-md-1">
-    <h3>
-      {% if prev_episode %}
-      <a href="{{ page.root }}{{ prev_episode.url }}"><span class="glyphicon glyphicon-menu-left"></span></a>
-      {% else %}
-      <a href="{{ page.root }}"><span class="glyphicon glyphicon-menu-up"></span></a>
-      {% endif %}
-    </h3>
   </div>
   <div class="col-md-10">
   </div>
   <div class="col-md-10">
-    <h3 class="maintitle"><a href="{{ page.root }}/">{{ site.title }}</a></h3>
     <h1 class="maintitle">{{ page.title }}</h1>
   </div>
   <div class="col-md-1">
     <h1 class="maintitle">{{ page.title }}</h1>
   </div>
   <div class="col-md-1">
-    <h3>
-      {% if next_episode %}
-      <a href="{{ page.root }}{{ next_episode.url }}"><span class="glyphicon glyphicon-menu-right"></span></a>
-      {% else %}
-      <a href="{{ page.root }}"><span class="glyphicon glyphicon-menu-up"></span></a>
-      {% endif %}
-    </h3>
   </div>
 </div>
   </div>
 </div>
index 00fd328babc24494b2c44a9c06317c0bc2e65537..7782c9dd5b7bdbdfb9d1f61026e562f9ea0aaaeb 100644 (file)
@@ -45,6 +45,8 @@
             {% for episode in site.episodes %}
             <li><a href="{{ page.root }}{{ episode.url }}">{{ episode.title }}</a></li>
             {% endfor %}
             {% for episode in site.episodes %}
             <li><a href="{{ page.root }}{{ episode.url }}">{{ episode.title }}</a></li>
             {% endfor %}
+           <li role="separator" class="divider"></li>
+            <li><a href="{{ page.root }}/aio/">All in one page (Beta)</a></li>
           </ul>
         </li>
        {% endif %}
           </ul>
         </li>
        {% endif %}
index 6e2a6a092f60e11ddda3ddd0cbb891a46db48b15..ac582324bf3132a257655cbb43c55464386be73e 100644 (file)
@@ -2,6 +2,9 @@
 layout: base
 ---
 {% include episode_navbar.html episode_navbar_title=true %}
 layout: base
 ---
 {% include episode_navbar.html episode_navbar_title=true %}
+<article>
+{% include episode_title.html %}
 {% include episode_break.html %}
 {{content}}
 {% include episode_break.html %}
 {{content}}
+</article>
 {% include episode_navbar.html episode_navbar_title=false %}
 {% include episode_navbar.html episode_navbar_title=false %}
index d774a6814733acd55e13a7d9c2ac132cd2a4eba8..0b276e773a269213fb0eb745fad9c413f7fc55d6 100644 (file)
@@ -2,7 +2,10 @@
 layout: base
 ---
 {% include episode_navbar.html episode_navbar_title=true %}
 layout: base
 ---
 {% include episode_navbar.html episode_navbar_title=true %}
+<article>
+{% include episode_title.html %}
 {% include episode_overview.html %}
 {{content}}
 {% include episode_keypoints.html %}
 {% include episode_overview.html %}
 {{content}}
 {% include episode_keypoints.html %}
+</article>
 {% include episode_navbar.html episode_navbar_title=false %}
 {% include episode_navbar.html episode_navbar_title=false %}
index 540bb08c83724f964570874b1b6e796640ac99d9..513597a40cd144186811f40528a344dd1237903b 100755 (executable)
@@ -278,6 +278,45 @@ permalink: /setup/
 FIXME
 '''
 
 FIXME
 '''
 
+ROOT_SETUP_MD = '''\
+---
+layout: page 
+permalink: /aio/
+---
+<script>
+  window.onload = function() {
+    var lesson_episodes = [
+    {% for episode in site.episodes %}
+    "{{ episode.url}}"{% unless forloop.last %},{% endunless %}
+    {% endfor %}
+    ];
+    var xmlHttp = [];  /* Required since we are going to query every episode. */
+    for (i=0; i < lesson_episodes.length; i++) {
+      xmlHttp[i] = new XMLHttpRequest();
+      xmlHttp[i].episode = lesson_episodes[i];  /* To enable use this later. */
+      xmlHttp[i].onreadystatechange = function() {
+      if (this.readyState == 4 && this.status == 200) {
+        var article_here = document.getElementById(this.episode);
+        var parser = new DOMParser();
+        var htmlDoc = parser.parseFromString(this.responseText,"text/html");
+        var htmlDocArticle = htmlDoc.getElementsByTagName("article")[0];
+        article_here.innerHTML = htmlDocArticle.innerHTML;
+        }
+      }
+      episode_url = "{{ page.root }}" + lesson_episodes[i];
+      xmlHttp[i].open("GET", episode_url);
+      xmlHttp[i].send(null);
+    }
+  }
+</script>
+{% comment %}
+Create anchor for each one of the episodes.
+{% endcomment %}
+{% for episode in site.episodes %}
+<article id="{{ episode.url }}"></article>
+{% endfor %}
+'''
+
 EPISODES_INTRODUCTION_MD = '''\
 ---
 title: "Introduction"
 EPISODES_INTRODUCTION_MD = '''\
 ---
 title: "Introduction"
@@ -340,6 +379,7 @@ BOILERPLATE = (
     ('index.md', ROOT_INDEX_MD),
     ('reference.md', ROOT_REFERENCE_MD),
     ('setup.md', ROOT_SETUP_MD),
     ('index.md', ROOT_INDEX_MD),
     ('reference.md', ROOT_REFERENCE_MD),
     ('setup.md', ROOT_SETUP_MD),
+    ('aio.md', ROOT_AIO_MD),
     ('_episodes/01-introduction.md', EPISODES_INTRODUCTION_MD),
     ('_extras/about.md', EXTRAS_ABOUT_MD),
     ('_extras/discuss.md', EXTRAS_DISCUSS_MD),
     ('_episodes/01-introduction.md', EPISODES_INTRODUCTION_MD),
     ('_extras/about.md', EXTRAS_ABOUT_MD),
     ('_extras/discuss.md', EXTRAS_DISCUSS_MD),