Skip to content

Commit

Permalink
Merge https://github.com/carpentries/styles into update-styles-2021-0…
Browse files Browse the repository at this point in the history
…4-20
  • Loading branch information
zkamvar committed Apr 20, 2021
2 parents 5eee7f1 + 6ce5c22 commit 53fa84a
Show file tree
Hide file tree
Showing 14 changed files with 161 additions and 73 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ jobs:
RSPM: 'https://packagemanager.rstudio.com/cran/__linux__/focal/latest'
steps:
- name: Set up Ruby
uses: actions/setup-ruby@v1
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true

- name: Set up Python
uses: actions/setup-python@v2
Expand All @@ -44,7 +45,7 @@ jobs:

- name: Install GitHub Pages, Bundler, and kramdown gems
run: |
gem install github-pages bundler kramdown
gem install github-pages bundler kramdown kramdown-parser-gfm
- name: Install Python modules
run: |
Expand Down Expand Up @@ -96,7 +97,8 @@ jobs:
- name: Install needed packages
if: steps.check-rmd.outputs.count != 0
run: |
install.packages(setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages())))
packages = setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages()))
install.packages(packages, repo="https://cran.rstudio.com/")
shell: Rscript {0}

- name: Query dependencies
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ jobs:
shell: bash
steps:
- name: Set up Ruby
uses: actions/setup-ruby@v1
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true

- name: Set up Python
uses: actions/setup-python@v2
Expand All @@ -28,7 +29,7 @@ jobs:

- name: Install GitHub Pages, Bundler, and kramdown gems
run: |
gem install github-pages bundler kramdown
gem install github-pages bundler kramdown kramdown-parser-gfm
- name: Install Python modules
run: |
Expand Down Expand Up @@ -62,7 +63,8 @@ jobs:
- name: Install needed packages
if: steps.check-rmd.outputs.count != 0
run: |
install.packages(setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages())))
packages = setdiff(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'), rownames(installed.packages()))
install.packages(packages, repo="https://cran.rstudio.com/")
shell: Rscript {0}

- name: Query dependencies
Expand Down Expand Up @@ -97,6 +99,11 @@ jobs:
- name: Commit and Push
if: ${{ github.event_name == 'push' && steps.check-rmd.outputs.count != 0 && github.ref != 'refs/heads/gh-pages'}}
run: |
# clean up gh-pages
cd gh-pages
git rm -rf . # remove all previous files
git restore --staged . # remove things from the stage
cd ..
# copy everything into gh-pages site
cp -r `ls -A | grep -v 'gh-pages' | grep -v '.git' | grep -v '.bundle/' | grep -v '_site'` gh-pages
# move into gh-pages, add, commit, and push
Expand All @@ -105,7 +112,7 @@ jobs:
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add -A .
git commit --allow-empty -m "[Github Actions] render website (via ${{ github.sha }}"
git commit --allow-empty -m "[Github Actions] render website (via ${{ github.sha }})"
git push origin gh-pages
# return
cd ..
Expand Down
3 changes: 2 additions & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ 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 %}
[coc]: https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html
[coc-reporting]: https://docs.carpentries.org/topic_folders/policies/incident-reporting.html
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
ruby '>=2.7.1'

gem 'github-pages', group: :jekyll_plugins

if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
gem 'webrick', '>= 1.6.1'
end
46 changes: 29 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Settings
MAKEFILES=Makefile $(wildcard *.mk)
JEKYLL=bundle config --local set path .vendor/bundle && bundle install && bundle update && bundle exec jekyll
JEKYLL=bundle config set --local path .vendor/bundle && bundle install && bundle update && bundle exec jekyll
PARSER=bin/markdown_ast.rb
DST=_site

Expand All @@ -12,7 +12,7 @@ DST=_site
PYTHON3_EXE := $(shell which python3 2>/dev/null)
ifneq (, $(PYTHON3_EXE))
ifeq (,$(findstring Microsoft/WindowsApps/python3,$(subst \,/,$(PYTHON3_EXE))))
PYTHON := python3
PYTHON := $(PYTHON3_EXE)
endif
endif

Expand All @@ -21,25 +21,25 @@ ifeq (,$(PYTHON))
ifneq (, $(PYTHON_EXE))
PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))
PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL})
ifneq (3, ${PYTHON_VERSION_MAJOR})
$(error "Your system does not appear to have Python 3 installed.")
ifeq (3, ${PYTHON_VERSION_MAJOR})
PYTHON := $(PYTHON_EXE)
else
PYTHON_NOTE = "Your system does not appear to have Python 3 installed."
endif
PYTHON := python
else
$(error "Your system does not appear to have any Python installed.")
PYTHON_NOTE = "Your system does not appear to have any Python installed."
endif
endif


# Controls
.PHONY : commands clean files

# Default target
.DEFAULT_GOAL := commands

## I. Commands for both workshop and lesson websites
## =================================================

.PHONY: site docker-serve repo-check clean clean-rmd

## * serve : render website and run a local server
serve : lesson-md
${JEKYLL} serve
Expand All @@ -50,8 +50,8 @@ site : lesson-md

## * docker-serve : use Docker to serve the site
docker-serve :
docker pull carpentries/lesson-docker:latest
docker run --rm -it \
@docker pull carpentries/lesson-docker:latest
@docker run --rm -it \
-v $${PWD}:/home/rstudio \
-p 4000:4000 \
-p 8787:8787 \
Expand All @@ -60,14 +60,17 @@ docker-serve :
carpentries/lesson-docker:latest

## * repo-check : check repository settings
repo-check :
repo-check : python
@${PYTHON} bin/repo_check.py -s .

## * clean : clean up junk files
clean :
@rm -rf ${DST}
@rm -rf .sass-cache
@rm -rf bin/__pycache__
@rm -rf .vendor
@rm -rf .bundle
@rm -f Gemfile.lock
@find . -name .DS_Store -exec rm {} \;
@find . -name '*~' -exec rm {} \;
@find . -name '*.pyc' -exec rm {} \;
Expand All @@ -85,7 +88,7 @@ clean-rmd :
.PHONY : workshop-check

## * workshop-check : check workshop homepage
workshop-check :
workshop-check : python
@${PYTHON} bin/workshop_check.py .


Expand Down Expand Up @@ -128,18 +131,18 @@ lesson-md : ${RMD_DST}

_episodes/%.md: _episodes_rmd/%.Rmd install-rmd-deps
@mkdir -p _episodes
@bin/knit_lessons.sh $< $@
@$(SHELL) bin/knit_lessons.sh $< $@

