Skip to content

Commit

Permalink
Bring rustup.js and installation markup into alignment with rustup.rs
Browse files Browse the repository at this point in the history
This primarily makes the install page offer the 64-bit version
of rustup-init when appropriate, per rustup.rs.

Also

- Adjust the "unknown" and "default" cases to offer both
  64-bit and 32-bit windows installers
- rustup.rs and rust-www use the exact same rustup.js
- add the "If you are a WSL user..." language to all
  non-English pages
- fix style on vi-VN

Fixes rust-lang#1049
  • Loading branch information
brson committed Jun 17, 2018
1 parent af3b81c commit b168549
Show file tree
Hide file tree
Showing 17 changed files with 598 additions and 140 deletions.
78 changes: 43 additions & 35 deletions _includes/rustup.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// IF YOU CHANGE THIS FILE IT MUST BE CHANGED ON BOTH rust-www and rustup.rs

var platforms = ["default", "unknown", "win32", "win64", "unix"];
var platform_override = null;

function detect_platform() {
"use strict";

if (platform_override) {
return platform_override;
if (platform_override !== null) {
return platforms[platform_override];
}

var os = "unknown";
Expand All @@ -20,23 +23,27 @@ function detect_platform() {
if (navigator.platform == "Linux mips") {os = "unix";}
if (navigator.platform == "Linux mips64") {os = "unix";}
if (navigator.platform == "Mac") {os = "unix";}
if (navigator.platform == "Win32") {os = "win";}
if (navigator.platform == "Win32") {os = "win32";}
if (navigator.platform == "Win64" ||
navigator.userAgent.indexOf("WOW64") != -1 ||
navigator.userAgent.indexOf("Win64") != -1) { os = "win64"; }
if (navigator.platform == "FreeBSD x86_64") {os = "unix";}
if (navigator.platform == "FreeBSD amd64") {os = "unix";}
if (navigator.platform == "NetBSD x86_64") {os = "unix";}
if (navigator.platform == "NetBSD amd64") {os = "unix";}

// I wish I knew by now, but I don't. Try harder.
if (os == "unknown") {
if (navigator.appVersion.indexOf("Win")!=-1) {os = "win";}
if (navigator.appVersion.indexOf("Win")!=-1) {os = "win32";}
if (navigator.appVersion.indexOf("Mac")!=-1) {os = "unix";}
// rust-www/#692 - FreeBSD epiphany!
if (navigator.appVersion.indexOf("FreeBSD")!=-1) {os = "unix";}
}

// Firefox Quantum likes to hide platform and appVersion but oscpu works
if (navigator.oscpu) {
if (navigator.oscpu.indexOf("Windows")!=-1) {os = "win";}
if (navigator.oscpu.indexOf("Win32")!=-1) {os = "win32";}
if (navigator.oscpu.indexOf("Win64")!=-1) {os = "win64";}
if (navigator.oscpu.indexOf("Mac")!=-1) {os = "unix";}
if (navigator.oscpu.indexOf("Linux")!=-1) {os = "unix";}
if (navigator.oscpu.indexOf("FreeBSD")!=-1) {os = "unix";}
Expand All @@ -51,26 +58,19 @@ function adjust_for_platform() {

var platform = detect_platform();

var unix_div = document.getElementById("platform-instructions-unix");
var win_div = document.getElementById("platform-instructions-win");
var unknown_div = document.getElementById("platform-instructions-unknown");
var default_div = document.getElementById("platform-instructions-default");

unix_div.style.display = "none";
win_div.style.display = "none";
unknown_div.style.display = "none";
default_div.style.display = "none";

if (platform == "unix") {
unix_div.style.display = "block";
} else if (platform == "win") {
win_div.style.display = "block";
} else if (platform == "unknown") {
unknown_div.style.display = "block";
} else {
default_div.style.display = "block";
}
platforms.forEach(function (platform_elem) {
var platform_div = document.getElementById("platform-instructions-" + platform_elem);
platform_div.style.display = "none";
if (platform == platform_elem) {
platform_div.style.display = "block";
}
});

adjust_platform_specific_instrs(platform);
}

// NB: This has no effect on rustup.rs
function adjust_platform_specific_instrs(platform) {
var platform_specific = document.getElementsByClassName("platform-specific");
for (var el of platform_specific) {
var el_is_not_win = el.className.indexOf("not-win") !== -1;
Expand All @@ -79,7 +79,7 @@ function adjust_for_platform() {
if (el_is_inline) {
el_visible_style = "inline";
}
if (platform == "win") {
if (platform == "win64" || platform == "win32") {
if (el_is_not_win) {
el.style.display = "none";
} else {
Expand All @@ -97,15 +97,9 @@ function adjust_for_platform() {

function cycle_platform() {
if (platform_override == null) {
platform_override = "default";
} else if (platform_override == "default") {
platform_override = "unknown";
} else if (platform_override == "unknown") {
platform_override = "win";
} else if (platform_override == "win") {
platform_override = "unix";
} else if (platform_override == "unix") {
platform_override = "default";
platform_override = 0;
} else {
platform_override = (platform_override + 1) % platforms.length;
}
adjust_for_platform();
}
Expand Down Expand Up @@ -139,6 +133,19 @@ function set_up_cycle_button() {
};
}

function go_to_default_platform() {
platform_override = 0;
adjust_for_platform();
}

// NB: This has no effect on rust-lang.org/install.html
function set_up_default_platform_buttons() {
var defaults_buttons = document.getElementsByClassName('default-platform-button');
for (var i = 0; i < defaults_buttons.length; i++) {
defaults_buttons[i].onclick = go_to_default_platform;
}
}

function fill_in_bug_report_values() {
var nav_plat = document.getElementById("nav-plat");
var nav_app = document.getElementById("nav-app");
Expand All @@ -149,5 +156,6 @@ function fill_in_bug_report_values() {
(function () {
adjust_for_platform();
set_up_cycle_button();
set_up_default_platform_buttons();
fill_in_bug_report_values();
}());
12 changes: 8 additions & 4 deletions css/style-vi.css
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,10 @@ footer a {
}

#platform-instructions-unix > pre,
#platform-instructions-win > pre,
#platform-instructions-default > div > pre {
#platform-instructions-win32 > pre,
#platform-instructions-win64 > pre,
#platform-instructions-default > div > pre,
#platform-instructions-unknown > div > pre {
background-color: #515151;
color: white;
margin-left: auto;
Expand All @@ -617,8 +619,10 @@ footer a {
margin-bottom: 2rem;
}

#platform-instructions-win a,
#platform-instructions-default a {
#platform-instructions-win32 a.windows-download,
#platform-instructions-win64 a.windows-download,
#platform-instructions-default a.windows-download,
#platform-instructions-unknown a.windows-download {
display: block;
padding-top: 0.4rem;
padding-bottom: 0.6rem;
Expand Down
14 changes: 9 additions & 5 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,10 @@ footer a {
}

#platform-instructions-unix > pre,
#platform-instructions-win > pre,
#platform-instructions-default > div > pre {
#platform-instructions-win32 > pre,
#platform-instructions-win64 > pre,
#platform-instructions-default > div > pre,
#platform-instructions-unknown > div > pre {
background-color: #515151;
color: white;
margin-left: auto;
Expand All @@ -664,9 +666,11 @@ footer a {
margin-bottom: 2rem;
}

#platform-instructions-win a,
#platform-instructions-default a {
display: block;
#platform-instructions-win32 a.windows-download,
#platform-instructions-win64 a.windows-download,
#platform-instructions-default a.windows-download,
#platform-instructions-unknown a.windows-download {
display: block;
padding-top: 0.4rem;
padding-bottom: 0.6rem;
font-family: 'Fira Sans', "Helvetica Neue", Helvetica, Arial, sans-serif;
Expand Down
44 changes: 38 additions & 6 deletions de-DE/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,24 @@ <h1 class="rustup">Rust installieren</h1>
<pre>curl https://sh.rustup.rs -sSf | sh</pre>
</div>

<div id="platform-instructions-win" class="instructions" style="display: none;">
<div id="platform-instructions-win32" class="instructions" style="display: none;">
<p>
Um Rust zu installieren, lade das folgende Installationsprogram herunter und führe es aus:
<a href="https://win.rustup.rs">rustup&#x2011;init.exe</a>
<a class="windows-download" href="https://win.rustup.rs/i686">rustup&#x2011;init.exe</a>
Folge dann den Anweisungen des Installers.
</p>
<p>If you're a Windows Subsystem for Linux user run the following in your terminal, then follow the onscreen instructions to install Rust.</p>
<pre>curl https://sh.rustup.rs -sSf | sh</pre>
</div>

<div id="platform-instructions-win64" class="instructions" style="display: none;">
<p>
Um Rust zu installieren, lade das folgende Installationsprogram herunter und führe es aus:
<a class="windows-download" href="https://win.rustup.rs/x86_64">rustup&#x2011;init.exe</a>
Folge dann den Anweisungen des Installers.
</p>
<p>If you're a Windows Subsystem for Linux user run the following in your terminal, then follow the onscreen instructions to install Rust.</p>
<pre>curl https://sh.rustup.rs -sSf | sh</pre>
</div>

<div id="platform-instructions-unknown" class="instructions" style="display: none;">
Expand Down Expand Up @@ -48,9 +60,20 @@ <h1 class="rustup">Rust installieren</h1>

<div>
<p>
Um Rust unter Windows zu installieren, lade das folgende Installationsprogramm
Um Rust unter Windows 64-bit zu installieren, lade das folgende Installationsprogramm
herunter und führe es aus:
<a class="windows-download" href="https://win.rustup.rs/x86_64">rustup&#x2011;init.exe</a>
Folge dann den Anweisungen des Installers.
</p>
</div>

<hr/>

<div>
<p>
Um Rust unter Windows 64-bit zu installieren, lade das folgende Installationsprogramm
herunter und führe es aus:
<a href="https://win.rustup.rs">rustup&#x2011;init.exe</a>
<a class="windows-download" href="https://win.rustup.rs/i686">rustup&#x2011;init.exe</a>
Folge dann den Anweisungen des Installers.
</p>
</div>
Expand All @@ -67,9 +90,18 @@ <h1 class="rustup">Rust installieren</h1>

<div>
<p>
Um Rust unter Windows zu installieren, lade das folgende Installationsprogramm herunter und
Um Rust unter Windows 64-bit zu installieren, lade das folgende Installationsprogramm herunter und
führe es aus:
<a class="windows-download" href="https://win.rustup.rs/x86_64">rustup&#x2011;init.exe</a>
Folge dann den Anweisungen des Installers.
</p>
</div>

<div>
<p>
Um Rust unter Windows 32-bit zu installieren, lade das folgende Installationsprogramm herunter und
führe es aus:
<a href="https://win.rustup.rs">rustup&#x2011;init.exe</a>
<a class="windows-download" href="https://win.rustup.rs/i686">rustup&#x2011;init.exe</a>
Folge dann den Anweisungen des Installers.
</p>
</div>
Expand Down
42 changes: 36 additions & 6 deletions en-US/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@ <h1 class="rustup">Install Rust</h1>
<pre>curl https://sh.rustup.rs -sSf | sh</pre>
</div>

<div id="platform-instructions-win" class="instructions" style="display: none;">
<div id="platform-instructions-win32" class="instructions" style="display: none;">
<p>
To install Rust, download and run
<a href="https://win.rustup.rs">rustup&#x2011;init.exe</a>
<a class="windows-download" href="https://win.rustup.rs/i686">rustup&#x2011;init.exe</a>
then follow the onscreen instructions.
</p>
<p>If you're a Windows Subsystem for Linux user run the following in your terminal, then follow the onscreen instructions to install Rust.</p>
<pre>curl https://sh.rustup.rs -sSf | sh</pre>
</div>

<div id="platform-instructions-win64" class="instructions" style="display: none;">
<p>
To install Rust, download and run
<a class="windows-download" href="https://win.rustup.rs/x86_64">rustup&#x2011;init.exe</a>
then follow the onscreen instructions.
</p>
<p>If you're a Windows Subsystem for Linux user run the following in your terminal, then follow the onscreen instructions to install Rust.</p>
Expand Down Expand Up @@ -49,8 +59,18 @@ <h1 class="rustup">Install Rust</h1>

<div>
<p>
If you are running Windows,<br/>download and run
<a href="https://win.rustup.rs">rustup&#x2011;init.exe</a>
If you are running Windows 64-bit,<br/>download and run
<a class="windows-download" href="https://win.rustup.rs/x86_64">rustup&#x2011;init.exe</a>
then follow the onscreen instructions.
</p>
</div>

<hr/>

<div>
<p>
If you are running Windows 32-bit,<br/>download and run
<a class="windows-download" href="https://win.rustup.rs/i686">rustup&#x2011;init.exe</a>
then follow the onscreen instructions.
</p>
</div>
Expand All @@ -67,8 +87,18 @@ <h1 class="rustup">Install Rust</h1>

<div>
<p>
If you are running Windows,<br/>download and run
<a href="https://win.rustup.rs">rustup&#x2011;init.exe</a>
If you are running Windows 64-bit,<br/>download and run
<a class="windows-download" href="https://win.rustup.rs/x86_64">rustup&#x2011;init.exe</a>
then follow the onscreen instructions.
</p>
</div>

<hr/>

<div>
<p>
If you are running Windows 32-bit,<br/>download and run
<a class="windows-download" href="https://win.rustup.rs/i686">rustup&#x2011;init.exe</a>
then follow the onscreen instructions.
</p>
</div>
Expand Down
Loading

0 comments on commit b168549

Please sign in to comment.