Created
June 13, 2014 13:10
-
-
Save sqs/e7369ec8fef62b54ea65 to your computer and use it in GitHub Desktop.
Patch to add speaker notes to the Go present tool (lines beginning with ">"; in the web UI, toggle display with 'n'). Works on all slides but the title slide. Breaks if you have more than one contiguous run of lines starting with "> " in a single slide (due to CSS). I'll submit a real patch upstream soon (unless someone else volunteers).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 5b025577f8ab cmd/present/static/slides.js | |
--- a/cmd/present/static/slides.js Fri Jun 13 12:42:11 2014 +1000 | |
+++ b/cmd/present/static/slides.js Fri Jun 13 06:09:06 2014 -0700 | |
@@ -10,6 +10,8 @@ | |
var curSlide; | |
+var showNotes; | |
+ | |
/* ---------------------------------------------------------------------- */ | |
/* classList polyfill by Eli Grey | |
* (http://purl.eligrey.com/github/classList.js/blob/master/classList.js) */ | |
@@ -214,6 +216,18 @@ | |
} | |
}; | |
+/* Note functions */ | |
+ | |
+function toggleNotes() { | |
+ document.body.classList.toggle('notes-visible'); | |
+ showNotes = !showNotes; | |
+ updateHash(); | |
+} | |
+ | |
+function getShowNotesFromHash() { | |
+ return location.hash.indexOf('-notes') !== -1; | |
+}; | |
+ | |
/* Slide events */ | |
function triggerEnterEvent(no) { | |
@@ -380,7 +394,7 @@ | |
}; | |
function updateHash() { | |
- location.replace('#' + (curSlide + 1)); | |
+ location.replace('#' + (curSlide + 1) + (showNotes ? '-notes' : '')); | |
}; | |
/* Event listeners */ | |
@@ -418,6 +432,10 @@ | |
prevSlide(); | |
event.preventDefault(); | |
break; | |
+ | |
+ case 78: // 'n' | |
+ if (inCode) break; | |
+ toggleNotes(); | |
} | |
}; | |
@@ -474,6 +492,7 @@ | |
addPrintStyle(); | |
addEventListeners(); | |
+ if (getShowNotesFromHash()) toggleNotes(); | |
updateSlides(); | |
setupInteraction(); | |
diff -r 5b025577f8ab cmd/present/static/styles.css | |
--- a/cmd/present/static/styles.css Fri Jun 13 12:42:11 2014 +1000 | |
+++ b/cmd/present/static/styles.css Fri Jun 13 06:09:06 2014 -0700 | |
@@ -415,6 +415,52 @@ | |
bottom: 5px; | |
} | |
+/* Notes */ | |
+ | |
+.note { | |
+ display: none; | |
+ | |
+ padding: 40px 50px; | |
+ | |
+ background-color: rgb(255, 255, 230); | |
+ | |
+ border: solid 1px rgb(215, 215, 215); | |
+ border-radius: 10px; | |
+ -o-border-radius: 10px; | |
+ -moz-border-radius: 10px; | |
+ -webkit-border-radius: 10px; | |
+ | |
+ position: absolute; | |
+ top: 100%; | |
+ left: 0; | |
+ right: 0; | |
+} | |
+ | |
+.note p { | |
+ margin-bottom: 15px; | |
+} | |
+ | |
+.note p:last-child { | |
+ margin-bottom: 0; | |
+} | |
+ | |
+body.notes-visible { | |
+ zoom: 0.60; | |
+} | |
+ | |
+body.notes-visible .note { | |
+ display: block; | |
+} | |
+ | |
+body.notes-visible .slides > article { | |
+ overflow: visible; | |
+ top: 25%; | |
+} | |
+ | |
+body.notes-visible .slide-area { | |
+ top: 25%; | |
+} | |
+ | |
/* Presenter details */ | |
.presenter { | |
margin-top: 20px; | |
diff -r 5b025577f8ab cmd/present/templates/action.tmpl | |
--- a/cmd/present/templates/action.tmpl Fri Jun 13 12:42:11 2014 +1000 | |
+++ b/cmd/present/templates/action.tmpl Fri Jun 13 06:09:06 2014 -0700 | |
@@ -31,6 +31,15 @@ | |
<div class="code{{if playable .}} playground{{end}}" contenteditable="true" spellcheck="false">{{.Text}}</div> | |
{{end}} | |
+{{define "note"}} | |
+ <div class="note"> | |
+ <p> | |
+ {{range $i, $l := .Lines}}{{if not $l}}</p><p>{{end}} | |
+ {{style $l}}{{end}} | |
+ </p> | |
+ </div> | |
+{{end}} | |
+ | |
{{define "image"}} | |
<div class="image"> | |
<img src="{{.URL}}"{{with .Height}} height="{{.}}"{{end}}{{with .Width}} width="{{.}}"{{end}}> | |
diff -r 5b025577f8ab cmd/present/templates/slides.tmpl | |
--- a/cmd/present/templates/slides.tmpl Fri Jun 13 12:42:11 2014 +1000 | |
+++ b/cmd/present/templates/slides.tmpl Fri Jun 13 06:09:06 2014 -0700 | |
@@ -27,12 +27,12 @@ | |
{{range $i, $s := .Sections}} | |
<!-- start of slide {{$s.Number}} --> | |
<article> | |
- {{if $s.Elem}} | |
- <h3>{{$s.Title}}</h3> | |
- {{range $s.Elem}}{{elem $.Template .}}{{end}} | |
+ {{if $s.TitleOnly}} | |
+ <h2>{{$s.Title}}</h2> | |
{{else}} | |
- <h2>{{$s.Title}}</h2> | |
+ <h3>{{$s.Title}}</h3> | |
{{end}} | |
+ {{range $s.Elem}}{{elem $.Template .}}{{end}} | |
</article> | |
<!-- end of slide {{$i}} --> | |
{{end}}{{/* of Slide block */}} | |
diff -r 5b025577f8ab present/parse.go | |
--- a/present/parse.go Fri Jun 13 12:42:11 2014 +1000 | |
+++ b/present/parse.go Fri Jun 13 06:09:06 2014 -0700 | |
@@ -124,6 +124,17 @@ | |
return b.String() | |
} | |
+// TitleOnly returns true if the section contains only a title and (optionally) | |
+// notes, and false otherwise. | |
+func (s Section) TitleOnly() bool { | |
+ for _, e := range s.Elem { | |
+ if _, ok := e.(Note); !ok { | |
+ return false | |
+ } | |
+ } | |
+ return true | |
+} | |
+ | |
func (s Section) TemplateName() string { return "section" } | |
// Elem defines the interface for a present element. That is, something that | |
@@ -168,6 +179,13 @@ | |
func (t Text) TemplateName() string { return "text" } | |
+// Note represents notes about a slide. | |
+type Note struct { | |
+ Lines []string | |
+} | |
+ | |
+func (n Note) TemplateName() string { return "note" } | |
+ | |
// List represents a bulleted list. | |
type List struct { | |
Bullet []string | |
@@ -358,6 +376,14 @@ | |
return nil, err | |
} | |
e = t | |
+ case strings.HasPrefix(text, "> "): | |
+ var l []string | |
+ for ok && strings.HasPrefix(text, ">") { | |
+ l = append(l, strings.TrimSpace(text[1:])) | |
+ text, ok = lines.next() | |
+ } | |
+ lines.back() | |
+ e = Note{Lines: l} | |
default: | |
var l []string | |
for ok && strings.TrimSpace(text) != "" { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment