-
Notifications
You must be signed in to change notification settings - Fork 5
/
navbar.html
147 lines (135 loc) · 7.82 KB
/
navbar.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
{% comment %}
Lesson navigation bar.
{% endcomment %}
{% include gh_variables.html %}
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
{% comment %} Select what logo to display. {% endcomment %}
{% if site.carpentry == "swc" %}
<a href="{{ site.swc_site }}" class="pull-left">
<img class="navbar-logo" src="{{ '/assets/img/swc-icon-blue.svg' | absolute_url }}" alt="Software Carpentry logo" />
</a>
{% elsif site.carpentry == "dc" %}
<a href="{{ site.dc_site }}" class="pull-left">
<img class="navbar-logo" src="{{ '/assets/img/dc-icon-black.svg' | absolute_url }}" alt="Data Carpentry logo" />
</a>
{% elsif site.carpentry == "lc" %}
<a href="{{ site.lc_site }}" class="pull-left">
<img class="navbar-logo" src="{{ '/assets/img/lc-icon-black.png' | absolute_url }}" alt="Library Carpentry logo" />
</a>
{% elsif site.carpentry == "cp" %}
<a href="{{ site.carpentries_site }}" class="pull-left">
<img class="navbar-logo" src="{{ '/assets/img/cp-logo-blue.svg' | absolute_url }}" alt="The Carpentries logo" />
</a>
{% endif %}
{% comment %} Always show link to home page. {% endcomment %}
{% assign indexurl = include.pathLocale | append: "index/" | absolute_url %}
<a class="navbar-brand" href="{{ indexurl }}">{{ include.language.index }}</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
{% comment %} Always show code of conduct. {% endcomment %}
{% assign CoCurl = include.pathLocale | append: "conduct/" | absolute_url %}
<li><a href="{{ CoCurl}}">{{ include.language.CoC }}</a></li>
{% if site.kind == "lesson" %}
{% comment %} Show setup instructions. {% endcomment %}
{% assign setupurl = include.pathLocale | append: "setup/" | absolute_url %}
<li><a href="{{ setupurl }}">{{ include.language.setup }}</a></li>
{% comment %} Show lesson episodes for lessons. {% endcomment %}
<li class="dropdown">
<a href="{{ page.root }}/" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ include.language.episodes }} <span class="caret"></span></a>
<ul class="dropdown-menu">
{% for episode in episodes %}
<li><a href="{{ episode.url | absolute_url }}">{{ episode.title }}</a></li><!-- NOTE: Check whether this works on github where root is different than localhost; also for extras and others. -->
{% endfor %}
<li role="separator" class="divider"></li>
{% assign aiourl = include.pathLocale | append: "aio/" | absolute_url %}
<li><a href="{{ aiourl }}">{{ include.language.aio }} (Beta)</a></li>
</ul>
</li>
{% endif %}
{% comment %} Show extras for lessons or if this is the main workshop-template repo (where they contain documentation). {% endcomment %}
{% if site.kind == "lesson" %}
<li class="dropdown">
<a href="{{ page.root }}/" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ include.language.extras }} <span class="caret"></span></a>
<ul class="dropdown-menu">
{% assign referenceurl = include.pathLocale | append: "reference/" | absolute_url %}
<li><a href="{{ referenceurl }}">{{ include.language.reference }}</a></li>
{% for extra in extras %}
<li><a href="{{ extra.url | absolute_url }}">{{ extra.title }}</a></li>
{% endfor %}
</ul>
</li>
{% endif %}
{% comment %} Always show license. {% endcomment %}
{% assign licenseurl = include.pathLocale | append: "LICENSE/" | absolute_url %}
<li><a href="{{ licenseurl}}">{{ include.language.LICENSE }}</a></li>
{% if page.source %}
{% if page.source == "Rmd" %}
<li><a href="{{site.github.repository_url}}/edit/gh-pages/{{page.path|replace: "_episodes", "_episodes_rmd" | replace: ".md", ".Rmd"}}">{{ include.language.improve }}<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a></li>
{% endif %}
{% else %}
<li><a href="{{site.github.repository_url}}/edit/gh-pages/{{page.path}}">{{ include.language.improve }}<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a></li>
{% endif %}
{% comment %} Adding languages if they exists {% endcomment %}
{% if site.kind == "lesson" and site.locale %}
<li class="dropdown">
<a href="{{ page.root }}/" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-globe" aria-hidden="true"></span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
{% assign current_page = page.path | split: "/" | last %}
{% if page.path contains "locale" %}
{% comment %} Check whether the page is a root page {% endcomment %}
{% assign allpages = site.pages | map: "path" %}
{% if allpages contains current_page %}
{% assign path_current_original = site.pages | where_exp: "spage", "spage.path contains current_page" | map: "url" | first %}
{% assign path_word = current_page | replace: ".md", "" %}
<li><a href="{{ path_current_original | absolute_url }}">en: {{ include.language_en[path_word] }}</a>
{% else %}
{% comment %} Looking for episodes {% endcomment %}
{% for episode in site.episodes %}
{% capture original_episode %}{{ episode.path | split: "/" | last }}{% endcapture %}
{% if original_episode == current_page %}
<li><a href="{{ episode.url | absolute_url }}">en: {{ episode.title }}</a>
{% endif %}
{% endfor %}
{% comment %} Looking for extras {% endcomment %}
{% for extra in site.extras %}
{% capture original_extra %}{{ extra.path | split: "/" | last }}{% endcapture %}
{% if original_extra == current_page %}
<li><a href="{{ extra.url | absolute_url }}">en: {{ extra.title }}</a>
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% comment %} Generate the links for the other possible translations {% endcomment %}
{% for translated_page in site.locale %}
{% if translated_page.path != page.path %} {% comment %} to skip the current page {% endcomment %}
{% assign langfilename = translated_page.path | split: "/" | last %}
{% assign thislanguage = translated_page.path | remove: "_locale/" | split: "/" | first %}
{% if page.path contains langfilename %} {% comment %} So it's the translation of the page {% endcomment %}
<li><a href="{{ translated_page.url | absolute_url }}">{{ thislanguage }}: {{ translated_page.title}}</a></li>
{% endif %}
{% endif %}
{% endfor %}
</ul>
</li>
{% endif %}
</ul>
<form class="navbar-form navbar-right" role="search" id="search" onsubmit="google_search(); return false;">
<div class="form-group">
<input type="text" id="google-search" placeholder="{{ include.language.search }}..." aria-label="Google site search">
</div>
</form>
</div>
</div>
</nav>