## * lesson-check : validate lesson Markdown
lesson-check : lesson-fixme
lesson-check : python lesson-fixme
@${PYTHON} 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 :
lesson-check-all : python
@${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive

## * unittest : run unit tests on checking tools
unittest :
unittest : python
@${PYTHON} bin/test_lesson_check.py

## * lesson-files : show expected names of generated files for debugging
Expand All @@ -157,6 +160,15 @@ lesson-fixme :
## IV. Auxililary (plumbing) commands
## =================================================

.PHONY : commands python

## * commands : show all commands.
commands :
@sed -n -e '/^##/s|^##[[:space:]]*||p' $(MAKEFILE_LIST)

python :
ifeq (, $(PYTHON))
$(error $(PYTHON_NOTE))
else
@:
endif
54 changes: 34 additions & 20 deletions _includes/base_path.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
{% comment %}
This is adapted from: https://ricostacruz.com/til/relative-paths-in-jekyll
{%- comment -%}
When the website is built by GitHub Pages,
'site.url' is set to 'https://username.github.io'
'site.baseurl' is set to '/lesson-name'

`page.url` gives the URL of the current page with a leading /:
When we start a local server using `jekyll serve`,
'site.url' is set to 'http://localhost:4000' and
'site.baseurl' is empty.

- when the URL ends with the extension (e.g., /foo/bar.html) then we can get
the depth by counting the number of / and remove - 1
- when the URL ends with a / (e.g. /foo/bar/) then the number / gives the depth
directly
{% endcomment %}
In both of the above cases we set 'relative_root_path' to 'site.url + site.baseurl'.

{% assign relative_root_path = '' %}
When we build a website locally with `jekyll build`,
both 'site.url' and 'site.baseurl' are empty.
This case is handled by the last 'else' in the code below.
The logic there follows the (adapted) instructions found at:
https://ricostacruz.com/til/relative-paths-in-jekyll

{% assign last_char = page.url | slice: -1 %}
`page.url` gives the URL of the current page with a leading /:

{% if last_char == "/"}
{% assign offset = 0 %}
{% else %}
{% assign offset = 1 %}
{% endif %}
- when the URL ends with an extension (e.g., /foo/bar.html),
we can get the 'depth' of the page by counting the number of
forward slashes ('/') and subtracting 1
- when the URL ends with a forward slash (e.g. /foo/bar/),
we can get the depth of the page by counting the number of /
{%- endcomment -%}

{% assign depth = page.url | split: '/' | size | minus: offset %}
{% if depth <= 1 %}{% assign relative_root_path = '.' %}
{% elsif depth == 2 %}{% assign relative_root_path = '..' %}
{% elsif depth == 3 %}{% assign relative_root_path = '../..' %}
{% elsif depth == 4 %}{% assign relative_root_path = '../../..' %}
{% if site.url %}
{% assign relative_root_path = site.url | append: site.baseurl %}
{% else %}
{% assign last_char = page.url | slice: -1 %}
{% if last_char == "/" %}
{% assign offset = 0 %}
{% else %}
{% assign offset = 1 %}
{% endif %}
{% assign depth = page.url | split: '/' | size | minus: offset %}
{% if depth <= 1 %}{% assign relative_root_path = '.' %}
{% elsif depth == 2 %}{% assign relative_root_path = '..' %}
{% else %}{% capture relative_root_path %}..{% for i in (3..depth) %}/..{% endfor %}{% endcapture %}
{% endif %}
{% endif %}
2 changes: 1 addition & 1 deletion _includes/links.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[cran-stringr]: https://cran.r-project.org/package=stringr
[dc-lessons]: http://www.datacarpentry.org/lessons/
[email]: mailto:[email protected]
[github-importer]: https://import.github.com/
[github-importer]: https://import2.github.com/
[importer]: https://github.com/new/import
[jekyll-collection]: https://jekyllrb.com/docs/collections/
[jekyll-install]: https://jekyllrb.com/docs/installation/
Expand Down
55 changes: 45 additions & 10 deletions assets/css/lesson.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,32 @@ div.error::before { background-color: #ffebe6; content: "Error"; }
div.warning:before { background-color: #f8f4e8; content:" Warning"; }
div.output::before { background-color: #efefef; content: "Output"; }

div.language-bash::before { content: "Bash"; }
div.language-c::before { content: "C"; }
div.language-cmake::before { content: "CMake"; }
div.language-cpp::before { content: "C++"; }
div.language-html::before { content: "HTML"; }
div.language-make::before { content: "Make"; }
div.language-matlab::before { content: "MATLAB"; }
div.language-python::before { content: "Python"; }
div.language-r::before { content: "R"; }
div.language-sql::before { content: "SQL"; }
div.language-basic::before { content: "Basic"; }
div.language-bash::before { content: "Bash"; }
div.language-c::before { content: "C"; }
div.language-chapel::before { content: "Chapel"; }
div.language-cmake::before { content: "CMake"; }
div.language-cpp::before { content: "C++"; }
div.language-cuda::before { content: "Cuda"; }
div.language-d::before { content: "D"; }
div.language-fortran::before { content: "Fortran"; }
div.language-go::before { content: "Go"; }
div.language-html::before { content: "HTML"; }
div.language-java::before { content: "Java"; }
div.language-julia::before { content: "Julia"; }
div.language-kotlin::before { content: "Kotlin"; }
div.language-lua::before { content: "Lua"; }
div.language-make::before { content: "Make"; }
div.language-matlab::before { content: "MATLAB"; }
div.language-opencl::before { content: "OpenCL"; }
div.language-perl::before { content: "Perl"; }
div.language-python::before { content: "Python"; }
div.language-r::before { content: "R"; }
div.language-ruby::before { content: "Ruby"; }
div.language-rust::before { content: "Rust"; }
div.language-scala::before { content: "Scala"; }
div.language-sql::before { content: "SQL"; }
div.language-vulkan::before { content: "Vulkan"; }

// Tab panels are used on Setup pages to show instructions for different Operating Systems
.tab-pane {
Expand Down Expand Up @@ -210,6 +226,20 @@ a code {
color: #006cad;
}

a:link {
color: #196EBD;
}

a:active,
a:hover {
outline: 0;
text-decoration: underline;
}

a:visited {
color: #1AA4DA;
}

code {
white-space: nowrap;
padding: 2px 5px;
Expand Down Expand Up @@ -287,6 +317,11 @@ span.fold-unfold {
}


p.image-with-shadow img,
img.image-with-shadow {
box-shadow: 0 6px 24px 0 #888;
}

//----------------------------------------
// Life cycle box
//----------------------------------------
Expand Down
Loading

0 comments on commit 53fa84a

Please sign in to comment.