Skip to content

Commit 993c1cd

Browse files
committed
Convert the Windows downloads page to Hugo
This migrates the page from the Rails app to the static site generated via Hugo. We also need to move the server-side logic that is responsible for adjusting the download link on 32-bit Windows to the client side, as Javascript. Note that we need to access the site parameters from that Javascript code, therefore we need to move the `application.js` file from `static/` to `assets/`. While at it, also minify it. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent f3accf4 commit 993c1cd

File tree

3 files changed

+39
-15
lines changed

3 files changed

+39
-15
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,26 @@ var Downloads = {
341341
return `<strong>${ago}</strong>, `;
342342
},
343343

344+
adjustFor32BitWindows: function() {
345+
// adjust the auto-link for Windows 32-bit setups
346+
const is32BitWindows = window.session.browser.os === 'Windows'
347+
&& !navigator.userAgent.match(/WOW64|Win64|x64|x86_64/)
348+
if (!is32BitWindows) return;
349+
350+
const link = $('#auto-download-link');
351+
const version = $('#auto-download-version');
352+
const bitness = $('#auto-download-bitness');
353+
const date = $('#auto-download-date');
354+
if (link.length && version.length && bitness.length && date.length) {
355+
bitness.html('32-bit');
356+
link.attr('href', '{{ .Site.Params.windows_installer.installer32.url }}');
357+
version.html('{{ .Site.Params.windows_installer.installer32.version }}');
358+
date.html('{{ .Site.Params.windows_installer.installer32.release_date }}');
359+
}
360+
},
361+
344362
postProcessDownloadPage: function() {
363+
Downloads.adjustFor32BitWindows();
345364
$('#relative-release-date').html(Downloads.postProcessReleaseDate);
346365
},
347366
}

content/downloads/win.html

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
1-
<%- @section = "downloads" %>
2-
<%- @subsection = "" %>
3-
<%- @page_title = "Git - Downloading Package" %>
4-
5-
<% content_for :sidebar do %>
6-
<%= render 'shared/book' %>
7-
<% end %>
1+
---
2+
section: "downloads"
3+
title: "Git - Downloading Package"
4+
aliases:
5+
- /download/win
6+
---
87

98
<div id="main">
109
<h1>Download for Windows</h1>
1110
<p>
12-
<%= raw "<strong><a id=\"auto-download-link\" href=\"#{@download.url}\">Click here to download </a></strong>" %><%= raw " the latest (<strong>#{@download.version.name}</strong>) <strong>#{@bitness}</strong> version of <strong>Git for Windows</strong>. This is the most recent <a href='#{@project_url}'>maintained build</a>. It was released <strong>#{time_ago_in_words @download.release_date} ago</strong>, on #{@download.release_date.strftime("%Y-%m-%d")}." %>
11+
<strong><a id="auto-download-link" href="{{< site-param windows_installer.installer64.url >}}">Click here to download </a></strong>
12+
the latest (<strong id="auto-download-version">{{< site-param windows_installer.installer64.version >}}</strong>)
13+
<strong id="auto-download-bitness">64-bit</strong> version of <strong>Git for Windows</strong>.
14+
This is the most recent <a href="https://git-for-windows.github.io/">maintained build</a>.
15+
It was released <span id="relative-release-date"></span>on <span id="auto-download-date">{{< site-param windows_installer.installer64.release_date >}}</span>.
1316
</p>
1417
<h3>Other Git for Windows downloads</h3>
1518
<h4>Standalone Installer</h4>
1619
<p>
17-
<%= raw "<strong><a href=\"#{@download32.url}\">32-bit Git for Windows Setup</a>.</strong>" %>
20+
<strong><a href="{{< site-param windows_installer.installer32.url >}}">32-bit Git for Windows Setup</a>.</strong>
1821
</p>
1922
<p>
20-
<%= raw "<strong><a href=\"#{@download64.url}\">64-bit Git for Windows Setup</a>.</strong>" %>
23+
<strong><a href="{{< site-param windows_installer.installer64.url >}}">64-bit Git for Windows Setup</a>.</strong>
2124
</p>
2225
<h4>Portable ("thumbdrive edition")</h4>
2326
<p>
24-
<%= raw "<strong><a href=\"#{@download32portable.url}\">32-bit Git for Windows Portable</a>.</strong>" %>
27+
<strong><a href="{{< site-param windows_installer.portable32.url >}}">32-bit Git for Windows Portable</a>.</strong>
2528
</p>
2629
<p>
27-
<%= raw "<strong><a href=\"#{@download64portable.url}\">64-bit Git for Windows Portable</a>.</strong>" %>
30+
<strong><a href="{{< site-param windows_installer.portable64.url >}}">64-bit Git for Windows Portable</a>.</strong>
2831
</p>
2932
<h4>Using winget tool</h4>
3033
<p>
3134
Install <a href="https://docs.microsoft.com/en-us/windows/package-manager/winget">winget tool</a> if you don't already have it, then type this command in command prompt or Powershell.<br>
3235
<code>winget install --id Git.Git -e --source winget</code>
3336
</p>
3437
<p class="small">
35-
<%= raw "The current source code release is version <strong>#{@latest.name}</strong>. If you want the newer version, you can build it from <a href=\"#{@source_url}\">the source code</a>." %>
38+
The current source code release is version <strong>{{< site-param latest_version >}}</strong>.
39+
If you want the newer version, you can build it from <a href="https://github.com/git-for-windows/git">the source code</a>.
3640
</p>
3741

3842
<h2>Now What?</h2>
@@ -51,7 +55,7 @@ <h3>Read the Book</h3>
5155
<a href="/downloads/guis">
5256
<img src="/images/icons/nav-download-gui.png" />
5357
<h3>Download a GUI</h3>
54-
<p><%= raw "Several free and commercial GUI tools are available for the #{@platform.capitalize} platform." %></p>
58+
<p>Several free and commercial GUI tools are available for the Windows platform.</p>
5559
</a>
5660
</li>
5761
<li>

layouts/partials/footer.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
<script src="/js/jquery-ui-1.8.18.custom.min.js"></script>
1616
<script src="/js/jquery.defaultvalue.js"></script>
1717
<script src="/js/session.min.js"></script>
18-
<script src="/js/application.js"></script>
18+
{{ $js := resources.Get "js/application.js" | resources.ExecuteAsTemplate "js/application.js" . | resources.Minify }}
19+
<script src="{{ $js.RelPermalink }}"></script>

0 commit comments

Comments
 (0)