Merge pull request #382 from lucidlime/i308
Remove play links for pkgs outside std lib
diff --git a/gddo-server/assets/templates/pkg.html b/gddo-server/assets/templates/pkg.html
index 3f9883d..9bd8f68 100644
--- a/gddo-server/assets/templates/pkg.html
+++ b/gddo-server/assets/templates/pkg.html
@@ -171,7 +171,7 @@
<div class="panel-heading"><a class="accordion-toggle" data-toggle="collapse" href="#ex-{{.ID}}">Example{{with .Example.Name}} ({{.}}){{end}}</a></div>
<div id="ex-{{.ID}}" class="panel-collapse collapse"><div class="panel-body">
{{with .Example.Doc}}<p>{{.|comment}}{{end}}
- <p>Code:{{if .Example.Play}}<span class="pull-right"><a href="?play={{.ID}}">play</a> </span>{{end}}
+ <p>Code:{{if .Play}}<span class="pull-right"><a href="?play={{.ID}}">play</a> </span>{{end}}
{{code .Example.Code nil}}
{{with .Example.Output}}<p>Output:<pre>{{.}}</pre>{{end}}
</div></div>
diff --git a/gddo-server/template.go b/gddo-server/template.go
index 8a50a44..272dbf0 100644
--- a/gddo-server/template.go
+++ b/gddo-server/template.go
@@ -85,6 +85,7 @@
ID string
Label string
Example *doc.Example
+ Play bool
obj interface{}
}
@@ -121,7 +122,14 @@
id += "-" + method
}
for _, e := range examples {
- te := &texample{Label: label, ID: id, Example: e, obj: obj}
+ te := &texample{
+ Label: label,
+ ID: id,
+ Example: e,
+ obj: obj,
+ // Only show play links for packages within the standard library.
+ Play: e.Play != "" && gosrc.IsGoRepoPath(pdoc.ImportPath),
+ }
if e.Name != "" {
te.Label += " (" + e.Name + ")"
if method == "" {