Skip to content

Commit 10b9c0c

Browse files
committed
Merge branch gh-pages of carpentries/styles
2 parents 25a8449 + 0deede1 commit 10b9c0c

24 files changed

+293
-174
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: [carpentries, swcarpentry, datacarpentry, librarycarpentry]
2+
custom: ["https://carpentries.wedid.it"]

.github/ISSUE_TEMPLATE.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
Please delete this line and the text below before submitting your contribution.
1+
<details>
2+
<summary><strong>Instructions</strong></summary>
23

3-
---
4+
Thanks for contributing! :heart:
45

5-
Thanks for contributing! If this contribution is for instructor training, please send an email to [email protected] with a link to this contribution so we can record your progress. You’ve completed your contribution step for instructor checkout just by submitting this contribution.
6+
If this contribution is for instructor training, please email the link to this contribution to
7+
[email protected] so we can record your progress. You've completed your contribution
8+
step for instructor checkout by submitting this contribution!
69

710
If this issue is about a specific episode within a lesson, please provide its link or filename.
811

9-
Please keep in mind that lesson maintainers are volunteers and it may be some time before they can respond to your contribution. Although not all contributions can be incorporated into the lesson materials, we appreciate your time and effort to improve the curriculum. If you have any questions about the lesson maintenance process or would like to volunteer your time as a contribution reviewer, please contact The Carpentries Team at [email protected].
12+
Keep in mind that **lesson maintainers are volunteers** and it may take them some time to
13+
respond to your contribution. Although not all contributions can be incorporated into the lesson
14+
materials, we appreciate your time and effort to improve the curriculum. If you have any questions
15+
about the lesson maintenance process or would like to volunteer your time as a contribution
16+
reviewer, please contact The Carpentries Team at [email protected].
1017

11-
---
18+
You may delete these instructions from your comment.
19+
20+
\- The Carpentries
21+
</details>

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ _site
99
.Rproj.user
1010
.Rhistory
1111
.RData
12-
12+
.bundle/
13+
.vendor/
14+
.docker-vendor/
15+
Gemfile.lock
16+
.*history

Gemfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
4+
5+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6+
7+
# Synchronize with https://pages.github.com/versions
8+
ruby '>=2.5.3'
9+
10+
gem 'github-pages', group: :jekyll_plugins

Makefile

Lines changed: 74 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,72 @@
1+
# Use /bin/bash instead of /bin/sh
2+
export SHELL = /bin/bash
3+
14
## ========================================
25
## Commands for both workshop and lesson websites.
36

47
# Settings
58
MAKEFILES=Makefile $(wildcard *.mk)
6-
JEKYLL=jekyll
7-
JEKYLL_VERSION=3.8.5
9+
JEKYLL=bundle install --path .vendor/bundle && bundle update && bundle exec jekyll
810
PARSER=bin/markdown_ast.rb
911
DST=_site
1012

13+
# Check Python 3 is installed and determine if it's called via python3 or python
14+
# (https://stackoverflow.com/a/4933395)
15+
PYTHON3_EXE := $(shell which python3 2>/dev/null)
16+
ifneq (, $(PYTHON3_EXE))
17+
ifeq (,$(findstring Microsoft/WindowsApps/python3,$(subst \,/,$(PYTHON3_EXE))))
18+
PYTHON := python3
19+
endif
20+
endif
21+
22+
ifeq (,$(PYTHON))
23+
PYTHON_EXE := $(shell which python 2>/dev/null)
24+
ifneq (, $(PYTHON_EXE))
25+
PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))
26+
PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL})
27+
ifneq (3, ${PYTHON_VERSION_MAJOR})
28+
$(error "Your system does not appear to have Python 3 installed.")
29+
endif
30+
PYTHON := python
31+
else
32+
$(error "Your system does not appear to have any Python installed.")
33+
endif
34+
endif
35+
36+
1137
# Controls
1238
.PHONY : commands clean files
13-
.NOTPARALLEL:
14-
all : commands
1539

16-
## commands : show all commands.
17-
commands :
18-
@grep -h -E '^##' ${MAKEFILES} | sed -e 's/## //g'
40+
# Default target
41+
.DEFAULT_GOAL := commands
1942

20-
## docker-serve : use docker to build the site
21-
docker-serve :
22-
docker run --rm -it -v ${PWD}:/srv/jekyll -p 127.0.0.1:4000:4000 jekyll/jekyll:${JEKYLL_VERSION} make serve
43+
## I. Commands for both workshop and lesson websites
44+
## =================================================
2345

24-
## serve : run a local server.
46+
## * serve : render website and run a local server
2547
serve : lesson-md
2648
${JEKYLL} serve
2749

28-
## site : build files but do not run a server.
50+
## * site : build website but do not run a server
2951
site : lesson-md
3052
${JEKYLL} build
3153

32-
# repo-check : check repository settings.
54+
## * docker-serve : use Docker to serve the site
55+
docker-serve :
56+
docker pull carpentries/lesson-docker:latest
57+
docker run --rm -it \
58+
-v $${PWD}:/home/rstudio \
59+
-p 4000:4000 \
60+
-p 8787:8787 \
61+
-e USERID=$$(id -u) \
62+
-e GROUPID=$$(id -g) \
63+
carpentries/lesson-docker:latest
64+
65+
## * repo-check : check repository settings
3366
repo-check :
34-
@bin/repo_check.py -s .
67+
@${PYTHON} bin/repo_check.py -s .
3568

36-
## clean : clean up junk files.
69+
## * clean : clean up junk files
3770
clean :
3871
@rm -rf ${DST}
3972
@rm -rf .sass-cache
@@ -42,22 +75,26 @@ clean :
4275
@find . -name '*~' -exec rm {} \;
4376
@find . -name '*.pyc' -exec rm {} \;
4477

45-
## clean-rmd : clean intermediate R files (that need to be committed to the repo).
78+
## * clean-rmd : clean intermediate R files (that need to be committed to the repo)
4679
clean-rmd :
4780
@rm -rf ${RMD_DST}
4881
@rm -rf fig/rmd-*
4982

50-
## ----------------------------------------
51-
## Commands specific to workshop websites.
83+
84+
##
85+
## II. Commands specific to workshop websites
86+
## =================================================
5287

5388
.PHONY : workshop-check
5489

55-
## workshop-check : check workshop homepage.
90+
## * workshop-check : check workshop homepage
5691
workshop-check :
57-
@bin/workshop_check.py .
92+
@${PYTHON} bin/workshop_check.py .
5893

59-
## ----------------------------------------
60-
## Commands specific to lesson websites.
94+
95+
##
96+
## III. Commands specific to lesson websites
97+
## =================================================
6198

6299
.PHONY : lesson-check lesson-md lesson-files lesson-fixme
63100

