Skip to content

Commit 2ef9b30

Browse files
authored
Merge pull request #1437 from brson/install
Bring rustup.js and markup into alingment with rust-www
2 parents bb6f65f + c7fe58c commit 2ef9b30

File tree

3 files changed

+86
-12
lines changed

3 files changed

+86
-12
lines changed

www/index.html

+34-9
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,24 @@
3131

3232
<div id="platform-instructions-win32" class="instructions" style="display: none;">
3333
<p>
34-
Download and run
34+
To install Rust, download and run
3535
<a class="windows-download" href="https://win.rustup.rs/i686">rustup&#x2011;init.exe</a>
3636
then follow the onscreen instructions.
3737
</p>
38-
<p class="other-platforms-help">You appear to be running Windows 32 bit. If not, <a class="default-platform-button" href="#">display all supported installers</a>.</p>
38+
<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>
39+
<pre>curl https://sh.rustup.rs -sSf | sh</pre>
40+
<p class="other-platforms-help">You appear to be running Windows 32-bit. If not, <a class="default-platform-button" href="#">display all supported installers</a>.</p>
3941
</div>
4042

4143
<div id="platform-instructions-win64" class="instructions" style="display: none;">
4244
<p>
43-
Download and run
45+
To install Rust, download and run
4446
<a class="windows-download" href="https://win.rustup.rs/x86_64">rustup&#x2011;init.exe</a>
4547
then follow the onscreen instructions.
4648
</p>
47-
<p class="other-platforms-help">You appear to be running Windows 64 bit. If not, <a class="default-platform-button" href="#">display all supported installers</a>.</p>
49+
<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>
50+
<pre>curl https://sh.rustup.rs -sSf | sh</pre>
51+
<p class="other-platforms-help">You appear to be running Windows 64-bit. If not, <a class="default-platform-button" href="#">display all supported installers</a>.</p>
4852
</div>
4953

5054
<div id="platform-instructions-unknown" class="instructions" style="display: none;">
@@ -74,8 +78,18 @@
7478

7579
<div>
7680
<p>
77-
If you are running Windows,<br/>download and run
78-
<a class="windows-download" href="https://win.rustup.rs">rustup&#x2011;init.exe</a>
81+
If you are running Windows 64-bit,<br/>download and run
82+
<a class="windows-download" href="https://win.rustup.rs/x86_64">rustup&#x2011;init.exe</a>
83+
then follow the onscreen instructions.
84+
</p>
85+
</div>
86+
87+
<hr/>
88+
89+
<div>
90+
<p>
91+
If you are running Windows 32-bit,<br/>download and run
92+
<a class="windows-download" href="https://win.rustup.rs/i686">rustup&#x2011;init.exe</a>
7993
then follow the onscreen instructions.
8094
</p>
8195
</div>
@@ -84,16 +98,27 @@
8498

8599
<div id="platform-instructions-default" class="instructions">
86100
<div>
87-
<p>If you are running Unix,<br/>run the following in your terminal, then follow the onscreen instructions.</p>
101+
<p>To install Rust, if you are running Unix,<br/>run the following
102+
in your terminal, then follow the onscreen instructions.</p>
88103
<pre>curl https://sh.rustup.rs -sSf | sh</pre>
89104
</div>
90105

91106
<hr/>
92107

93108
<div>
94109
<p>
95-
If you are running Windows,<br/>download and run
96-
<a class="windows-download" href="https://win.rustup.rs">rustup&#x2011;init.exe</a>
110+
If you are running Windows 64-bit,<br/>download and run
111+
<a class="windows-download" href="https://win.rustup.rs/x86_64">rustup&#x2011;init.exe</a>
112+
then follow the onscreen instructions.
113+
</p>
114+
</div>
115+
116+
<hr/>
117+
118+
<div>
119+
<p>
120+
If you are running Windows 32-bit,<br/>download and run
121+
<a class="windows-download" href="https://win.rustup.rs/i686">rustup&#x2011;init.exe</a>
97122
then follow the onscreen instructions.
98123
</p>
99124
</div>

www/rustup.css

+4-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ hr {
107107
}
108108

109109
#platform-instructions-unix > pre,
110+
#platform-instructions-win32 > pre,
111+
#platform-instructions-win64 > pre,
110112
#platform-instructions-default > div > pre,
111113
#platform-instructions-unknown > div > pre {
112114
background-color: #515151;
@@ -120,7 +122,8 @@ hr {
120122
box-shadow: inset 0px 0px 20px 0px #333333;
121123
}
122124

123-
#platform-instructions-win a.windows-download,
125+
#platform-instructions-win32 a.windows-download,
126+
#platform-instructions-win64 a.windows-download,
124127
#platform-instructions-default a.windows-download,
125128
#platform-instructions-unknown a.windows-download {
126129
display: block;

www/rustup.js

+48-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// IF YOU CHANGE THIS FILE IT MUST BE CHANGED ON BOTH rust-www and rustup.rs
2+
13
var platforms = ["default", "unknown", "win32", "win64", "unix"];
24
var platform_override = null;
35

@@ -23,7 +25,7 @@ function detect_platform() {
2325
if (navigator.platform == "Mac") {os = "unix";}
2426
if (navigator.platform == "Win32") {os = "win32";}
2527
if (navigator.platform == "Win64" ||
26-
navigator.userAgent.indexOf("WOW64") != -1 ||
28+
navigator.userAgent.indexOf("WOW64") != -1 ||
2729
navigator.userAgent.indexOf("Win64") != -1) { os = "win64"; }
2830
if (navigator.platform == "FreeBSD x86_64") {os = "unix";}
2931
if (navigator.platform == "FreeBSD amd64") {os = "unix";}
@@ -38,6 +40,16 @@ function detect_platform() {
3840
if (navigator.appVersion.indexOf("FreeBSD")!=-1) {os = "unix";}
3941
}
4042

43+
// Firefox Quantum likes to hide platform and appVersion but oscpu works
44+
if (navigator.oscpu) {
45+
if (navigator.oscpu.indexOf("Win32")!=-1) {os = "win32";}
46+
if (navigator.oscpu.indexOf("Win64")!=-1) {os = "win64";}
47+
if (navigator.oscpu.indexOf("Mac")!=-1) {os = "unix";}
48+
if (navigator.oscpu.indexOf("Linux")!=-1) {os = "unix";}
49+
if (navigator.oscpu.indexOf("FreeBSD")!=-1) {os = "unix";}
50+
if (navigator.oscpu.indexOf("NetBSD")!=-1) {os = "unix";}
51+
}
52+
4153
return os;
4254
}
4355

@@ -53,10 +65,42 @@ function adjust_for_platform() {
5365
platform_div.style.display = "block";
5466
}
5567
});
68+
69+
adjust_platform_specific_instrs(platform);
70+
}
71+
72+
// NB: This has no effect on rustup.rs
73+
function adjust_platform_specific_instrs(platform) {
74+
var platform_specific = document.getElementsByClassName("platform-specific");
75+
for (var el of platform_specific) {
76+
var el_is_not_win = el.className.indexOf("not-win") !== -1;
77+
var el_is_inline = el.tagName.toLowerCase() == "span";
78+
var el_visible_style = "block";
79+
if (el_is_inline) {
80+
el_visible_style = "inline";
81+
}
82+
if (platform == "win64" || platform == "win32") {
83+
if (el_is_not_win) {
84+
el.style.display = "none";
85+
} else {
86+
el.style.display = el_visible_style;
87+
}
88+
} else {
89+
if (el_is_not_win) {
90+
el.style.display = el_visible_style;
91+
} else {
92+
el.style.display = "none";
93+
}
94+
}
95+
}
5696
}
5797

5898
function cycle_platform() {
59-
platform_override = (platform_override + 1) % platforms.length;
99+
if (platform_override == null) {
100+
platform_override = 0;
101+
} else {
102+
platform_override = (platform_override + 1) % platforms.length;
103+
}
60104
adjust_for_platform();
61105
}
62106

@@ -79,6 +123,7 @@ function set_up_cycle_button() {
79123
if (idx == key.length) {
80124
cycle_button.style.display = "block";
81125
unlocked = true;
126+
cycle_platform();
82127
}
83128
} else if (event.key == key[0]) {
84129
idx = 1;
@@ -93,6 +138,7 @@ function go_to_default_platform() {
93138
adjust_for_platform();
94139
}
95140

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

0 commit comments

Comments
 (0)