Skip to content

Commit

Permalink
Merge pull request carpentries#339 from zkamvar/update-styles-2021-04-20
Browse files Browse the repository at this point in the history
Update styles 2021-04-20
  • Loading branch information
maxim-belkin authored Apr 21, 2021
2 parents ba38508 + 53fa84a commit e62d461
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 35 deletions.
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 %}
36 changes: 26 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
10 changes: 5 additions & 5 deletions bin/boilerplate/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ There are many ways to contribute,
from writing new exercises and improving existing ones
to updating or filling in the documentation
and submitting [bug reports][issues]
about things that do not work, aren not clear, or are missing.
about things that do not work, are not clear, or are missing.
If you are looking for ideas, please see the 'Issues' tab for
a list of issues associated with this repository,
or you may also look at the issues for [Data Carpentry][dc-issues],
Expand All @@ -94,7 +94,7 @@ and (b) explain what you would take out to make room for it.
The first encourages contributors to be honest about requirements;
the second, to think hard about priorities.

We are also not looking for exercises or other material that only run on one platform.
We are also not looking for exercises or other material that will only run on one platform.
Our workshops typically contain a mixture of Windows, macOS, and Linux users;
in order to be usable,
our lessons must run equally well on all three.
Expand All @@ -104,7 +104,7 @@ our lessons must run equally well on all three.
If you choose to contribute via GitHub, you may want to look at
[How to Contribute to an Open Source Project on GitHub][how-contribute].
To manage changes, we follow [GitHub flow][github-flow].
Each lesson has two maintainers who review issues and pull requests or encourage others to do so.
Each lesson has at least two maintainers who review issues and pull requests or encourage others to do so.
The maintainers are community volunteers and have final say over what gets merged into the lesson.
To use the web interface for contributing to a lesson:

Expand All @@ -128,12 +128,12 @@ repository for reference while revising.

## Other Resources

General discussion of [Software Carpentry][swc-site] and [Data Carpentry][dc-site]
General discussion of [Software Carpentry][swc-site], [Data Carpentry][dc-site], and [Library Carpentry][lc-site]
happens on the [discussion mailing list][discuss-list],
which everyone is welcome to join.
You can also [reach us by email][email].

[email]: mailto:admin@software-carpentry.org
[email]: mailto:team@carpentries.org
[dc-issues]: https://github.com/issues?q=user%3Adatacarpentry
[dc-lessons]: http://datacarpentry.org/lessons/
[dc-site]: http://datacarpentry.org/
Expand Down

0 comments on commit e62d461

Please sign in to comment.