Skip to content

Commit fc1c514

Browse files
authored
Merge pull request #1240 from AkihiroSuda/dev
website: set up https://lima-vm.io/
2 parents 9c2322d + 99e8250 commit fc1c514

File tree

2 files changed

+287
-0
lines changed

2 files changed

+287
-0
lines changed

website/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# The source of the Lima website (https://lima-vm.io)
2+
3+
This directory is the [Netlify base directory](https://docs.netlify.com/configure-builds/overview/) of [https://lima-vm.io](https://lima-vm.io/) .
4+
5+
The actual contents are generated from the markdown files on the browser side:
6+
- [`../README.md`](../README.md)
7+
- [`../docs/*.md`](../docs/)
8+
- [`../examples/README.md`](../examples/README.md)
9+
10+
The site is previewable and deployable with just the single [`index.html`](./index.html).
11+
12+
No dependency on any templating engine currently, but eventually we may adopt docsy or something else similar.

website/index.html

Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
<!DOCTYPE html>
2+
<!--
3+
Copyright The Lima Authors
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<html>
18+
<script>
19+
const ghRepo = "lima-vm/lima"
20+
const ghRef = "master"
21+
const ghRepoUrl = `https://github.com/${ghRepo}`
22+
const baseUrl = `${ghRepoUrl}/blob/${ghRef}/`;
23+
const contentBaseUrl = `https://raw.githubusercontent.com/${ghRepo}/${ghRef}/`;
24+
const files = [
25+
"README.md",
26+
// Advanced topic: "docs/deprecated.md",
27+
// Advanced topic: "docs/experimental.md",
28+
// Advanced topic: "docs/internal.md",
29+
"docs/mount.md",
30+
"docs/multi-arch.md",
31+
"docs/network.md",
32+
"docs/talks.md",
33+
"docs/vmtype.md",
34+
"examples/README.md",
35+
];
36+
</script>
37+
38+
<head>
39+
<title>Lima: Linux virtual machines</title>
40+
<meta charset="utf-8" />
41+
<style>
42+
code,
43+
pre {
44+
background-color: #eee;
45+
font: monospace;
46+
}
47+
48+
pre {
49+
border: solid;
50+
padding: 10px;
51+
}
52+
53+
table,
54+
th,
55+
td {
56+
border: solid;
57+
border-collapse: collapse;
58+
padding: 5px;
59+
}
60+
61+
blockquote {
62+
border: dashed;
63+
padding: 5px;
64+
}
65+
66+
header {
67+
display: flex;
68+
}
69+
70+
header h1 {
71+
display: none;
72+
}
73+
74+
#md-main-left {
75+
width: 20vw;
76+
}
77+
78+
#md-header-right {
79+
width: 80vw;
80+
text-align: right;
81+
}
82+
83+
body>hr {
84+
border-top: solid green 5px;
85+
}
86+
87+
.md-2col {
88+
display: flex;
89+
}
90+
91+
#md-main-left {
92+
width: 15vw;
93+
overflow-x: scroll;
94+
margin-right: 20px;
95+
}
96+
97+
#md-main-left hr {
98+
border-top: dotted green 3px;
99+
}
100+
101+
#md-main-right {
102+
width: 85vw;
103+
}
104+
105+
#md-filename {
106+
font-size: 150%;
107+
margin-bottom: 20px;
108+
}
109+
110+
#md-content {
111+
border: solid green;
112+
padding: 30px;
113+
overflow-y: scroll;
114+
height: 100vh;
115+
}
116+
117+
.md-error {
118+
color: red;
119+
}
120+
</style>
121+
</head>
122+
123+
<body>
124+
<header>
125+
<h1>Lima: Linux virtual machines</a></h1>
126+
<div id="md-header-left">
127+
<a href="?">
128+
<img src="https://raw.githubusercontent.com/lima-vm/lima/master/docs/images/lima-logo-01.svg" />
129+
</a>
130+
</div> <!-- /md-header-left -->
131+
<div id="md-header-right">
132+
<p>
133+
[<a href="https://github.com/lima-vm/lima">GitHub]
134+
[<a href="https://slack.cncf.io/">Slack</a>
135+
(<code>#lima</code>)]
136+
</p>
137+
<iframe src="https://ghbtns.com/github-btn.html?user=lima-vm&repo=lima&type=star&count=true&size=large"
138+
frameborder="0" scrolling="0" width="170" height="30" title="GitHub stars of lima-vm/lima"></iframe>
139+
140+
</div> <!-- /md-header-right -->
141+
</header>
142+
<hr />
143+
<div class="md-2col">
144+
<nav id="md-main-left">
145+
<h4>Documents</h4>
146+
<div id="md-files">Loading...<noscript class="md-error">ERROR: JavaScript is disabled</noscript></div>
147+
<hr />
148+
<h4>Contents</h4>
149+
<div id="md-toc"><noscript class="md-error">ERROR: JavaScript is disabled</noscript></div>
150+
</nav> <!-- /md-main-left -->
151+
<article id="md-main-right">
152+
<div id="md-filename"></div>
153+
<div id="md-content">
154+
<h1>Lima: Linux virtual machines, made for running containerd on Mac</h1>
155+
<p>Lima launches Linux virtual machines with automatic file sharing and port forwarding (similar to
156+
WSL2), and containerd.</p>
157+
<p>Lima can be considered as a some sort of unofficial "containerd for Mac".</p>
158+
<p>Lima is expected to be used on macOS hosts, but can be used on Linux hosts as well.</p>
159+
<p><noscript class="md-error">ERROR: JavaScript is disabled</noscript></p>
160+
</div> <!-- /md-content -->
161+
<p>
162+
If the content is not shown, visit: <a
163+
href="https://github.com/lima-vm/lima">https://github.com/lima-vm/lima</a>
164+
</p>
165+
</article> <!-- /md-main-right -->
166+
</div> <!-- /md-main-2col-->
167+
<hr />
168+
<footer>
169+
<p><strong>We are a <a href="https://cncf.io/">Cloud Native Computing Foundation</a> sandbox project.</strong>
170+
</p>
171+
<img src="https://www.cncf.io/wp-content/uploads/2022/07/cncf-color-bg.svg" width=300 />
172+
<p>The Linux Foundation® (TLF) has registered trademarks and uses trademarks.For a list of TLF trademarks,
173+
see <a href="https://www.linuxfoundation.org/trademark-usage/">Trademark Usage</a>.</p>
174+
<hr />
175+
<p>Help wanted to improve this website.
176+
Please send pull requests to <a
177+
href="https://github.com/lima-vm/lima/tree/master/website">https://github.com/lima-vm/lima/tree/master/website</a>
178+
🙏.
179+
</p>
180+
</footer>
181+
</body>
182+
183+
<!-- marked: MIT License: https://github.com/markedjs/marked/blob/v4.2.3/LICENSE.md -->
184+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/marked.min.js"
185+
integrity="sha384-IMygIQafcYXMtRhq7WReNw5YkMe3eTKl420LY/Xz4yi6nfihtVdatoddRcEsO4KQ"
186+
crossorigin="anonymous"></script>
187+
<!-- DOMPurify: Apache License 2.0: https://github.com/cure53/DOMPurify/blob/2.4.1/LICENSE -->
188+
<script src="https://cdn.jsdelivr.net/gh/cure53/[email protected]/dist/purify.min.js"
189+
integrity="sha384-arqXKBMaxueqlbHTzDnjId9y+DYmnmjBWr2t2wXFAUwg00iJKZe5ItR/bQQAaaHp"
190+
crossorigin="anonymous"></script>
191+
<script>
192+
const walkTokens = async (token) => {
193+
if (token.type === "image" && !token.href.includes("://")) {
194+
token.href = new URL(token.href, contentBaseUrl).href;
195+
}
196+
};
197+
const dirname = function (file) {
198+
const arr = file.split("/");
199+
arr.pop();
200+
return arr.join("/");
201+
};
202+
const render = function (file) {
203+
let fileInAllowList = false;
204+
// Render the side bar
205+
let ul = "<ul>";
206+
for (let i = 0; i < files.length; i++) {
207+
const f = files[i];
208+
let li = "<li>";
209+
if (file && file == f) {
210+
fileInAllowList = true;
211+
li += `<strong><code>${f}</code></strong>`;
212+
} else {
213+
li += `<code><a href="?file=${f}">${f}</a></code>`;
214+
}
215+
li += "</li>";
216+
ul += li;
217+
}
218+
ul += "</ul>";
219+
const filesE = document.getElementById("md-files");
220+
filesE.innerHTML = ul;
221+
if (!file) return;
222+
// Render the markdown content
223+
if (!fileInAllowList) throw new Error(`invalid file "${file}"`);
224+
const fileAbs = new URL(file, baseUrl).href;
225+
const contentAbs = new URL(file, contentBaseUrl).href;
226+
const filenameE = document.getElementById("md-filename");
227+
filenameE.innerHTML = `<code>${file}</code> (<a href="${fileAbs}"><code>${fileAbs}</code></a>)`;
228+
const contentE = document.getElementById("md-content");
229+
contentE.innerHTML = `Loading <code><a href="${fileAbs}">${fileAbs}</a></code> ...`
230+
+ ` (from <code><a href="${contentAbs}">${contentAbs}</a></code>)`;
231+
const req = new Request(contentAbs);
232+
fetch(req)
233+
.then((resp) => {
234+
if (!resp.ok) {
235+
console.log(resp);
236+
const error = `${resp.status} (${resp.type}) for ${resp.url}`;
237+
throw new Error(error);
238+
}
239+
return resp.blob()
240+
})
241+
.then(async (blob) => {
242+
const text = await blob.text();
243+
const baseUrlFull = baseUrl + dirname(file) + "/";
244+
let mdHTMLStr = DOMPurify.sanitize(marked.parse(text, { baseUrl: baseUrlFull, walkTokens: walkTokens }));
245+
contentE.innerHTML = mdHTMLStr;
246+
const mdHTML = (new DOMParser).parseFromString(mdHTMLStr, "text/html");
247+
const selected = mdHTML.querySelectorAll("h2");
248+
const tocE = document.getElementById("md-toc");
249+
let ul = "<ul>";
250+
for (let i = 0; i < selected.length; i++) {
251+
const f = selected[i];
252+
let li = `<li><a href="#${f.id}">${f.innerText}</a></li>`;
253+
ul += li;
254+
}
255+
ul += "</ul>";
256+
tocE.innerHTML = ul;
257+
return blob;
258+
})
259+
.catch((error) => {
260+
contentE.innerHTML += `<div class="md-error">${error}</div>` +
261+
`<p>Please visit <code><a href="${fileAbs}">${fileAbs}</a></code> directly.</p>`;
262+
});
263+
};
264+
window.onload = function () {
265+
let file = (new URL(document.location)).searchParams.get("file");
266+
if (!file) file = files[0];
267+
try {
268+
render(file);
269+
} catch (error) {
270+
document.getElementById("md-content").innerHTML += `<div class="md-error">${error}</div>`;
271+
}
272+
}
273+
</script>
274+
275+
</html>

0 commit comments

Comments
 (0)