app: add support to download snippets

When a file is requested with the "?download=true" query string, the
Playground will now serve the file with the "Content-Disposition" header that
makes the browser download the snippet rather than display it.

Updates golang/go#15378.

Change-Id: Iba3e04418e92d3aed3d27e4d6903d6a4d2ce944f
Reviewed-on: https://go-review.googlesource.com/35950
Reviewed-by: Chris Broadfoot <cbro@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
diff --git a/app/goplay/edit.go b/app/goplay/edit.go
index 25eb9db..0df15cc 100644
--- a/app/goplay/edit.go
+++ b/app/goplay/edit.go
@@ -5,6 +5,7 @@
 package goplay
 
 import (
+	"fmt"
 	"html/template"
 	"net/http"
 	"strings"
@@ -57,6 +58,11 @@
 			return
 		}
 		if serveText {
+			if r.FormValue("download") == "true" {
+				w.Header().Set(
+					"Content-Disposition", fmt.Sprintf(`attachment; filename="%s.go"`, id),
+				)
+			}
 			w.Header().Set("Content-type", "text/plain")
 			w.Write(snip.Body)
 			return
diff --git a/app/goplay/edit.html b/app/goplay/edit.html
index 740e98d..f4229fb 100644
--- a/app/goplay/edit.html
+++ b/app/goplay/edit.html
@@ -19,7 +19,8 @@
 				'shareEl':      '#share',
 				'shareURLEl':   '#shareURL',
 				{{end}}
-				'enableHistory': true
+				'enableHistory': true,
+				'enableShortcuts': true
 			});
 			playgroundEmbed({
 				'codeEl':       '#code',
diff --git a/app/static/style.css b/app/static/style.css
index f77a577..1cd00e8 100644
--- a/app/static/style.css
+++ b/app/static/style.css
@@ -11,7 +11,7 @@
 a {
 	color: #009;
 }
-#wrap, 
+#wrap,
 #about {
 	padding: 5px;
 	margin: 0;