From: François Michonneau Date: Fri, 8 Nov 2019 23:50:32 +0000 (+0100) Subject: Use Jekyll to generate the 'all-in-one' page (carpentries/styles#438) X-Git-Url: https://git.arvados.org/rnaseq-cwl-training.git/commitdiff_plain/a966a6859ec2ef6c38337ac789a2f664a80afd0e?hp=e06f686cc83e191d93a730b95307d98af3cce44b Use Jekyll to generate the 'all-in-one' page (carpentries/styles#438) --- diff --git a/_includes/aio-script.md b/_includes/aio-script.md index a81fbcd..d90e6d6 100644 --- a/_includes/aio-script.md +++ b/_includes/aio-script.md @@ -6,45 +6,20 @@ open an issue: https://github.com/carpentries/styles/issues/new {% include manual_episode_order.html %} - +{% for lesson_episode in lesson_episodes %} -{% comment %} Create an anchor for every episode. {% endcomment %} +{% if site.episode_order %} + {% assign e = site.episodes | where: "slug", lesson_episode | first %} +{% else %} + {% assign e = lesson_episode %} +{% endif %} -{% for lesson_episode in lesson_episodes %} - {% if site.episode_order %} - {% assign episode = site.episodes | where: "slug", lesson_episode | first %} - {% else %} - {% assign episode = lesson_episode %} - {% endif %} -
+

{{ e.title }}

+ +{% include episode_overview.html teaching_time=e.teaching exercise_time=e.exercises episode_questions=e.questions episode_objectives=e.objectives %} + +{{ e.content }} + +{% include episode_keypoints.html episode_keypoints=e.keypoints %} +
{% endfor %} diff --git a/_includes/episode_keypoints.html b/_includes/episode_keypoints.html index 2baa53e..5c283ea 100644 --- a/_includes/episode_keypoints.html +++ b/_includes/episode_keypoints.html @@ -1,10 +1,17 @@ {% comment %} Display key points for an episode. {% endcomment %} + +{% if page.keypoints == nil %} +{% assign episode_keypoints = include.episode_keypoints %} +{% else %} +{% assign episode_keypoints = page.keypoints %} +{% endif %} +

Key Points

diff --git a/_includes/episode_overview.html b/_includes/episode_overview.html index cb87e0f..c4a4d48 100644 --- a/_includes/episode_overview.html +++ b/_includes/episode_overview.html @@ -1,19 +1,59 @@ {% comment %} - Display an episode's timings and learning objectives. + Display episode's timings and learning objectives. + + Regarding the `if page.*** == nil` below: + all-in-one page combines all episodes into one. + It, therefore, does not define its own objectives, exercises, + and questions, which 'normal' episodes define in the front matter. + + To display episodes' teaching and exercise times, as well as episode + questions and objectives, we pass them as parameters to the Liquid's + `include` statement when we generate the page: + + {% include episode_overview.html teaching_time=e.teaching ... %} + + Here we obtain the information we need either from the episode itself or + from the parameters passed in. {% endcomment %} + +{% if page.teaching == nil %} +{% assign teaching_time = include.teaching_time %} +{% else %} +{% assign teaching_time = page.teaching %} +{% endif %} + +{% if page.exercises == nil %} +{% assign exercise_time = include.exercise_time %} +{% else %} +{% assign exercise_time = page.exercises %} +{% endif %} + +{% if page.questions == nil %} +{% assign episode_questions = include.episode_questions %} +{% else %} +{% assign episode_questions = page.questions %} +{% endif %} + +{% if page.objectives == nil %} +{% assign episode_objectives = include.episode_objectives %} +{% else %} +{% assign episode_objectives = page.objectives %} +{% endif %} + +

Overview

- Teaching: {{ page.teaching }} min + Teaching: {{ teaching_time }} min
- Exercises: {{ page.exercises }} min + Exercises: {{ exercise_time }} min
Questions
    - {% for question in page.questions %} + {% for question in episode_questions %}
  • {{ question|markdownify }}
  • {% endfor %}
@@ -26,7 +66,7 @@
Objectives
    - {% for objective in page.objectives %} + {% for objective in episode_objectives %}
  • {{ objective|markdownify }}
  • {% endfor %}