Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

Update website for rustup installation #621

Merged
merged 8 commits into from
Dec 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ name: The Rust Programming Language
stable: "1.13.0"
stable_date: "2016-11-10"
stable_blog: "/2016/11/10/Rust-1.13.html"
stable_full_version: "rustc 1.13.0 (2c6933acc 2016-11-07)"
beta: "1.14"
beta_date: "2016-12-22"
nightly: "1.15"
channels:
- name: "stable"
vers: "1.13.0"
package: "1.13.0"
- name: "beta"
vers: "1.14"
package: "beta"
- name: "nightly"
vers: "1.15"
package: "nightly"
147 changes: 147 additions & 0 deletions _includes/rustup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
var platform_override = null;

function detect_platform() {
"use strict";

if (platform_override) {
return platform_override;
}

var os = "unknown";

if (navigator.platform == "Linux x86_64") {os = "unix";}
if (navigator.platform == "Linux i686") {os = "unix";}
if (navigator.platform == "Linux i686 on x86_64") {os = "unix";}
if (navigator.platform == "Linux aarch64") {os = "unix";}
if (navigator.platform == "Linux armv6l") {os = "unix";}
if (navigator.platform == "Linux armv7l") {os = "unix";}
if (navigator.platform == "Mac") {os = "unix";}
if (navigator.platform == "Win32") {os = "win";}
if (navigator.platform == "FreeBSD x86_64") {os = "unix";}
if (navigator.platform == "FreeBSD amd64") {os = "unix";}

if (navigator.platform == "Linux armv7l"
&& navigator.appVersion.indexOf("Android") != -1 ) {
os = "android";
}

// 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("Mac")!=-1) {os = "unix";}
}

return os;
}

function adjust_for_platform() {
"use strict";

var platform = detect_platform();

var unix_div = document.getElementById("platform-instructions-unix");
var win_div = document.getElementById("platform-instructions-win");
var android_div = document.getElementById("platform-instructions-android");
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";
android_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 == "android") {
android_div.style.display = "block";
} else if (platform == "unknown") {
unknown_div.style.display = "block";
} else {
default_div.style.display = "block";
}

var platform_specific = document.getElementsByClassName("platform-specific");
for (var el of platform_specific) {
var el_is_not_win = el.className.indexOf("not-win") !== -1;
var el_is_inline = el.tagName.toLowerCase() == "span";
var el_visible_style = "block";
if (el_is_inline) {
el_visible_style = "inline";
}
if (platform == "win") {
if (el_is_not_win) {
el.style.display = "none";
} else {
el.style.display = el_visible_style;
}
} else {
if (el_is_not_win) {
el.style.display = el_visible_style;
} else {
el.style.display = "none";
}
}
}
}

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 = "android";
} else if (platform_override == "android") {
platform_override = "default";
}
adjust_for_platform();
}

function set_up_cycle_button() {
var cycle_button = document.getElementById("platform-button");
cycle_button.onclick = cycle_platform;

var key="test";
var idx=0;
var unlocked=false;

document.onkeypress = function(event) {
if (event.key == "n" && unlocked) {
cycle_platform();
}

if (event.key == key[idx]) {
idx += 1;

if (idx == key.length) {
cycle_button.style.display = "block";
unlocked = true;
cycle_platform();
}
} else if (event.key == key[0]) {
idx = 1;
} else {
idx = 0;
}
};
}

function fill_in_bug_report_values() {
var nav_plat = document.getElementById("nav-plat");
var nav_app = document.getElementById("nav-app");
nav_plat.textContent = navigator.platform;
nav_app.textContent = navigator.appVersion;
}

(function () {
adjust_for_platform();
set_up_cycle_button();
fill_in_bug_report_values();
}());
2 changes: 1 addition & 1 deletion _layouts/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</li>
<li class="col-xs-12 col-md-10 menu">
<h2><a href="/en-US/documentation.html">Documentation</a></h2>
<h2><a href="/en-US/install.html">Install</a></h2>
<h2><a href="/en-US/community.html">Community</a></h2>
<h2><a href="/en-US/downloads.html">Downloads</a></h2>
<h2><a href="/en-US/contribute.html">Contribute</a></h2>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion _layouts/fr/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</li>
<li class="col-xs-12 col-md-10 menu">
<h2><a href="/fr/documentation.html">Documentation</a></h2>
<h2><a href="/fr/install.html">Install</a></h2>
<h2><a href="/fr/community.html">Communauté</a></h2>
<h2><a href="/fr/downloads.html">Télécharger</a></h2>
<h2><a href="/fr/contribute.html">Contribuer</a></h2>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion _layouts/ko-KR/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</li>
<li class="col-xs-12 col-md-10 menu">
<h2><a href="/ko-KR/documentation.html">문서</a></h2>
<h2><a href="/ko-KR/install.html">Install</a></h2>
<h2><a href="/ko-KR/community.html">커뮤니티</a></h2>
<h2><a href="/ko-KR/downloads.html">다운로드</a></h2>
<h2><a href="/ko-KR/contribute.html">기여하기</a></h2>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion _layouts/pt-BR/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</li>
<li class="col-xs-12 col-md-10 menu">
<h2><a href="/pt-BR/documentation.html">Documentação</a></h2>
<h2><a href="/pt-BR/install.html">Install</a></h2>
<h2><a href="/pt-BR/community.html">Comunidade</a></h2>
<h2><a href="/pt-BR/downloads.html">Downloads</a></h2>
<h2><a href="/pt-BR/contribute.html">Contribua</a></h2>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion _layouts/ru-RU/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</li>
<li class="col-xs-12 col-md-10 menu">
<h2><a href="/ru-RU/documentation.html">Документация</a></h2>
<h2><a href="/ru-RU/install.html">Install</a></h2>
<h2><a href="/ru-RU/community.html">Сообщество</a></h2>
<h2><a href="/ru-RU/downloads.html">Загрузки</a></h2>
<h2><a href="/ru-RU/contribute.html">Участие</a></h2>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion _layouts/zh-CN/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
</li>
<li class="col-xs-12 col-md-10 menu">
<h2><a href="/zh-CN/documentation.html">文档</a></h2>
<h2><a href="/zh-CN/install.html">Install</a></h2>
<h2><a href="/zh-CN/community.html">社区</a></h2>
<h2><a href="/zh-CN/downloads.html">下载</a></h2>
<h2><a href="/zh-CN/contribute.html">贡献</a></h2>
</li>
</ul>
Expand Down
Loading