Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
swc-bb
swc-pages
2019-11-26-Potsdam-Berlin-Python
Commits
d32a598f
Commit
d32a598f
authored
Aug 27, 2018
by
François Michonneau
Browse files
refactor to avoid errors when rendering locally
parent
feeb525b
Changes
6
Hide whitespace changes
Inline
Side-by-side
_includes/gh_
default_branch
.html
→
_includes/gh_
variables
.html
View file @
d32a598f
{% comment %}
identify the default branch of the GitHub repo for the lesson, to create the correct link for "Improve on GitHub"
When rendering websites locally, `site.github.url` doesn't get resolved
properly unless GitHub PAT are set up and available in the environment.
This leads to warnings and errors when trying to serve the site locally.
To work around this, we use the `jekyll.environment` variable which is set to
`development` when rendering the site locally, and set to `production` on
GitHub where `site.github.url` will be defined.
{% endcomment %}
{% if jekyll.environment == "production" %}
{% comment %}
First, get the name of the repository
{% endcomment %}
...
...
@@ -17,3 +24,22 @@ of the metadata that is relevant to the present repository.
Now, we can extract the default branch for the repo
{% endcomment %}
{% assign default_branch = repo_info[0].default_branch %}
{% comment %}
Other variables requested by the template
{% endcomment %}
{% assign repo_url = site.github.repository_url %}
{% assign search_domain_url = site.github.url %}
{% assign project_title = site.github.project_title %}
{% assign source_branch = site.github.source.branch %}
{% elsif jekyll.environment == "development" %}
{% assign repo_name = "" %}
{% assign repo_url = "" %}
{% assign default_branch = "" %}
{% assign search_domain_url = "" %}
{% assign project_title = "" %}
{% assign source_branch = "" %}
{% endif %}
_includes/lesson_footer.html
View file @
d32a598f
...
...
@@ -2,7 +2,7 @@
Footer for lesson pages.
{% endcomment %}
{% include gh_
default_branch
.html %}
{% include gh_
variables
.html %}
<footer>
<div
class=
"row"
>
...
...
@@ -30,17 +30,17 @@
<div
class=
"col-md-6 help-links"
align=
"right"
>
{% if page.source %}
{% if page.source == "Rmd" %}
<a
href=
"{{
site.github.repository
_url}}/edit/{{ default_branch }}/{{page.path|replace: "
_episodes
",
"
_episodes_rmd
"
|
replace:
".
md
",
".
Rmd
"}}"
>
Edit on GitHub
</a>
<a
href=
"{{
repo
_url}}/edit/{{ default_branch }}/{{page.path|replace: "
_episodes
",
"
_episodes_rmd
"
|
replace:
".
md
",
".
Rmd
"}}"
>
Edit on GitHub
</a>
{% endif %}
{% else %}
<a
href=
"{{
site.github.repository
_url}}/edit/{{ default_branch }}/{{page.path}}"
>
Edit on GitHub
</a>
<a
href=
"{{
repo
_url}}/edit/{{ default_branch }}/{{page.path}}"
>
Edit on GitHub
</a>
{% endif %}
/
<a
href=
"{{
site.github.repository
_url }}/blob/{{
site.github.
source
.
branch }}/CONTRIBUTING.md"
>
Contributing
</a>
<a
href=
"{{
repo
_url }}/blob/{{ source
_
branch }}/CONTRIBUTING.md"
>
Contributing
</a>
/
<a
href=
"{{
site.github.repository
_url }}/"
>
Source
</a>
<a
href=
"{{
repo
_url }}/"
>
Source
</a>
/
<a
href=
"{{
site.github.repository
_url }}/blob/{{
site.github.
source
.
branch }}/CITATION"
>
Cite
</a>
<a
href=
"{{
repo
_url }}/blob/{{ source
_
branch }}/CITATION"
>
Cite
</a>
/
<a
href=
"mailto:{{ site.email }}"
>
Contact
</a>
</div>
...
...
_includes/links.md
View file @
d32a598f
{% include gh_variables.html %}
[
cc-by-human
]:
https://creativecommons.org/licenses/by/4.0/
[
cc-by-legal
]:
https://creativecommons.org/licenses/by/4.0/legalcode
[
ci
]:
http://communityin.org/
...
...
@@ -5,7 +7,7 @@
[
coc
]:
https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html
[
concept-maps
]:
https://carpentries.github.io/instructor-training/05-memory/
[
contrib-covenant
]:
https://contributor-covenant.org/
[
contributing
]:
{{
site.github.repository_url }}/blob/gh-pages
/CONTRIBUTING.md
[
contributing
]:
{{
repo_url }}/blob/{{ source_branch }}
/CONTRIBUTING.md
[
cran-checkpoint
]:
https://cran.r-project.org/package=checkpoint
[
cran-knitr
]:
https://cran.r-project.org/package=knitr
[
cran-stringr
]:
https://cran.r-project.org/package=stringr
...
...
_includes/navbar.html
View file @
d32a598f
...
...
@@ -2,7 +2,7 @@
Lesson navigation bar.
{% endcomment %}
{% include gh_
default_branch
.html %}
{% include gh_
variables
.html %}
<nav
class=
"navbar navbar-default"
>
<div
class=
"container-fluid"
>
...
...
@@ -77,10 +77,10 @@
<li><a
href=
"{{ relative_root_path }}{% link LICENSE.md %}"
>
License
</a></li>
{% if page.source %}
{% if page.source == "Rmd" %}
<li><a
href=
"{{
site.github.repository
_url}}/edit/{{ default_branch }}/{{page.path|replace: "
_episodes
",
"
_episodes_rmd
"
|
replace:
".
md
",
".
Rmd
"}}"
>
Improve this page
<span
class=
"glyphicon glyphicon-pencil"
aria-hidden=
"true"
></span></a></li>
<li><a
href=
"{{
repo
_url}}/edit/{{ default_branch }}/{{page.path|replace: "
_episodes
",
"
_episodes_rmd
"
|
replace:
".
md
",
".
Rmd
"}}"
>
Improve this page
<span
class=
"glyphicon glyphicon-pencil"
aria-hidden=
"true"
></span></a></li>
{% endif %}
{% else %}
<li><a
href=
"{{
site.github.repository
_url}}/edit/{{ default_branch}}/{{page.path}}"
>
Improve this page
<span
class=
"glyphicon glyphicon-pencil"
aria-hidden=
"true"
></span></a></li>
<li><a
href=
"{{
repo
_url}}/edit/{{ default_branch}}/{{page.path}}"
>
Improve this page
<span
class=
"glyphicon glyphicon-pencil"
aria-hidden=
"true"
></span></a></li>
{% endif %}
</ul>
<form
class=
"navbar-form navbar-right"
role=
"search"
id=
"search"
onsubmit=
"google_search(); return false;"
>
...
...
_layouts/base.html
View file @
d32a598f
---
---
{% comment %}
When rendering websites locally, `site.github.url` doesn't get resolved
properly unless GitHub PAT are set up and available in the environment.
This leads to warnings and errors when trying to serve the site locally.
To work around this, we use the `jekyll.environment` variable which is set to
`development` when rendering the site locally, and set to `production` on
GitHub where `site.github.url` will be defined.
{% endcomment %}
{% if jekyll.environment == "development" %}
{% assign search_domain_url = "" %}
{% elsif jekyll.environment == "production" %}
{% assign search_domain_url = site.github.url %}
{% endif %}
{% include base_path.html %}
{% include gh_variables.html %}
<!doctype html>
<html
lang=
"en"
>
...
...
_layouts/workshop.html
View file @
d32a598f
---
---
{% include base_path.html %}
{% include gh_variables.html %}
<!doctype html>
<html
lang=
"en"
>
<head>
<meta
name=
"slug"
content=
"{{
site.github.
project_title}}"
/>
<meta
name=
"slug"
content=
"{{project_title}}"
/>
<meta
name=
"startdate"
content=
"{{page.startdate}}"
/>
<meta
name=
"enddate"
content=
"{{page.enddate}}"
/>
<meta
name=
"humandate"
content=
"{{page.humandate}}"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment