Skip to content

Commit 01ee372

Browse files
committed
Added dynamic cck4 versions and urls
1 parent f4fb364 commit 01ee372

5 files changed

Lines changed: 77 additions & 18 deletions

File tree

_variables/cck.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,5 @@
99
"executable": "https://unity.com/releases/editor/whats-new/2021.3.45f2#installs"
1010
}
1111
}
12-
},
13-
"cck4": {
14-
"version": "v4.0.1",
15-
"downloadUrl": "https://files.chilloutvr.net/cck/CCK_4.0.1_Release.unitypackage",
16-
"unity": {
17-
"install": {
18-
"version": "2022.3.58f1",
19-
"hub": "unityhub://2022.3.58f1/ed7f6eacb62e",
20-
"executable": "https://unity.com/releases/editor/whats-new/2022.3.58f1#installs"
21-
}
22-
}
2312
}
2413
}

docs/assets/javascripts/cck.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// docs/assets/javascripts/cck.js
2+
// Fetches live CCK info from the API and fills in any element marked with data-cck (text) or data-cck-href (link href)
3+
// Runs on every page render, including mkdocs-material instant navigation.
4+
5+
(function () {
6+
const API_URL = "https://api.chilloutvr.net/1/public/cck/info";
7+
8+
// Cache the response across instant-nav page changes so we don't refetch on every navigation. Set to null to force a
9+
// refetch.
10+
let cckPromise = null;
11+
12+
function fetchCck() {
13+
if (!cckPromise) {
14+
cckPromise = fetch(API_URL)
15+
.then((r) => {
16+
if (!r.ok) throw new Error("HTTP " + r.status);
17+
return r.json();
18+
})
19+
.then((json) => {
20+
const i = json.data.cckInfo;
21+
return {
22+
"cck4.version": i.cckVersion,
23+
"cck4.downloadUrl": i.cckDownloadUrl,
24+
"cck4.unity.version": i.unityVersion,
25+
"cck4.unity.hub": i.unityHubInstallUrl,
26+
"cck4.unity.executable": i.unityDownloadUrl,
27+
};
28+
})
29+
.catch((e) => {
30+
// Reset so a later page view can retry, then re-throw.
31+
cckPromise = null;
32+
throw e;
33+
});
34+
}
35+
return cckPromise;
36+
}
37+
38+
function populate(map) {
39+
document.querySelectorAll("[data-cck]").forEach((el) => {
40+
const v = map[el.dataset.cck];
41+
if (v != null) el.textContent = v;
42+
});
43+
document.querySelectorAll("[data-cck-href]").forEach((el) => {
44+
const v = map[el.dataset.cckHref];
45+
if (v != null) el.setAttribute("href", v);
46+
});
47+
}
48+
49+
function run() {
50+
// Skip work if there's nothing to fill on this page
51+
if (!document.querySelector("[data-cck], [data-cck-href]")) return;
52+
fetchCck()
53+
.then(populate)
54+
.catch((e) => console.error("CCK info fetch failed:", e));
55+
}
56+
57+
// mkdocs-material exposes document$ (an RxJS observable) that emits on every page load AND every instant-navigation
58+
// render. Prefer it when present
59+
if (typeof document$ !== "undefined" && document$.subscribe) {
60+
document$.subscribe(run);
61+
} else {
62+
// Fallback for non-instant-nav setups
63+
if (document.readyState !== "loading") {
64+
run();
65+
} else {
66+
document.addEventListener("DOMContentLoaded", run);
67+
}
68+
}
69+
})();

docs/cck/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ChilloutVR is currently running on **Unity Version {{ chilloutvr.unity.nativeVer
99
The CCK can be used with the following Unity Versions:
1010

1111
+ **{{ cck.cck3.unity.install.version }}** ({{ cck.cck3.version }})
12-
+ **{{ cck.cck4.unity.install.version }}** ({{ cck.cck4.version }})
12+
+ **<span data-cck="cck4.unity.version">…</span>** (v<span data-cck="cck4.version">…</span>)
1313

1414
### Still have more Questions?
1515
Couldn't find what you were looking for?

docs/cck/setup.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ comparison below.
1414

1515
A rewrite with a modern build panel, content browser, account
1616
switcher, and reworked build pipeline. No more play mode
17-
to upload. Uses **Unity {{ cck.cck4.unity.install.version }}**.
17+
to upload. Uses **Unity <span data-cck="cck4.unity.version">…</span>**.
1818

1919
Missing some translations, but all future
2020
development is happening here.
@@ -48,17 +48,17 @@ comparison below.
4848

4949
##### Download CCK 4
5050

51-
[ :fontawesome-solid-download: Download Content Creation Kit {{ cck.cck4.version }}]({{ cck.cck4.downloadUrl }}){ .md-button .md-button--primary }
51+
[ :fontawesome-solid-download: Download Content Creation Kit v<span data-cck="cck4.version">…</span>](#){ .md-button .md-button--primary data-cck-href="cck4.downloadUrl" }
5252

5353
##### Download Unity for CCK 4
5454

55-
CCK 4 requires a newer version of Unity. We recommend **Unity {{ cck.cck4.unity.install.version }}**
55+
CCK 4 requires a newer version of Unity. We recommend **Unity <span data-cck="cck4.unity.version">…</span>**
5656

57-
[ :fontawesome-solid-download: Unity {{ cck.cck4.unity.install.version }} (Unity Hub)]({{ cck.cck4.unity.install.hub }}){ .md-button .md-button--primary }
58-
[ :fontawesome-solid-download: Unity {{ cck.cck4.unity.install.version }} (Win-Executable)]({{ cck.cck4.unity.install.executable }}){ .md-button }
57+
[ :fontawesome-solid-download: Unity <span data-cck="cck4.unity.version">…</span> (Unity Hub)](#){ .md-button .md-button--primary data-cck-href="cck4.unity.hub" }
58+
[ :fontawesome-solid-download: Unity <span data-cck="cck4.unity.version">…</span> (Win-Executable)](#){ .md-button data-cck-href="cck4.unity.executable" }
5959

6060
!!! info "Reguarding the Unity Security Update Advisory"
61-
**Unity {{ cck.cck4.unity.install.version }}** will be flagged by Unity Hub as vulnerable due to a recent Unity Security Update Advisory.
61+
**Unity <span data-cck="cck4.unity.version">…</span>** will be flagged by Unity Hub as vulnerable due to a recent Unity Security Update Advisory.
6262
This issue does not affect the Unity Editor and is specific to player builds only, so __it is safe to use this version__ for creating content in ChilloutVR.
6363

6464
=== "CCK 3 (Legacy)"

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extra_css:
3434
- assets/stylesheets/extra.css
3535
extra_javascript:
3636
- assets/javascripts/extra.js
37+
- assets/javascripts/cck.js
3738
extra:
3839
generator: false
3940
alternate:

0 commit comments

Comments
 (0)