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:
parent
52d9c872e3
commit
b75b3f5cd5
|
@ -31,6 +31,7 @@ var (
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.BoolVar(&present.PlayEnabled, "play", true, "enable playground (permit execution of arbitrary user code)")
|
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()
|
flag.Parse()
|
||||||
|
|
||||||
if *basePath == "" {
|
if *basePath == "" {
|
||||||
|
@ -85,6 +86,9 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Open your web browser and visit %s", origin.String())
|
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))
|
log.Fatal(http.Serve(ln, nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Is the playground available?
|
// PlayEnabled specifies whether runnable playground snippets should be
|
||||||
|
// displayed in the present user interface.
|
||||||
var PlayEnabled = false
|
var PlayEnabled = false
|
||||||
|
|
||||||
// TODO(adg): replace the PlayEnabled flag with something less spaghetti-like.
|
// 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
|
// value that contains various global metadata required when rendering
|
||||||
// templates.
|
// templates.
|
||||||
|
|
||||||
|
// NotesEnabled specifies whether presenter notes should be displayed in the
|
||||||
|
// present user interface.
|
||||||
|
var NotesEnabled = false
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Register("code", parseCode)
|
Register("code", parseCode)
|
||||||
Register("play", parseCode)
|
Register("play", parseCode)
|
||||||
|
|
|
@ -35,9 +35,10 @@ func Template() *template.Template {
|
||||||
func (d *Doc) Render(w io.Writer, t *template.Template) error {
|
func (d *Doc) Render(w io.Writer, t *template.Template) error {
|
||||||
data := struct {
|
data := struct {
|
||||||
*Doc
|
*Doc
|
||||||
Template *template.Template
|
Template *template.Template
|
||||||
PlayEnabled bool
|
PlayEnabled bool
|
||||||
}{d, t, PlayEnabled}
|
NotesEnabled bool
|
||||||
|
}{d, t, PlayEnabled, NotesEnabled}
|
||||||
return t.ExecuteTemplate(w, "root", data)
|
return t.ExecuteTemplate(w, "root", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue