aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bonventre <andybons@golang.org>2017-08-02 16:31:46 -0400
committerAndrew Bonventre <andybons@golang.org>2017-08-02 21:09:49 +0000
commita8730cd93a6731a14519902ccfed604971d3e8dc (patch)
tree1cfe6221f817a2625e35253f6cc299e423ffa9f4
parentb63db76c4ae4e154ed40b4ec3c782d7fe9c0d3b6 (diff)
downloadgo-a8730cd93a6731a14519902ccfed604971d3e8dc.tar.gz
go-a8730cd93a6731a14519902ccfed604971d3e8dc.zip
doc: hide video and share if being served from CN
In the case where requests are coming from mainland China, hide links to locations that are blocked and functionality that is not permitted. Additionally, some very small cleanup of the JS. This change requires https://go-review.googlesource.com/c/52873 Change-Id: I7fc68748e629dbe5b966d6bf117e7f7b546966eb Reviewed-on: https://go-review.googlesource.com/52872 Reviewed-by: Chris Broadfoot <cbro@golang.org>
-rw-r--r--doc/root.html155
1 files changed, 82 insertions, 73 deletions
diff --git a/doc/root.html b/doc/root.html
index 27dbc74ab6..0b3c74954b 100644
--- a/doc/root.html
+++ b/doc/root.html
@@ -6,7 +6,9 @@
<div class="left">
<div id="learn">
+{{if not $.GoogleCN}}
<a class="popout share">Pop-out</a>
+{{end}}
<div class="rootHeading">Try Go</div>
<div class="input">
<textarea spellcheck="false" class="code">// You can edit this code!
@@ -26,10 +28,10 @@ Hello, 世界
</div>
<div class="buttons">
<a class="run" href="#" title="Run this code [shift-enter]">Run</a>
-{{if $.Share}}
+{{if not $.GoogleCN}}
<a class="share" href="#" title="Share this code">Share</a>
-{{end}}
<a class="tour" href="//tour.golang.org/" title="Learn Go from your browser">Tour</a>
+{{end}}
</div>
<div class="toys">
<select>
@@ -68,85 +70,92 @@ Linux, Mac OS X, Windows, and more.
<div style="clear: both"></div>
+{{if not $.GoogleCN}}
<div class="left">
-
-<div id="video">
-<div class="rootHeading">Featured video</div>
-<iframe width="415" height="241" src="//www.youtube.com/embed/ytEkHepK08c" frameborder="0" allowfullscreen></iframe>
+ <div id="video">
+ <div class="rootHeading">Featured video</div>
+ <iframe width="415" height="241" src="//www.youtube.com/embed/ytEkHepK08c" frameborder="0" allowfullscreen></iframe>
+ </div>
</div>
+{{end}}
-</div>
-
-<div class="right">
-
-<div id="blog">
-<div class="rootHeading">Featured articles</div>
-<div class="read"><a href="//blog.golang.org/">Read more</a></div>
-</div>
+ <div {{if not $.GoogleCN}}class="right"{{end}}>
+ <div id="blog">
+ <div class="rootHeading">Featured articles</div>
+ <div class="read"><a href="//blog.golang.org/">Read more</a></div>
+ </div>
+ </div>
-</div>
<div style="clear: both;"></div>
-<script type="text/javascript">
-
-function readableTime(t) {
- var m = ["January", "February", "March", "April", "May", "June", "July",
- "August", "September", "October", "November", "December"];
- var p = t.substring(0, t.indexOf("T")).split("-");
- var d = new Date(p[0], p[1]-1, p[2]);
- return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear();
-}
-
-function feedLoaded(result) {
- var blog = document.getElementById("blog");
- var read = blog.getElementsByClassName("read")[0];
- for (var i = 0; i < result.length && i < 2; i++) {
- var entry = result[i];
- var title = document.createElement("a");
- title.className = "title";
- title.href = entry.Link;
- title.innerHTML = entry.Title;
- blog.insertBefore(title, read);
- var extract = document.createElement("div");
- extract.className = "extract";
- extract.innerHTML = entry.Summary;
- blog.insertBefore(extract, read);
- var when = document.createElement("div");
- when.className = "when";
- when.innerHTML = "Published " + readableTime(entry.Time);
- blog.insertBefore(when, read);
- }
-}
-
-window.initFuncs.push(function() {
- // Set up playground if enabled.
- if (window.playground) {
- window.playground({
- "codeEl": "#learn .code",
- "outputEl": "#learn .output",
- "runEl": "#learn .run",
- "shareEl": "#learn .share",
- "shareRedirect": "//play.golang.org/p/",
- "toysEl": "#learn .toys select"
- });
- } else {
- $('#learn').hide()
+<script>
+(function() {
+ 'use strict';
+
+ function readableTime(t) {
+ var m = ["January", "February", "March", "April", "May", "June", "July",
+ "August", "September", "October", "November", "December"];
+ var p = t.substring(0, t.indexOf("T")).split("-");
+ var d = new Date(p[0], p[1]-1, p[2]);
+ return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear();
}
- // Load blog feed.
- $('<script/>').attr('text', 'text/javascript')
- .attr('src', '//blog.golang.org/.json?jsonp=feedLoaded')
- .appendTo('body');
-
- // Set the video at random.
- var videos = [
- {h: 241, s: "//www.youtube.com/embed/ytEkHepK08c"}, // Tour of Go
- {h: 241, s: "//www.youtube.com/embed/f6kdp27TYZs"}, // Concurrency Patterns
- {h: 233, s: "//player.vimeo.com/video/69237265"} // Simple environment
- ];
- var v = videos[Math.floor(Math.random()*videos.length)];
- $('#video iframe').attr('height', v.h).attr('src', v.s);
-});
+ window.feedLoaded = function(result) {
+ var blog = document.getElementById("blog");
+ var read = blog.getElementsByClassName("read")[0];
+ for (var i = 0; i < result.length && i < 2; i++) {
+ var entry = result[i];
+ var title = document.createElement("a");
+ title.className = "title";
+ title.href = entry.Link;
+ title.innerHTML = entry.Title;
+ blog.insertBefore(title, read);
+ var extract = document.createElement("div");
+ extract.className = "extract";
+ extract.innerHTML = entry.Summary;
+ blog.insertBefore(extract, read);
+ var when = document.createElement("div");
+ when.className = "when";
+ when.innerHTML = "Published " + readableTime(entry.Time);
+ blog.insertBefore(when, read);
+ }
+ }
+ window.initFuncs.push(function() {
+ // Set up playground if enabled.
+ if (window.playground) {
+ window.playground({
+ "codeEl": "#learn .code",
+ "outputEl": "#learn .output",
+ "runEl": "#learn .run",
+ "shareEl": "#learn .share",
+ "shareRedirect": "//play.golang.org/p/",
+ "toysEl": "#learn .toys select"
+ });
+ } else {
+ $('#learn').hide()
+ }
+
+ // Load blog feed.
+ $('<script/>').attr('text', 'text/javascript')
+ .attr('src', '//blog.golang.org/.json?jsonp=feedLoaded')
+ .appendTo('body');
+ });
+
+ {{if not $.GoogleCN}}
+
+ window.initFuncs.push(function() {
+ // Set the video at random.
+ var videos = [
+ {h: 241, s: "//www.youtube.com/embed/ytEkHepK08c"}, // Tour of Go
+ {h: 241, s: "//www.youtube.com/embed/f6kdp27TYZs"}, // Concurrency Patterns
+ {h: 233, s: "//player.vimeo.com/video/69237265"} // Simple environment
+ ];
+ var v = videos[Math.floor(Math.random()*videos.length)];
+ $('#video iframe').attr('height', v.h).attr('src', v.s);
+ });
+
+ {{end}}
+})();
</script>