Skip to content

Commit

Permalink
Carpentries style
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyhodges authored and tischi committed Jul 18, 2019
1 parent b617e91 commit 8870468
Show file tree
Hide file tree
Showing 215 changed files with 12,664 additions and 114 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.sass-cache*
Gemfile.lock
_site*
.travis.yml
19 changes: 9 additions & 10 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
image: ruby:2.5

variables:
JEKYLL_ENV: production
LC_ALL: C.UTF-8

before_script:
- bundle install

test:
stage: test
script:
- bundle exec jekyll build -d test
artifacts:
paths:
- test
- apt-get -y update
- apt-get install -y python3
- apt-get install -y python3-pip
- gem install json kramdown jekyll
- pip3 install pyyaml

pages:
stage: deploy
script:
- bundle exec jekyll build -d public
- make --always-make site
artifacts:
paths:
- public
only:
- master
- carpentries-style
- theme
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FIXME: list authors' names and email addresses.
1 change: 1 addition & 0 deletions CITATION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FIXME: describe how to cite this lesson.
11 changes: 11 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
layout: page
title: "Contributor Code of Conduct"
---
As contributors and maintainers of this project,
we pledge to follow the [Carpentry Code of Conduct][coc].

Instances of abusive, harassing, or otherwise unacceptable behavior
may be reported by following our [reporting guidelines][coc-reporting].

{% include links.md %}
13 changes: 0 additions & 13 deletions Gemfile

This file was deleted.

121 changes: 121 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
## ========================================
## Commands for both workshop and lesson websites.

# Settings
MAKEFILES=Makefile $(wildcard *.mk)
JEKYLL=jekyll
JEKYLL_VERSION=3.8.5
PARSER=bin/markdown_ast.rb
DST=public

# Controls
.PHONY : commands clean files
.NOTPARALLEL:
all : commands

## commands : show all commands.
commands :
@grep -h -E '^##' ${MAKEFILES} | sed -e 's/## //g'

## docker-serve : use docker to build the site
docker-serve :
docker run --rm -it -v ${PWD}:/srv/jekyll -p 127.0.0.1:4000:4000 jekyll/jekyll:${JEKYLL_VERSION} make serve

## serve : run a local server.
serve : lesson-md
${JEKYLL} serve

## site : build files but do not run a server.
site : lesson-md
${JEKYLL} build -d ${DST}

# repo-check : check repository settings.
repo-check :
@bin/repo_check.py -s .

## clean : clean up junk files.
clean :
@rm -rf ${DST}
@rm -rf .sass-cache
@rm -rf bin/__pycache__
@find . -name .DS_Store -exec rm {} \;
@find . -name '*~' -exec rm {} \;
@find . -name '*.pyc' -exec rm {} \;

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

## ----------------------------------------
## Commands specific to workshop websites.

.PHONY : workshop-check

## workshop-check : check workshop homepage.
workshop-check :
@bin/workshop_check.py .

## ----------------------------------------
## Commands specific to lesson websites.

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

# RMarkdown files
RMD_SRC = $(wildcard _episodes_rmd/??-*.Rmd)
RMD_DST = $(patsubst _episodes_rmd/%.Rmd,_episodes/%.md,$(RMD_SRC))

# Lesson source files in the order they appear in the navigation menu.
MARKDOWN_SRC = \
index.md \
CODE_OF_CONDUCT.md \
setup.md \
$(sort $(wildcard _episodes/*.md)) \
reference.md \
$(sort $(wildcard _extras/*.md)) \
LICENSE.md

# Generated lesson files in the order they appear in the navigation menu.
HTML_DST = \
${DST}/index.html \
${DST}/conduct/index.html \
${DST}/setup/index.html \
$(patsubst _episodes/%.md,${DST}/%/index.html,$(sort $(wildcard _episodes/*.md))) \
${DST}/reference/index.html \
$(patsubst _extras/%.md,${DST}/%/index.html,$(sort $(wildcard _extras/*.md))) \
${DST}/license/index.html

## lesson-md : convert Rmarkdown files to markdown
lesson-md : ${RMD_DST}

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

## lesson-check : validate lesson Markdown.
lesson-check : lesson-fixme
@bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md

## lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace.
lesson-check-all :
@bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive

## unittest : run unit tests on checking tools.
unittest :
@bin/test_lesson_check.py

## lesson-files : show expected names of generated files for debugging.
lesson-files :
@echo 'RMD_SRC:' ${RMD_SRC}
@echo 'RMD_DST:' ${RMD_DST}
@echo 'MARKDOWN_SRC:' ${MARKDOWN_SRC}
@echo 'HTML_DST:' ${HTML_DST}

## lesson-fixme : show FIXME markers embedded in source files.
lesson-fixme :
@fgrep -i -n FIXME ${MARKDOWN_SRC} || true

#-------------------------------------------------------------------------------
# Include extra commands if available.
#-------------------------------------------------------------------------------

-include commands.mk
48 changes: 43 additions & 5 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
title: Image Analysis Training
email: image-analysis-support@embl.de
title: "Image Analysis Training"
email: "image-analysis-support@embl.de"
description: > # this means to ignore newlines until "baseurl:"
A collection of material for teaching image analysis.
Includes concept maps, exercises, example data
Expand All @@ -8,11 +8,49 @@ url: "https://grp-bio-it.embl-community.io/" # the base hostname & protocol for
contributing: CONTRIBUTING

# Build settings
markdown: CommonMarkGhPages
commonmark:
options: ["SMART"]
# Turn on built-in syntax highlighting.
highlighter: rouge
exclude: ["README.md", "TEACHING.md"]

# options are: "NONE", "ImageJ GUI", "ImageJ Macro", "Jython", "MATLAB"
default-platform: "NONE"

life_cycle: "pre-alpha"
kind: "lesson"

# Sites
repo_url: "https://git.embl.de/grp-bio-it/image-analysis-training-resources"
cc_by_human: "https://creativecommons.org/licenses/by/4.0/"

# Specify that things in the episodes collection should be output.
collections:
modules:
output: true
permalink: /:path/index.html
extras:
output: true
permalink: /:path/index.html

# Set the default layout for things in the modules collection.
defaults:
- values:
root: .
layout: page
- scope:
path: ""
type: modules
values:
root: ..
layout: module
- scope:
path: ""
type: extras
values:
root: ..
layout: page

# Files and directories that are not to be copied.
exclude:
- Makefile
- bin/
- .Rproj.user/
Empty file added _extras/.gitkeep
Empty file.
5 changes: 5 additions & 0 deletions _extras/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: About
---
{% include carpentries.html %}
{% include links.md %}
6 changes: 6 additions & 0 deletions _extras/discuss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Discussion
---
FIXME

{% include links.md %}
68 changes: 68 additions & 0 deletions _extras/figures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
title: Figures
---

{% include base_path.html %}

<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 parser = new DOMParser();
var htmlDoc = parser.parseFromString(this.responseText,"text/html");
var htmlDocArticle = htmlDoc.getElementsByTagName("article")[0];

var article_here = document.getElementById(this.episode);
var images = htmlDocArticle.getElementsByTagName("img");

if (images.length > 0) {
var h1text = htmlDocArticle.getElementsByTagName("h1")[0].innerHTML;

var htitle = document.createElement('h2');
htitle.innerHTML = h1text;
article_here.appendChild(htitle);

var image_num = 0;
for (let image of images) {
image_num++;

var title = document.createElement('p');
title.innerHTML = "<strong>Figure " + image_num + ".</strong> " + image.alt;
article_here.appendChild(title);

article_here.appendChild(image.cloneNode(false));

if (image_num < images.length) {
var hr = document.createElement('hr');
article_here.appendChild(hr);
}
}
}
}
}
episode_url = "{{ relative_root_path }}" + 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 }}" class="figures"></article>
{% endfor %}

{% include links.md %}
6 changes: 6 additions & 0 deletions _extras/guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: "Instructor Notes"
---
FIXME

{% include links.md %}
38 changes: 38 additions & 0 deletions _includes/aio-script.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% comment %}
As a maintainer, you don't need to edit this file.
If you notice that something doesn't work, please
open an issue: https://github.com/carpentries/styles/issues/new
{% endcomment %}

<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;
}
}
var episode_url = "{{ relative_root_path }}" + lesson_episodes[i];
xmlHttp[i].open("GET", episode_url);
xmlHttp[i].send(null);
}
}
</script>
{% comment %}
Create an anchor for every episode.
{% endcomment %}
{% for episode in site.episodes %}
<article id="{{ episode.url }}"></article>
{% endfor %}
Loading

0 comments on commit 8870468

Please sign in to comment.