Commit a8730cd9 authored by Andrew Bonventre's avatar Andrew Bonventre

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/52872Reviewed-by: default avatarChris Broadfoot <cbro@golang.org>
parent b63db76c
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
<div class="left"> <div class="left">
<div id="learn"> <div id="learn">
{{if not $.GoogleCN}}
<a class="popout share">Pop-out</a> <a class="popout share">Pop-out</a>
{{end}}
<div class="rootHeading">Try Go</div> <div class="rootHeading">Try Go</div>
<div class="input"> <div class="input">
<textarea spellcheck="false" class="code">// You can edit this code! <textarea spellcheck="false" class="code">// You can edit this code!
...@@ -26,10 +28,10 @@ Hello, 世界 ...@@ -26,10 +28,10 @@ Hello, 世界
</div> </div>
<div class="buttons"> <div class="buttons">
<a class="run" href="#" title="Run this code [shift-enter]">Run</a> <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> <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> <a class="tour" href="//tour.golang.org/" title="Learn Go from your browser">Tour</a>
{{end}}
</div> </div>
<div class="toys"> <div class="toys">
<select> <select>
...@@ -68,37 +70,38 @@ Linux, Mac OS X, Windows, and more. ...@@ -68,37 +70,38 @@ Linux, Mac OS X, Windows, and more.
<div style="clear: both"></div> <div style="clear: both"></div>
{{if not $.GoogleCN}}
<div class="left"> <div class="left">
<div id="video">
<div id="video"> <div class="rootHeading">Featured video</div>
<div class="rootHeading">Featured video</div> <iframe width="415" height="241" src="//www.youtube.com/embed/ytEkHepK08c" frameborder="0" allowfullscreen></iframe>
<iframe width="415" height="241" src="//www.youtube.com/embed/ytEkHepK08c" frameborder="0" allowfullscreen></iframe> </div>
</div> </div>
{{end}}
</div> <div {{if not $.GoogleCN}}class="right"{{end}}>
<div id="blog">
<div class="right"> <div class="rootHeading">Featured articles</div>
<div class="read"><a href="//blog.golang.org/">Read more</a></div>
<div id="blog"> </div>
<div class="rootHeading">Featured articles</div> </div>
<div class="read"><a href="//blog.golang.org/">Read more</a></div>
</div>
</div>
<div style="clear: both;"></div> <div style="clear: both;"></div>
<script type="text/javascript"> <script>
(function() {
'use strict';
function readableTime(t) { function readableTime(t) {
var m = ["January", "February", "March", "April", "May", "June", "July", var m = ["January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"]; "August", "September", "October", "November", "December"];
var p = t.substring(0, t.indexOf("T")).split("-"); var p = t.substring(0, t.indexOf("T")).split("-");
var d = new Date(p[0], p[1]-1, p[2]); var d = new Date(p[0], p[1]-1, p[2]);
return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear(); return d.getDate() + " " + m[d.getMonth()] + " " + d.getFullYear();
} }
function feedLoaded(result) { window.feedLoaded = function(result) {
var blog = document.getElementById("blog"); var blog = document.getElementById("blog");
var read = blog.getElementsByClassName("read")[0]; var read = blog.getElementsByClassName("read")[0];
for (var i = 0; i < result.length && i < 2; i++) { for (var i = 0; i < result.length && i < 2; i++) {
...@@ -117,9 +120,9 @@ function feedLoaded(result) { ...@@ -117,9 +120,9 @@ function feedLoaded(result) {
when.innerHTML = "Published " + readableTime(entry.Time); when.innerHTML = "Published " + readableTime(entry.Time);
blog.insertBefore(when, read); blog.insertBefore(when, read);
} }
} }
window.initFuncs.push(function() { window.initFuncs.push(function() {
// Set up playground if enabled. // Set up playground if enabled.
if (window.playground) { if (window.playground) {
window.playground({ window.playground({
...@@ -138,7 +141,11 @@ window.initFuncs.push(function() { ...@@ -138,7 +141,11 @@ window.initFuncs.push(function() {
$('<script/>').attr('text', 'text/javascript') $('<script/>').attr('text', 'text/javascript')
.attr('src', '//blog.golang.org/.json?jsonp=feedLoaded') .attr('src', '//blog.golang.org/.json?jsonp=feedLoaded')
.appendTo('body'); .appendTo('body');
});
{{if not $.GoogleCN}}
window.initFuncs.push(function() {
// Set the video at random. // Set the video at random.
var videos = [ var videos = [
{h: 241, s: "//www.youtube.com/embed/ytEkHepK08c"}, // Tour of Go {h: 241, s: "//www.youtube.com/embed/ytEkHepK08c"}, // Tour of Go
...@@ -147,6 +154,8 @@ window.initFuncs.push(function() { ...@@ -147,6 +154,8 @@ window.initFuncs.push(function() {
]; ];
var v = videos[Math.floor(Math.random()*videos.length)]; var v = videos[Math.floor(Math.random()*videos.length)];
$('#video iframe').attr('height', v.h).attr('src', v.s); $('#video iframe').attr('height', v.h).attr('src', v.s);
}); });
{{end}}
})();
</script> </script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment