Skip to content

Commit fe3ea7a

Browse files
authored
Merge pull request #37 from pyscript/ntoll-coi
Add COI to head.
2 parents c4a592d + 07732a2 commit fe3ea7a

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

docs/developers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ compassion wins every time.
3434
* If you need help with anything, get involved - _we welcome questions asked
3535
in good faith, and will move mountains to help_.
3636
* If you're unsure where to start, get involved - _we have [many ways to
37-
contribute](/contributing)_.
37+
contribute](contributing.md)_.
3838

39-
All contributors are expected to follow our [code of conduct](/conduct/).
39+
All contributors are expected to follow our [code of conduct](conduct.md).
4040

4141
## Setup
4242

@@ -242,7 +242,7 @@ is through this environment that you contribute to PyScript.
242242
243243
## Contributing
244244
245-
* We have [suggestions for how to contribute to PyScript](/contributing). Take
245+
* We have [suggestions for how to contribute to PyScript](contributing.md). Take
246246
a read and dive in.
247247
248248
* Please make sure you discuss potential contributions *before* you put in

docs/javascripts/mini-coi.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*! coi-serviceworker v0.1.7 - Guido Zuidhof and contributors, licensed under MIT */
2+
/*! mini-coi - Andrea Giammarchi and contributors, licensed under MIT */
3+
(({ document: d, navigator: { serviceWorker: s } }) => {
4+
if (d) {
5+
const { currentScript: c } = d;
6+
s.register(c.src, { scope: c.getAttribute('scope') || '.' }).then(r => {
7+
r.addEventListener('updatefound', () => location.reload());
8+
if (r.active && !s.controller) location.reload();
9+
});
10+
}
11+
else {
12+
addEventListener('install', () => skipWaiting());
13+
addEventListener('activate', e => e.waitUntil(clients.claim()));
14+
addEventListener('fetch', e => {
15+
const { request: r } = e;
16+
if (r.cache === 'only-if-cached' && r.mode !== 'same-origin') return;
17+
e.respondWith(fetch(r).then(r => {
18+
const { body, status, statusText } = r;
19+
if (!status || status > 399) return r;
20+
const h = new Headers(r.headers);
21+
h.set('Cross-Origin-Opener-Policy', 'same-origin');
22+
h.set('Cross-Origin-Embedder-Policy', 'require-corp');
23+
h.set('Cross-Origin-Resource-Policy', 'cross-origin');
24+
return new Response(body, { status, statusText, headers: h });
25+
}));
26+
});
27+
}
28+
})(self);

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ theme:
55

66
logo: assets/images/pyscript-black.svg
77

8+
custom_dir: overrides
9+
810
palette:
911
# Palette toggle for automatic mode
1012
- media: "(prefers-color-scheme)"

overrides/main.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% extends "base.html" %}
2+
3+
{% block libs %}
4+
<script src="./javascripts/mini-coi.js"></script>
5+
{{ super() }}
6+
{% endblock %}

0 commit comments

Comments
 (0)