@@ -85,37 +122,39 @@ HTML_DST = \
85122
$(patsubst _extras/%.md,${DST}/%/index.html,$(sort $(wildcard _extras/*.md))) \
86123
${DST}/license/index.html
87124

88-
## lesson-md : convert Rmarkdown files to markdown
125+
## * lesson-md : convert Rmarkdown files to markdown
89126
lesson-md : ${RMD_DST}
90127

91128
_episodes/%.md: _episodes_rmd/%.Rmd
92129
@bin/knit_lessons.sh $< $@
93130

94-
## lesson-check : validate lesson Markdown.
131+
# * lesson-check : validate lesson Markdown
95132
lesson-check : lesson-fixme
96-
@bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md
133+
@${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md
97134

98-
## lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace.
135+
## * lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace
99136
lesson-check-all :
100-
@bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive
137+
@${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive
101138

102-
## unittest : run unit tests on checking tools.
139+
## * unittest : run unit tests on checking tools
103140
unittest :
104-
@bin/test_lesson_check.py
141+
@${PYTHON} bin/test_lesson_check.py
105142

106-
## lesson-files : show expected names of generated files for debugging.
143+
## * lesson-files : show expected names of generated files for debugging
107144
lesson-files :
108145
@echo 'RMD_SRC:' ${RMD_SRC}
109146
@echo 'RMD_DST:' ${RMD_DST}
110147
@echo 'MARKDOWN_SRC:' ${MARKDOWN_SRC}
111148
@echo 'HTML_DST:' ${HTML_DST}
112149

113-
## lesson-fixme : show FIXME markers embedded in source files.
150+
## * lesson-fixme : show FIXME markers embedded in source files
114151
lesson-fixme :
115152
@fgrep -i -n FIXME ${MARKDOWN_SRC} || true
116153

117-
#-------------------------------------------------------------------------------
118-
# Include extra commands if available.
119-
#-------------------------------------------------------------------------------
154+
##
155+
## IV. Auxililary (plumbing) commands
156+
## =================================================
120157

121-
-include commands.mk
158+
## * commands : show all commands.
159+
commands :
160+
@sed -n -e '/^##/s|^##[[:space:]]*||p' $(MAKEFILE_LIST)

_includes/aio-script.md

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,20 @@ open an issue: https://github.com/carpentries/styles/issues/new
66

77
{% include manual_episode_order.html %}
88

9-
<script>
10-
window.onload = function() {
11-
var lesson_episodes = [
12-
{% for lesson_episode in lesson_episodes %}
13-
{% if site.episode_order %}
14-
{% assign episode = site.episodes | where: "slug", lesson_episode | first %}
15-
{% else %}
16-
{% assign episode = lesson_episode %}
17-
{% endif %}
18-
"{{ episode.url}}"{% unless forloop.last %},{% endunless %}
19-
{% endfor %}
20-
];
21-
var xmlHttp = []; /* Required since we are going to query every episode. */
22-
for (i=0; i < lesson_episodes.length; i++) {
23-
xmlHttp[i] = new XMLHttpRequest();
24-
xmlHttp[i].episode = lesson_episodes[i]; /* To enable use this later. */
25-
xmlHttp[i].onreadystatechange = function() {
26-
if (this.readyState == 4 && this.status == 200) {
27-
var article_here = document.getElementById(this.episode);
28-
var parser = new DOMParser();
29-
var htmlDoc = parser.parseFromString(this.responseText,"text/html");
30-
var htmlDocArticle = htmlDoc.getElementsByTagName("article")[0];
31-
article_here.innerHTML = htmlDocArticle.innerHTML;
32-
}
33-
}
34-
var episode_url = "{{ relative_root_path }}" + lesson_episodes[i];
35-
xmlHttp[i].open("GET", episode_url);
36-
xmlHttp[i].send(null);
37-
}
38-
}
39-
</script>
9+
{% for lesson_episode in lesson_episodes %}
4010

41-
{% comment %} Create an anchor for every episode. {% endcomment %}
11+
{% if site.episode_order %}
12+
{% assign e = site.episodes | where: "slug", lesson_episode | first %}
13+
{% else %}
14+
{% assign e = lesson_episode %}
15+
{% endif %}
4216

43-
{% for lesson_episode in lesson_episodes %}
44-
{% if site.episode_order %}
45-
{% assign episode = site.episodes | where: "slug", lesson_episode | first %}
46-
{% else %}
47-
{% assign episode = lesson_episode %}
48-
{% endif %}
49-
<article id="{{ episode.url }}"></article>
17+
<h1 id="{{ e.title | slugify }}" class="maintitle">{{ e.title }}</h1>
18+
19+
{% include episode_overview.html teaching_time=e.teaching exercise_time=e.exercises episode_questions=e.questions episode_objectives=e.objectives %}
20+
21+
{{ e.content }}
22+
23+
{% include episode_keypoints.html episode_keypoints=e.keypoints %}
24+
<hr />
5025
{% endfor %}

_includes/episode_keypoints.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
{% comment %}
22
Display key points for an episode.
33
{% endcomment %}
4+
5+
{% if page.keypoints == nil %}
6+
{% assign episode_keypoints = include.episode_keypoints %}
7+
{% else %}
8+
{% assign episode_keypoints = page.keypoints %}
9+
{% endif %}
10+
411
<blockquote class="keypoints">
512
<h2>Key Points</h2>
613
<ul>
7-
{% for keypoint in page.keypoints %}
14+
{% for keypoint in episode_keypoints %}
815
<li>{{ keypoint|markdownify }}</li>
916
{% endfor %}
1017
</ul>

_includes/episode_overview.html

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,59 @@
11
{% comment %}
2-
Display an episode's timings and learning objectives.
2+
Display episode's timings and learning objectives.
3+
4+
Regarding the `if page.*** == nil` below:
5+
all-in-one page combines all episodes into one.
6+
It, therefore, does not define its own objectives, exercises,
7+
and questions, which 'normal' episodes define in the front matter.
8+
9+
To display episodes' teaching and exercise times, as well as episode
10+
questions and objectives, we pass them as parameters to the Liquid's
11+
`include` statement when we generate the page:
12+
13+
include episode_overview.html teaching_time=e.teaching ...
14+
15+
Here we obtain the information we need either from the episode itself or
16+
from the parameters passed in.
317
{% endcomment %}
18+
19+
{% if page.teaching == nil %}
20+
{% assign teaching_time = include.teaching_time %}
21+
{% else %}
22+
{% assign teaching_time = page.teaching %}
23+
{% endif %}
24+
25+
{% if page.exercises == nil %}
26+
{% assign exercise_time = include.exercise_time %}
27+
{% else %}
28+
{% assign exercise_time = page.exercises %}
29+
{% endif %}
30+
31+
{% if page.questions == nil %}
32+
{% assign episode_questions = include.episode_questions %}
33+
{% else %}
34+
{% assign episode_questions = page.questions %}
35+
{% endif %}
36+
37+
{% if page.objectives == nil %}
38+
{% assign episode_objectives = include.episode_objectives %}
39+
{% else %}
40+
{% assign episode_objectives = page.objectives %}
41+
{% endif %}
42+
43+
444
<blockquote class="objectives">
545
<h2>Overview</h2>
646

747
<div class="row">
848
<div class="col-md-3">
9-
<strong>Teaching:</strong> {{ page.teaching }} min
49+
<strong>Teaching:</strong> {{ teaching_time }} min
1050
<br/>
11-
<strong>Exercises:</strong> {{ page.exercises }} min
51+
<strong>Exercises:</strong> {{ exercise_time }} min
1252
</div>
1353
<div class="col-md-9">
1454
<strong>Questions</strong>
1555
<ul>
16-
{% for question in page.questions %}
56+
{% for question in episode_questions %}
1757
<li>{{ question|markdownify }}</li>
1858
{% endfor %}
1959
</ul>
@@ -26,7 +66,7 @@ <h2>Overview</h2>
2666
<div class="col-md-9">
2767
<strong>Objectives</strong>
2868
<ul>
29-
{% for objective in page.objectives %}
69+
{% for objective in episode_objectives %}
3070
<li>{{ objective|markdownify }}</li>
3171
{% endfor %}
3272
</ul>

_includes/links.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
[pandoc]: https://pandoc.org/
3636
[paper-now]: https://github.com/PeerJ/paper-now
3737
[python-gapminder]: https://swcarpentry.github.io/python-novice-gapminder/
38-
[pyyaml]: https://pypi.python.org/pypi/PyYAML
38+
[pyyaml]: https://pypi.org/project/PyYAML/
3939
[r-markdown]: https://rmarkdown.rstudio.com/
4040
[rstudio]: https://www.rstudio.com/
4141
[ruby-install-guide]: https://www.ruby-lang.org/en/downloads/

_includes/main_title.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,11 @@
44

55
{% include base_path.html %}
66

7+
{% if site.kind == "lesson" %}
78
<h1 class="maintitle"><a href="{{ relative_root_path }}{% link index.md %}">{{ site.title }}</a>{% if page.title %}: {{ page.title }}{% endif %}</h1>
9+
10+
{% else %}
11+
12+
<h1 class="maintitle">{{ page.title }}</h1>
13+
14+
{% endif %}

0 commit comments

Comments
 (0)