-
Notifications
You must be signed in to change notification settings - Fork 1
/
header.html
195 lines (190 loc) · 8.47 KB
/
header.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<!doctype html>
{%- include common/assignCurrentModule.html -%}
{%- if current_module -%}
{%- capture pageTitle %}{%- include common/getPageTitle.html haystack=current_module.nav_items needle=page.id -%}{%- endcapture -%}
{%- assign pageTitle = current_module.title | append: ' - ' | append: pageTitle -%}
{%- capture filePath -%}{%- include common/getFilePath.html haystack=current_module.nav_items needle=page.id -%}{%- endcapture -%}
{%- if current_module.github -%}
{%- assign gh_repo = current_module.github.owner_name | append: '/' | append: current_module.github.repository_name -%}
{%- else -%}
{%- assign gh_repo = site.repository -%}
{%- endif -%}
{%- assign pageId = current_module.basepath | append: '-' | append: page.id -%}
{%- else -%}
{%- assign gh_repo = site.repository -%}
{%- assign pageId = page.id -%}
{%- assign pageTitle = page.title -%}
{%- assign filePath = 'docs/' | append: page.name -%}
{%- endif -%}
<html lang="{{ site.lang | default: 'fi-FI' }}">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" media="screen" href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}">
<link rel="stylesheet" type="text/css" media="print" href="{{ '/assets/css/style-print.css?v=' | append: site.github.build_revision | relative_url }}">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
{%- if page.layout == "swagger-ui" -%}
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@4/swagger-ui.css">
{%- endif -%}
<title>{{ pageTitle }}</title>
{% seo %}
{% if site.google_analytics %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ site.google_analytics }}');
</script>
{% endif %}
<script src="https://polyfill.io/v3/polyfill.min.js?features=String.prototype.padStart%2Cfetch" crossorigin="anonymous"></script>
<script>
function updateModifiedField(commit) {
if (commit.commit) {
var url = commit['html_url'];
$("#last-modified").append("<span>Viimeksi muutettu <a href=\"" + url +"\" title=\""
+ commit.commit.author.name
+ ": " + commit.commit.message
+ "\">" + new Date(commit.commit.committer.date).toLocaleString()
+ "</a>");
}
}
function updateModifiedFieldWithErr(msg) {
if (msg) {
$("#last-modified").append("<span title=\"" + msg + "\">Muutostietoa ei saatavilla</span>");
}
}
function updateChangeHistoryLink(url, branch) {
if (url.repo && url.path) {
var link = "<a href=\"https://github.com/" + url.repo + "/commits";
if (branch !== "default") {
link += "/" + branch
}
link += "?path=" + url.path;
if (url.limit) {
link += "&until=" + url.limit;
}
link += "\">Sivun muutoshistoria</a>";
$("#change-history").append(link);
}
}
function setModifiedDate() {
var branch = "default";
if ("{{ current_module_version.git-branch }}" !== "") {
branch = "{{ current_module_version.git-branch }}";
}
if ("{{ filePath }}" !== "" && document.getElementById('last-modified')) {
//Check that we have a non-empty current module, should at least have a title and basepath:
if ("{{ current_module.title }}" !== "" && "{{ current_module.basepath }}" !== "") {
var request_url = "https://api.github.com/repos/{{ site.repository }}/contents/docs/";
var module_path = "{{ current_module.basepath}}";
if ("{{ current_module_version.path }}" !== "") {
module_path += "/" + "{{ current_module_version.path }}";
}
request_url += module_path;
if ("{{ site.branch }}" !== "") {
request_url += "?ref={{ site.branch | url_encode }}";
}
/*
limit the commits to the linked submodule commit date:
*/
fetch(request_url)
.then((response) => {
if (!response.ok) {
throw new Error(response.statusText);
}
return response.json();
})
.then((contents) => {
if (contents.type == 'submodule') {
var submodule_commit_sha = contents.sha;
fetch("https://api.github.com/repos/{{ gh_repo }}/commits/" + submodule_commit_sha)
.then((response) => {
return response.json();
})
.then((submodule_commit) => {
if (submodule_commit.sha == submodule_commit_sha) {
var included_commit_limit = submodule_commit.commit.committer.date;
var info = {
repo: "{{ gh_repo }}",
path: "{{ filePath }}",
limit: included_commit_limit
};
updateChangeHistoryLink(info, branch);
var url = "https://api.github.com/repos/{{ gh_repo }}/commits?path={{ filePath }}&until=" + included_commit_limit;
if (branch !== "default") {
url += "&sha=" + branch;
}
fetch(url)
.then((response) => {
return response.json();
})
.then((commits) => {
if (Array.isArray(commits)) {
updateModifiedField(commits[0]);
}
});
}
});
} else {
var info = {
repo: "{{ gh_repo }}",
path: "docs/" + module_path + "/{{ filePath }}"
};
updateChangeHistoryLink(info, branch);
var url = "https://api.github.com/repos/{{ gh_repo }}/commits?path=docs/" + module_path + "/{{ filePath }}";
fetch(url)
.then((response) => {
return response.json();
})
.then((commits) => {
if (Array.isArray(commits)) {
updateModifiedField(commits[0]);
}
});
}
})
.catch(error => {
updateModifiedFieldWithErr(error);
});
} else {
var info = {
repo: "{{ gh_repo }}",
path: "{{ filePath }}"
};
updateChangeHistoryLink(info, branch);
fetch("https://api.github.com/repos/{{ gh_repo }}/commits?path={{ filePath }}")
.then((response) => {
return response.json();
})
.then((commits) => {
if (Array.isArray(commits)) {
updateModifiedField(commits[0]);
}
});
}
}
}
</script>
</head>
<body class="page-{{ pageId }} {{ layout.style }}">
<!-- HEADER -->
<div id="header_wrap" class="outer">
<header class="thinner">
<div class="brand-container">
<a class="navbar-brand long" href="{{ site.url }}"><i class="fas fa-home"></i> {{site.name}}</a>
{%- if site.beta -%}
<div class="betatag"><span title="{{site.name}} -sivusto ei ole vielä täysin valmis">βeta</span></div>
{%- endif -%}
</div>
<a class="owner" href="https://syke.fi/">Suomen ympäristökeskus</a>
</header>
<header class="print-title-block">
<a href="{{ site.home }}"><h1 class="title">{{site.name_short}}</h1></a>
<p class="origin">Lähde: <a href="{{ site.url }}/{{ page.url }}">{{ site.url }}/{{ page.url }}</a></p>
</header>
</div>