Skip to content

Commit 8fc57d0

Browse files
committed
feat: display version
Signed-off-by: Mateusz Urbanek <[email protected]>
1 parent 3ef2987 commit 8fc57d0

File tree

5 files changed

+345
-0
lines changed

5 files changed

+345
-0
lines changed

docs/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
book
2+
theme/index.hbs

docs/book.toml

+5
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ authors = ["The Kubernetes Authors"]
66
[output.html]
77
git-repository-url = "https://github.com/kubernetes-sigs/container-object-storage-interface/tree/main/docs"
88
edit-url-template = "https://github.com/kubernetes-sigs/container-object-storage-interface/tree/main/docs/{path}"
9+
additional-css = ["custom.css"]
10+
11+
[preprocessor.generate-version]
12+
renderers = ["html"]
13+
command = """sh -c 'scripts/generate-version.sh'"""

docs/custom.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#version {
2+
font-size: .75em;
3+
}

docs/scripts/generate-version.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
jq ".[1]";
2+
SHA=$(git rev-parse HEAD)
3+
VERSION="Built from: <a target="_blank" href=\"https:\/\/github.com\/kubernetes-sigs\/container-object-storage-interface\/tree\/${SHA}\"><code>${SHA}<\/code><\/a>"
4+
TAG=$(git tag --contains "$SHA" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$')
5+
if [ -n "$TAG" ]; then
6+
VERSION="Version: <a target="_blank" href=\"https:\/\/github.com\/kubernetes-sigs\/container-object-storage-interface\/tree\/${TAG}\"><code>${TAG}<\/code><\/a> ${VERSION}"
7+
fi
8+
sed "s/VERSION-PLACEHOLDER/${VERSION}/" theme/index-template.hbs > theme/index.hbs

docs/theme/index-template.hbs

+328
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
<!DOCTYPE HTML>
2+
<html lang="{{ language }}" class="{{ default_theme }} sidebar-visible" dir="{{ text_direction }}">
3+
<head>
4+
<!-- Book generated using mdBook -->
5+
<meta charset="UTF-8">
6+
<title>{{ title }}</title>
7+
{{#if is_print }}
8+
<meta name="robots" content="noindex">
9+
{{/if}}
10+
{{#if base_url}}
11+
<base href="{{ base_url }}">
12+
{{/if}}
13+
14+
15+
<!-- Custom HTML head -->
16+
{{> head}}
17+
18+
<meta name="description" content="{{ description }}">
19+
<meta name="viewport" content="width=device-width, initial-scale=1">
20+
<meta name="theme-color" content="#ffffff">
21+
22+
{{#if favicon_svg}}
23+
<link rel="icon" href="{{ path_to_root }}favicon.svg">
24+
{{/if}}
25+
{{#if favicon_png}}
26+
<link rel="shortcut icon" href="{{ path_to_root }}favicon.png">
27+
{{/if}}
28+
<link rel="stylesheet" href="{{ path_to_root }}css/variables.css">
29+
<link rel="stylesheet" href="{{ path_to_root }}css/general.css">
30+
<link rel="stylesheet" href="{{ path_to_root }}css/chrome.css">
31+
{{#if print_enable}}
32+
<link rel="stylesheet" href="{{ path_to_root }}css/print.css" media="print">
33+
{{/if}}
34+
35+
<!-- Fonts -->
36+
<link rel="stylesheet" href="{{ path_to_root }}FontAwesome/css/font-awesome.css">
37+
{{#if copy_fonts}}
38+
<link rel="stylesheet" href="{{ path_to_root }}fonts/fonts.css">
39+
{{/if}}
40+
41+
<!-- Highlight.js Stylesheets -->
42+
<link rel="stylesheet" href="{{ path_to_root }}highlight.css">
43+
<link rel="stylesheet" href="{{ path_to_root }}tomorrow-night.css">
44+
<link rel="stylesheet" href="{{ path_to_root }}ayu-highlight.css">
45+
46+
<!-- Custom theme stylesheets -->
47+
{{#each additional_css}}
48+
<link rel="stylesheet" href="{{ ../path_to_root }}{{ this }}">
49+
{{/each}}
50+
51+
{{#if mathjax_support}}
52+
<!-- MathJax -->
53+
<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
54+
{{/if}}
55+
56+
<!-- Provide site root to javascript -->
57+
<script>
58+
var path_to_root = "{{ path_to_root }}";
59+
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}";
60+
</script>
61+
<!-- Start loading toc.js asap -->
62+
<script src="{{ path_to_root }}toc.js"></script>
63+
</head>
64+
<body>
65+
<div id="body-container">
66+
<!-- Work around some values being stored in localStorage wrapped in quotes -->
67+
<script>
68+
try {
69+
var theme = localStorage.getItem('mdbook-theme');
70+
var sidebar = localStorage.getItem('mdbook-sidebar');
71+
72+
if (theme.startsWith('"') && theme.endsWith('"')) {
73+
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
74+
}
75+
76+
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
77+
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
78+
}
79+
} catch (e) { }
80+
</script>
81+
82+
<!-- Set the theme before any content is loaded, prevents flash -->
83+
<script>
84+
var theme;
85+
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
86+
if (theme === null || theme === undefined) { theme = default_theme; }
87+
const html = document.documentElement;
88+
html.classList.remove('{{ default_theme }}')
89+
html.classList.add(theme);
90+
html.classList.add("js");
91+
</script>
92+
93+
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
94+
95+
<!-- Hide / unhide sidebar before it is displayed -->
96+
<script>
97+
var sidebar = null;
98+
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
99+
if (document.body.clientWidth >= 1080) {
100+
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
101+
sidebar = sidebar || 'visible';
102+
} else {
103+
sidebar = 'hidden';
104+
}
105+
sidebar_toggle.checked = sidebar === 'visible';
106+
html.classList.remove('sidebar-visible');
107+
html.classList.add("sidebar-" + sidebar);
108+
</script>
109+
110+
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
111+
<!-- populated by js -->
112+
<mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
113+
<noscript>
114+
<iframe class="sidebar-iframe-outer" src="{{ path_to_root }}toc.html"></iframe>
115+
</noscript>
116+
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
117+
<div class="sidebar-resize-indicator"></div>
118+
</div>
119+
</nav>
120+
121+
<div id="page-wrapper" class="page-wrapper">
122+
123+
<div class="page">
124+
{{> header}}
125+
<div id="menu-bar-hover-placeholder"></div>
126+
<div id="menu-bar" class="menu-bar sticky">
127+
<div class="left-buttons">
128+
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
129+
<i class="fa fa-bars"></i>
130+
</label>
131+
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
132+
<i class="fa fa-paint-brush"></i>
133+
</button>
134+
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
135+
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
136+
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
137+
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
138+
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
139+
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
140+
</ul>
141+
{{#if search_enabled}}
142+
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
143+
<i class="fa fa-search"></i>
144+
</button>
145+
{{/if}}
146+
</div>
147+
148+
<h1 class="menu-title">{{ book_title }}</h1>
149+
150+
<div class="right-buttons">
151+
{{#if print_enable}}
152+
<a href="{{ path_to_root }}print.html" title="Print this book" aria-label="Print this book">
153+
<i id="print-button" class="fa fa-print"></i>
154+
</a>
155+
{{/if}}
156+
{{#if git_repository_url}}
157+
<a href="{{git_repository_url}}" title="Git repository" aria-label="Git repository">
158+
<i id="git-repository-button" class="fa {{git_repository_icon}}"></i>
159+
</a>
160+
{{/if}}
161+
{{#if git_repository_edit_url}}
162+
<a href="{{git_repository_edit_url}}" title="Suggest an edit" aria-label="Suggest an edit">
163+
<i id="git-edit-button" class="fa fa-edit"></i>
164+
</a>
165+
{{/if}}
166+
167+
</div>
168+
</div>
169+
170+
{{#if search_enabled}}
171+
<div id="search-wrapper" class="hidden">
172+
<form id="searchbar-outer" class="searchbar-outer">
173+
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
174+
</form>
175+
<div id="searchresults-outer" class="searchresults-outer hidden">
176+
<div id="searchresults-header" class="searchresults-header"></div>
177+
<ul id="searchresults">
178+
</ul>
179+
</div>
180+
</div>
181+
{{/if}}
182+
183+
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
184+
<script>
185+
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
186+
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
187+
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
188+
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
189+
});
190+
</script>
191+
192+
<div id="version" class="version">
193+
VERSION-PLACEHOLDER
194+
</div>
195+
196+
<div id="content" class="content">
197+
<main>
198+
{{{ content }}}
199+
</main>
200+
201+
<nav class="nav-wrapper" aria-label="Page navigation">
202+
<!-- Mobile navigation buttons -->
203+
{{#previous}}
204+
<a rel="prev" href="{{ path_to_root }}{{link}}" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
205+
<i class="fa fa-angle-left"></i>
206+
</a>
207+
{{/previous}}
208+
209+
{{#next}}
210+
<a rel="next prefetch" href="{{ path_to_root }}{{link}}" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
211+
<i class="fa fa-angle-right"></i>
212+
</a>
213+
{{/next}}
214+
215+
<div style="clear: both"></div>
216+
</nav>
217+
</div>
218+
</div>
219+
220+
<nav class="nav-wide-wrapper" aria-label="Page navigation">
221+
{{#previous}}
222+
<a rel="prev" href="{{ path_to_root }}{{link}}" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
223+
<i class="fa fa-angle-left"></i>
224+
</a>
225+
{{/previous}}
226+
227+
{{#next}}
228+
<a rel="next prefetch" href="{{ path_to_root }}{{link}}" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
229+
<i class="fa fa-angle-right"></i>
230+
</a>
231+
{{/next}}
232+
</nav>
233+
234+
</div>
235+
236+
{{#if live_reload_endpoint}}
237+
<!-- Livereload script (if served using the cli tool) -->
238+
<script>
239+
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
240+
const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
241+
const socket = new WebSocket(wsAddress);
242+
socket.onmessage = function (event) {
243+
if (event.data === "reload") {
244+
socket.close();
245+
location.reload();
246+
}
247+
};
248+
249+
window.onbeforeunload = function() {
250+
socket.close();
251+
}
252+
</script>
253+
{{/if}}
254+
255+
{{#if google_analytics}}
256+
<!-- Google Analytics Tag -->
257+
<script>
258+
var localAddrs = ["localhost", "127.0.0.1", ""];
259+
260+
// make sure we don't activate google analytics if the developer is
261+
// inspecting the book locally...
262+
if (localAddrs.indexOf(document.location.hostname) === -1) {
263+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
264+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
265+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
266+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
267+
268+
ga('create', '{{google_analytics}}', 'auto');
269+
ga('send', 'pageview');
270+
}
271+
</script>
272+
{{/if}}
273+
274+
{{#if playground_line_numbers}}
275+
<script>
276+
window.playground_line_numbers = true;
277+
</script>
278+
{{/if}}
279+
280+
{{#if playground_copyable}}
281+
<script>
282+
window.playground_copyable = true;
283+
</script>
284+
{{/if}}
285+
286+
{{#if playground_js}}
287+
<script src="{{ path_to_root }}ace.js"></script>
288+
<script src="{{ path_to_root }}editor.js"></script>
289+
<script src="{{ path_to_root }}mode-rust.js"></script>
290+
<script src="{{ path_to_root }}theme-dawn.js"></script>
291+
<script src="{{ path_to_root }}theme-tomorrow_night.js"></script>
292+
{{/if}}
293+
294+
{{#if search_js}}
295+
<script src="{{ path_to_root }}elasticlunr.min.js"></script>
296+
<script src="{{ path_to_root }}mark.min.js"></script>
297+
<script src="{{ path_to_root }}searcher.js"></script>
298+
{{/if}}
299+
300+
<script src="{{ path_to_root }}clipboard.min.js"></script>
301+
<script src="{{ path_to_root }}highlight.js"></script>
302+
<script src="{{ path_to_root }}book.js"></script>
303+
304+
<!-- Custom JS scripts -->
305+
{{#each additional_js}}
306+
<script src="{{ ../path_to_root }}{{this}}"></script>
307+
{{/each}}
308+
309+
{{#if is_print}}
310+
{{#if mathjax_support}}
311+
<script>
312+
window.addEventListener('load', function() {
313+
MathJax.Hub.Register.StartupHook('End', function() {
314+
window.setTimeout(window.print, 100);
315+
});
316+
});
317+
</script>
318+
{{else}}
319+
<script>
320+
window.addEventListener('load', function() {
321+
window.setTimeout(window.print, 100);
322+
});
323+
</script>
324+
{{/if}}
325+
{{/if}}
326+
</div>
327+
</body>
328+
</html>

0 commit comments

Comments
 (0)