x/tools/present: add command line flag to enable presenter notes

Change-Id: I9d4414ce8bafcb13f53361b45774f379bacd886b
Reviewed-on: https://go-review.googlesource.com/21486
Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
Audrey Lim 2016-04-03 16:33:36 -07:00 committed by Andrew Gerrand
parent 52d9c872e3
commit b75b3f5cd5
3 changed files with 14 additions and 4 deletions

View File

@ -31,6 +31,7 @@ var (
func main() {
flag.BoolVar(&present.PlayEnabled, "play", true, "enable playground (permit execution of arbitrary user code)")
flag.BoolVar(&present.NotesEnabled, "notes", false, "enable presenter notes (press 'N' from the browser to display them)")
flag.Parse()
if *basePath == "" {
@ -85,6 +86,9 @@ func main() {
}
log.Printf("Open your web browser and visit %s", origin.String())
if present.NotesEnabled {
log.Println("Notes are enabled, press 'N' from the browser to display them.")
}
log.Fatal(http.Serve(ln, nil))
}

View File

@ -15,7 +15,8 @@ import (
"strings"
)
// Is the playground available?
// PlayEnabled specifies whether runnable playground snippets should be
// displayed in the present user interface.
var PlayEnabled = false
// TODO(adg): replace the PlayEnabled flag with something less spaghetti-like.
@ -23,6 +24,10 @@ var PlayEnabled = false
// value that contains various global metadata required when rendering
// templates.
// NotesEnabled specifies whether presenter notes should be displayed in the
// present user interface.
var NotesEnabled = false
func init() {
Register("code", parseCode)
Register("play", parseCode)

View File

@ -37,7 +37,8 @@ func (d *Doc) Render(w io.Writer, t *template.Template) error {
*Doc
Template *template.Template
PlayEnabled bool
}{d, t, PlayEnabled}
NotesEnabled bool
}{d, t, PlayEnabled, NotesEnabled}
return t.ExecuteTemplate(w, "root", data)
}