Skip to content

Commit ce1cd81

Browse files
committed
Merge branch 'migrate-downloads-to-hugo'
This topic branch adapts the various pages in the "Downloads" section of the sidebar to render correctly using Hugo. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 1c0257c + 7a7cb6c commit ce1cd81

File tree

22 files changed

+284
-162
lines changed

22 files changed

+284
-162
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
source "https://rubygems.org"
44

55
gem "octokit"
6+
gem "rss"

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ Or you can do it from GitHub (much slower) like this:
8282

8383
## Update the `Downloads` pages
8484

85-
(TODO!)
8685
Now you need to get the latest downloads for the downloads pages:
8786

88-
$ rake downloads
87+
$ ruby ./script/update-download-data.rb
8988

9089
## Update the ProGit book
9190

app/views/downloads/download_windows.html.erb

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ var Downloads = {
248248
Downloads.observeGUIOSFilter();
249249
Downloads.observePopState();
250250
Downloads.filterGUIS();
251+
Downloads.postProcessDownloadPage();
251252
},
252253

253254
getOSFromQueryString: function() {
@@ -314,7 +315,54 @@ var Downloads = {
314315
onPopState(function() {
315316
Downloads.filterGUIS();
316317
});
317-
}
318+
},
319+
320+
// say how many days ago this version was released
321+
postProcessReleaseDate: function(index, releaseDateString) {
322+
const daysAgo = Math.floor((Date.now() - Date.parse($('#auto-download-date').html())) / 86400000);
323+
if (daysAgo < 0) return releaseDateString; // leave unparseable content alone
324+
325+
const rest = (count, unit) => `${count} ${unit}${count > 1 ? "s" : ""} ago`;
326+
let ago = rest(daysAgo, "day");
327+
328+
const handwave = (exact, unit) => {
329+
const roundedDown = Math.floor(exact);
330+
const fract = exact - roundedDown;
331+
if (fract < 0.25) return `about ${rest(roundedDown, unit)}`;
332+
if (fract < 0.75) return `over ${rest(roundedDown, unit)}`;
333+
return `almost ${rest(roundedDown + 1, unit)}`;
334+
}
335+
336+
if (daysAgo == 0) ago = "today";
337+
else if (daysAgo == 1) ago = "yesterday";
338+
// from here on out, we keep it only approximately exact
339+
else if (daysAgo > 365 * 0.75) ago = handwave(daysAgo / 365.25, "year");
340+
else if (daysAgo > 45) ago = handwave(daysAgo / 30.4, "month");
341+
return `<strong>${ago}</strong>, `;
342+
},
343+
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+
362+
postProcessDownloadPage: function() {
363+
Downloads.adjustFor32BitWindows();
364+
$('#relative-release-date').html(Downloads.postProcessReleaseDate);
365+
},
318366
}
319367

320368
// Scroll to Top

content/download/_index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
redirect_to: downloads
3+
---

content/download/gui/_index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
redirect_to: downloads/guis
3+
---
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<%- @section = "downloads" %>
2-
<%- @subsection = "" %>
3-
<%- @page_title = "Git - Downloads" %>
4-
5-
<% content_for :sidebar do %>
6-
<%= render 'shared/book' %>
7-
<% end %>
1+
---
2+
section: "downloads"
3+
title: "Git - Downloads"
4+
url: /downloads.html
5+
aliases:
6+
- /downloads/index.html
7+
---
88

99
<div id="main">
1010
<div class="two-column">
@@ -14,15 +14,15 @@ <h1>Downloads</h1>
1414
<table class="binaries">
1515
<tr>
1616
<td>
17-
<%= link_to "macOS", "/download/mac", {:class => 'icon mac'} %>
17+
<a href="/download/mac" class="icon mac">macOS</a>
1818
</td>
1919
<td>
20-
<%= link_to "Windows", "/download/win", {:class => 'icon windows'} %>
20+
<a href="/download/win" class="icon windows">Windows</a>
2121
</td>
2222
</tr>
2323
<tr>
2424
<td>
25-
<%= link_to "Linux/Unix", "/download/linux", {:class => 'icon linux'} %>
25+
<a href="/download/linux" class="icon linux">Linux/Unix</a>
2626
</td>
2727
</tr>
2828
</table>
@@ -32,7 +32,7 @@ <h1>Downloads</h1>
3232
</p>
3333
</div>
3434
<div class="column-right">
35-
<%= render partial: 'shared/monitor' %>
35+
{{< monitor >}}
3636
</div>
3737
</div>
3838
<div class="callout" id="more-downloads">
@@ -44,7 +44,7 @@ <h2>GUI Clients</h2>
4444
</p>
4545
<p>
4646
<strong>
47-
<%= link_to "View GUI Clients →", "/downloads/guis" %>
47+
<a href="/downloads/guis">View GUI Clients →</a>
4848
</strong>
4949
</p>
5050
</div>
@@ -53,7 +53,7 @@ <h2>Logos</h2>
5353
<p>Various Git logos in PNG (bitmap) and EPS (vector) formats are available for use in online and print projects.</p>
5454
<p>
5555
<strong>
56-
<%= link_to "View Logos →", "/downloads/logos" %>
56+
<a href="/downloads/logos">View Logos →</a>
5757
</strong>
5858
</p>
5959
</div>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
redirect_to: downloads/guis?os=android
3+
aliases:
4+
- /download/gui/android
5+
---

content/downloads/guis/ios.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
redirect_to: downloads/guis?os=ios
3+
aliases:
4+
- /download/gui/ios
5+
---
6+
7+

content/downloads/guis/linux.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
redirect_to: downloads/guis?os=linux
3+
aliases:
4+
- /download/gui/linux
5+
---
6+

0 commit comments

Comments
 (0)