Skip to content

Commit ff6a041

Browse files
committed
Remove RSS feed, add stable builds to the downloads section andadd platforms icon
1 parent d882dc2 commit ff6a041

File tree

8 files changed

+228
-88
lines changed

8 files changed

+228
-88
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Credits
2+
* Brand Icons from the [CoreUI Free Icons](https://github.com/coreui/coreui-icons/) set, licensed under [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/).

assets/sass/drs.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,12 @@ code {
213213
background: darken($grey-darker, 4);
214214
}
215215
}
216+
217+
.card-header-title {
218+
.icon {
219+
font-size: xx-large;
220+
margin: 0.25em;
221+
height: 1em;
222+
width: 1em;
223+
}
224+
}

config.toml

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,57 @@ disableKinds = ["taxonomy", "RSS"]
88
ignoreErrors = ["error-disable-taxonomy"]
99

1010
[params]
11-
[params.metadata.nightly]
12-
link = "https://raw.githubusercontent.com/doukutsu-rs/metadata/master/metadata/nightly.json"
11+
[params.downloads.nightly]
12+
metadata = "https://raw.githubusercontent.com/doukutsu-rs/metadata/master/metadata/nightly.json"
1313

14-
[[params.downloads_nightly]]
15-
platform = "Windows x64"
14+
[params.downloads.stable]
15+
id = "stable"
16+
description = "Released rarely and really have no much diffs from a nightly builds."
17+
metadata = "https://raw.githubusercontent.com/doukutsu-rs/metadata/master/metadata/stable.json"
18+
fail_page = "https://github.com/doukutsu-rs/doukutsu-rs/releases/"
19+
20+
[[params.downloads.platforms]]
21+
platform_name = "Windows x64"
1622
job_name = "windows-x86_64"
17-
link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_windows-x64.zip"
23+
icon = "windows"
24+
nightly_link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_windows-x64.zip"
1825

19-
[[params.downloads_nightly]]
20-
platform = "Windows x32"
26+
[[params.downloads.platforms]]
27+
platform_name = "Windows x32"
2128
job_name = "windows-i686"
22-
link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_windows-x32.zip"
29+
icon = "windows"
30+
nightly_link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_windows-x32.zip"
2331

24-
[[params.downloads_nightly]]
25-
platform = "Linux x64"
32+
[[params.downloads.platforms]]
33+
platform_name = "Linux x64"
2634
job_name = "linux-x86_64"
27-
link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_linux-x64.zip"
35+
icon = "linux"
36+
nightly_link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_linux-x64.zip"
2837

29-
[[params.downloads_nightly]]
30-
platform = "Android ARM64"
38+
[[params.downloads.platforms]]
39+
platform_name = "Android"
3140
job_name = "android"
32-
link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_android.zip"
41+
icon = "android-alt"
42+
nightly_link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_android.zip"
3343

34-
[[params.downloads_nightly]]
35-
platform = "macOS x64 (Intel Macs)"
44+
[[params.downloads.platforms]]
45+
platform_name = "macOS x64 (Intel Macs)"
3646
job_name = "macos-x64"
37-
link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_mac-x64.zip"
47+
icon = "apple"
48+
nightly_link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_mac-x64.zip"
3849

39-
[[params.downloads_nightly]]
40-
platform = "macOS ARM64 (M1 Macs)"
50+
[[params.downloads.platforms]]
51+
platform_name = "macOS ARM64 (M1 Macs)"
4152
job_name = "macos-arm64"
42-
link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_mac-arm64.zip"
53+
icon = "apple"
54+
nightly_link = "https://nightly.link/doukutsu-rs/doukutsu-rs/workflows/ci/master/doukutsu-rs_mac-arm64.zip"
55+
56+
[[params.downloads.platforms]]
57+
# platform_id is set for platforms for which there are no nightly builds, but stable builds are available.
58+
platform_id = "horizon"
59+
no_prebuilts = true
60+
platform_name = "Nintendo Switch"
61+
icon = "nintendo-switch"
4362

4463

4564
[privacy]

layouts/index.html

Lines changed: 110 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -59,92 +59,136 @@
5959
</div>
6060
</section>
6161

62-
<section class="section" id="downloads">
62+
63+
<section class="section" id="downloads">
6364
<div class="container">
6465
<h2 class="mb-5">Downloads</h2>
6566

66-
<h3>Nightly</h3>
67-
<p class="mt-2 mb-5">Fresh doukutsu-rs builds with freeware game data, compiled on each commit of <code>master</code> branch.</p>
68-
69-
<div class="columns is-multiline">
70-
{{ range .Site.Params.downloads_nightly }}
71-
<div class="column is-one-third">
72-
<div class="card">
73-
<header class="card-header">
74-
<p class="card-header-title">{{ .platform }}</p>
75-
</header>
76-
77-
<div class="card-content">
78-
<div class="content">
79-
{{ if .job_name }}
80-
<div id="info-{{ .job_name }}" class="mb-5">
81-
<strong>Version: </strong>
82-
<span class="version">...</span><br/>
83-
84-
<strong>Git commit ID: </strong>
85-
<span class="commit">...</span><br/>
86-
</div>
87-
{{ end }}
88-
89-
<div class="buttons">
90-
{{ if .link }}
91-
<a class="button is-primary link" href="{{ .link }}">Download</a>
92-
{{ else }}
93-
<p>No prebuilts for this platform yet.</p>
94-
{{ end }}
95-
</div>
96-
</div>
97-
</div>
98-
</div>
99-
</div>
100-
{{ end }}
67+
<div id="downloads-nightly">
68+
<h3>Nightly</h3>
69+
<p class="mt-2 mb-5">Fresh doukutsu-rs builds, compiled on each commit of <code>master</code> and features branch.</p>
70+
71+
<div class="columns is-multiline">
72+
{{ range .Site.Params.downloads.platforms }}
73+
{{ partial "downloads-section.html" (dict "platform" . "channel" "nightly" "fallback" true) }}
74+
{{ end }}
75+
</div>
76+
</div>
77+
<div class="mt-6" id="downloads-stable">
78+
<h3>Stable</h3>
79+
<p class="mt-2 mb-5">The latest changes and fixes are missing, but in general all features are tested and works fine.</p>
80+
81+
<div class="columns is-multiline">
82+
{{ range .Site.Params.downloads.platforms }}
83+
{{ partial "downloads-section.html" (dict "platform" . "channel" "stable" "fallback" false) }}
84+
{{ end }}
85+
</div>
10186
</div>
10287
</div>
10388
</section>
10489

10590
<script>
106-
async function setInfo(el, info) {
107-
if (el) {
108-
const verEl = el.querySelector('.version');
109-
if (verEl) {
110-
verEl.innerText = info.version
111-
}
91+
async function setInfo(container, info) {
92+
if (!container) {
93+
return;
94+
}
11295

113-
const commEl = el.querySelector('.commit');
114-
if (commEl) {
115-
commEl.innerHTML = "<code>" + info.commit.slice(0, 7) + "</code>";
116-
}
96+
const versionEl = container.querySelector('.info .version');
97+
if (versionEl) {
98+
versionEl.innerText = info.version
99+
}
117100

118-
const linkEl = el.parentNode.querySelector('.link');
119-
if (linkEl) {
120-
linkEl.href = info.link;
121-
}
101+
const commitEl = container.querySelector('.info .commit');
102+
if (commitEl && info.commit) {
103+
commitEl.innerHTML = '<code>' + info.commit.slice(0, 7) + '</code>';
104+
} else if (commitEl) {
105+
commitEl.parentNode.remove();
106+
}
107+
108+
const dateEl = container.querySelector('.info .date');
109+
if (dateEl && info.date) {
110+
dateEl.innerHTML = (new Date(info.date * 1000)).toLocaleDateString('{{ .Site.LanguageCode }}', {
111+
year: "numeric",
112+
month: "long",
113+
day: "2-digit",
114+
hour: "numeric",
115+
minute: "numeric",
116+
second: "numeric",
117+
//timeZoneName: "short"
118+
});
119+
}
120+
121+
const linkEl = container.querySelector('.link');
122+
if (linkEl) {
123+
linkEl.classList.remove("is-loading");
124+
125+
linkEl.href = info.link;
126+
linkEl.textContent = "Download";
122127
}
123128
}
124-
125-
(async() => {
126-
const req = await fetch('{{ .Site.Params.metadata.nightly.link }}', {
127-
headers: {
128-
'Accept': 'application/json'
129-
}
130-
});
131-
const data = await req.json();
132129

133-
for (const platform in data) {
134-
const info = data[platform];
135-
if (info.version !== undefined) {
136-
const el = document.getElementById(`info-${platform}`);
130+
async function setFail(channel, msg) {
131+
const channelContainer = document.getElementById(`downloads-${channel}`);
132+
const blocks = channelContainer.querySelectorAll('.content');
133+
134+
if (!msg) {
135+
msg = "Failed to fetch direct download link."
136+
}
137+
138+
for (const block of blocks) {
139+
block.innerHTML = String.raw`<p>${msg}</p>`;
140+
}
141+
}
142+
143+
async function fetchBuilds(channel, link, fallback = false, failMsg = null) {
144+
try {
145+
const req = await fetch(link, {
146+
headers: {
147+
'Accept': 'application/json'
148+
}
149+
});
150+
151+
const data = await req.json();
152+
console.log(data);
153+
154+
for (const platform in data) {
155+
const info = data[platform];
156+
console.log(info);
157+
if (info.version !== undefined) {
158+
const container = document.getElementById(`downloads-${channel}-${platform}`);
159+
160+
await setInfo(container, info);
161+
continue;
162+
}
137163

138-
setInfo(el, info);
139-
} else {
140164
for (const arch in info) {
141165
const archInfo = info[arch];
142-
const el = document.getElementById(`info-${platform}-${arch}`);
166+
const container = document.getElementById(`downloads-${channel}-${platform}-${arch}`);
143167

144-
setInfo(el, archInfo);
168+
await setInfo(container, archInfo);
145169
}
146170
}
171+
} catch (ex) {
172+
console.error(`Failed to fetch builds for '${channel}' channel.`);
173+
console.error(ex);
174+
175+
if (!fallback) {
176+
await setFail(channel, failMsg);
177+
}
178+
179+
return;
147180
}
181+
182+
183+
}
184+
185+
(async() => {
186+
await fetchBuilds('nightly', '{{ .Site.Params.downloads.nightly.metadata }}', true);
187+
await fetchBuilds(
188+
'stable',
189+
'{{ .Site.Params.downloads.stable.metadata }}',
190+
false,
191+
'Failed to fetch a direct download link. Check out the releases <a class="link" href="{{ .Site.Params.downloads.stable.fail_page }}">download page</a>.');
148192
})();
149193
</script>
150194

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<div class="column is-one-third" id="downloads-{{ .channel }}-{{ or .platform.job_name .platform.platform_id }}">
2+
<div class="card">
3+
<header class="card-header">
4+
<p class="card-header-title">
5+
{{ if .platform.icon }}
6+
<svg class="icon" fill="currentColor">
7+
<use xlink:href="img/icons/brand.svg#cib-{{ .platform.icon }}"></use>
8+
</svg>
9+
{{ end }}
10+
{{ .platform.platform_name }}
11+
</p>
12+
</header>
13+
14+
<div class="card-content">
15+
<div class="content">
16+
{{ if or (not .fallback) (not .platform.platform_id) }}
17+
<div class="info" class="mb-5">
18+
<strong>Version: </strong>
19+
<span class="version">...</span><br/>
20+
21+
<div>
22+
<strong>Git commit ID: </strong>
23+
<span class="commit">...</span><br/>
24+
</div>
25+
26+
<div>
27+
<strong>Date: </strong>
28+
<span class="date">...</span>
29+
</div><br/>
30+
</div>
31+
{{ end }}
32+
33+
<div class="buttons">
34+
{{ if and .platform.nightly_link .fallback }}
35+
<a class="button is-primary link" href="{{ .platform.nightly_link }}">Download</a>
36+
{{ else if not .fallback }}
37+
<a class="button is-primary link is-loading" href="#">Loading</a>
38+
{{ else }}
39+
<p>No prebuilts for this platform yet.</p>
40+
{{ end }}
41+
</div>
42+
</div>
43+
</div>
44+
</div>
45+
</div>

layouts/partials/footer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
</div>
77
</footer>
88

9-
{{ partial "scripts.html" . }}
9+
{{ partial "scripts.html" }}

layouts/partials/meta.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
<meta name="MobileOptimized" content="320" />
55
<meta name="viewport" content="width=device-width, initial-scale=1" />
66

7-
{{ with.Description }}<meta name="description" content="{{ .Description }}" />{{ end }}
7+
{{ with.Description }}
8+
<meta name="description" content="{{ .Description }}" />
9+
{{ end }}
810
<meta name="keywords" content="{{ if .Keywords }}{{ range.Keywords }}{{ . }},
911
{{ end }}{{else if isset .Params "tags" }}{{ range.Params.tags }}{{ . }},
1012
{{ end }}{{ end }}">

0 commit comments

Comments
 (0)