Skip to content

Commit

Permalink
Add fetching info about nightly builds
Browse files Browse the repository at this point in the history
Remove Google Analytics script as it no longer supported and will be removed in future version of Hugo.
  • Loading branch information
biroder committed Nov 27, 2023
1 parent 1410393 commit 85955f4
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 25 deletions.
25 changes: 13 additions & 12 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,36 @@ disableKinds = ["taxonomy", "RSS"]
ignoreErrors = ["error-disable-taxonomy"]

[params]
[params.metadata.nightly]
link = "https://raw.githubusercontent.com/doukutsu-rs/metadata/master/metadata/nightly.json"

[[params.downloads_nightly]]
platform = "Windows x64"
job_name = "windows-x64"
english_link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_windows-x64.zip"
job_name = "windows-x86_64"
link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_windows-x64.zip"

[[params.downloads_nightly]]
platform = "Windows x32"
job_name = "windows-x32"
english_link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_windows-x32.zip"
job_name = "windows-i686"
link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_windows-x32.zip"

[[params.downloads_nightly]]
platform = "Linux x64"
job_name = "linux-x64"
english_link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_linux-x64.zip"
job_name = "linux-x86_64"
link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_linux-x64.zip"

[[params.downloads_nightly]]
platform = "Android ARM64"
job_name = "android"
english_link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_android.zip"

[[params.downloads_nightly]]
platform = "macOS x64 (Intel Macs)"
job_name = "mac-x64"
english_link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_mac-x64.zip"
job_name = "macos-x64"
link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_mac-x64.zip"

[[params.downloads_nightly]]
platform = "macOS ARM64 (M1 Macs)"
job_name = "mac-arm64"
english_link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_mac-arm64.zip"
job_name = "macos-arm64"
link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_mac-arm64.zip"


[privacy]
Expand Down
60 changes: 49 additions & 11 deletions layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,19 @@ <h3>Nightly</h3>
<div class="card-content">
<div class="content">
{{ if .job_name }}
<!--
<div id="info-{{ .job_name }}" class="mb-5">
<strong>Version: </strong>
<span class="version">...</span><br/>

<strong>Git commit ID: </strong>
<span class="commit">...</span><br/>
</div>
-->
{{ end }}

<div class="buttons">
{{ if .english_link }}
<a class="button is-primary" href="{{ .english_link }}">With English game data</a>
{{ end }}

{{ if .japanese_link }}
<a class="button is-primary" href="{{ .japanese_link }}">With Japanese game data</a>
{{ end }}

{{ if (and (not .english_link) (not .japanese_link)) }}
{{ if .link }}
<a class="button is-primary link" href="{{ .link }}">Download</a>
{{ else }}
<p>No prebuilts for this platform yet.</p>
{{ end }}
</div>
Expand All @@ -110,6 +102,52 @@ <h3>Nightly</h3>
</div>
</section>

<script>
async function setInfo(el, info) {
if (el) {
const verEl = el.querySelector('.version');
if (verEl) {
verEl.innerText = info.version
}

const commEl = el.querySelector('.commit');
if (commEl) {
commEl.innerText = info.commit;
}

const linkEl = el.parentNode.querySelector('.link');
if (linkEl) {
linkEl.href = info.link;
}
}
}

(async() => {
const req = await fetch('{{ .Site.Params.metadata.nightly.link }}', {
headers: {
'content-type': 'application/json'
}
});
const data = await req.json();

for (const platform in data) {
const info = data[platform];
if (info.version !== undefined) {
const el = document.getElementById(`info-${platform}`);

setInfo(el, info);
} else {
for (const arch in info) {
const archInfo = info[arch];
const el = document.getElementById(`info-${platform}-${arch}`);

setInfo(el, archInfo);
}
}
}
})();
</script>

{{ partial "footer.html" . }}
</body>
</html>
2 changes: 0 additions & 2 deletions layouts/partials/head_includes.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@
<link rel="apple-touch-icon" sizes="180x180" href="/img/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/img/favicon/android-chrome-192x192.png">
<link rel="manifest" href="/site.webmanifest">

{{ template "_internal/google_analytics_async.html" . }}

0 comments on commit 85955f4

Please sign in to comment.