forked from carpentries/lesson-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge https://github.com/carpentries/styles into update-styles-2021-0…
…4-20
- Loading branch information
Showing
14 changed files
with
161 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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: | | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 .. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.