Skip to content

Commit 5003a35

Browse files
committed
Fix #538 - Homepage code sample has tabs for different runtime environments.
1 parent e9c7fa2 commit 5003a35

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

docs/site/css/main.css

+26
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,32 @@ ul {
586586
color: #4285f4;
587587
}
588588

589+
.about .code-sample-tabs {
590+
margin-top: 10px;
591+
width: 450px;
592+
}
593+
594+
.about .code-sample-tabs a {
595+
display: inline-block;
596+
padding: 2px 12px 0px 12px;
597+
border: 1px solid rgba(0,0,0,0.2);
598+
background-color: #fefefe;
599+
margin-bottom: -3px;
600+
margin-right: 8px;
601+
color: #333;
602+
text-decoration: none;
603+
}
604+
605+
.about .code-sample-tabs a.selected {
606+
background-color: #f8f8f8;
607+
font-weight: bold;
608+
border-bottom-color: #f8f8f8;
609+
}
610+
611+
.about pre {
612+
margin-top: 0;
613+
}
614+
589615
/*
590616
Examples
591617
*/

docs/site/home.html

+20-3
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,18 @@ <h3 class="block-title">What is it?</h3>
8080
</div>
8181

8282
<div class="quote-box--supplementary">
83-
<h4>Retrieve Datastore Entities</h4>
84-
85-
<div hljs language="js">
83+
<h4>Example: Retrieve an entity from Cloud Datastore</h4>
84+
85+
<div class="code-sample-tabs" ng-init="selected = 'compute engine'">
86+
<a ng-click="selected = 'anywhere'"
87+
ng-class="{selected: selected == 'anywhere'}"
88+
>Run anywhere</a>
89+
<a ng-click="selected = 'compute engine'"
90+
ng-class="{selected: selected == 'compute engine'}"
91+
>Run in Compute Engine</a>
92+
</div>
93+
94+
<div hljs language="js" ng-show="selected == 'anywhere'">
8695
var gcloud = require('gcloud')({
8796
projectId: 'my-project',
8897
keyFilename: '/path/to/keyfile.json'
@@ -95,6 +104,14 @@ <h4>Retrieve Datastore Entities</h4>
95104
console.log(err, entity);
96105
});</div>
97106

107+
<div hljs language="js" ng-show="selected == 'compute engine'">
108+
// Auth is handled automatically inside GCE.
109+
var dataset = require('gcloud').datastore.dataset();
110+
var productKey = dataset.key(['Product', 123]);
111+
112+
dataset.get(productKey, function(err, entity) {
113+
console.log(err, entity);
114+
});</div>
98115
</div>
99116
</div><!-- end of .container -->
100117
</section><!-- end of .featuring -->

0 commit comments

Comments
 (0)