-
Notifications
You must be signed in to change notification settings - Fork 5
/
slides2png.groovy
51 lines (40 loc) · 1.08 KB
/
slides2png.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* Converts a reveal.js slideshow to png's
* based on the original slides2png by Dan Allen
*
* @author Jason Swartz
* @license ASLv2
*/
@Grapes([
@Grab("org.gebish:geb-core:0.9.3"),
@Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.42.2"),
@Grab("org.seleniumhq.selenium:selenium-support:2.42.2")
])
import geb.Browser
if (args.length != 1) {
println "usage: slides2png.groovy <url> "
return
}
def url = args[0]
def dirName = "slides_" + new Date().time
def idx = 0
def MAX_SLIDES = 999
def SLEEP_MS = 500
Browser.drive {
def fullScreen = { $('body') << 'f' }
def nextSlide = { $('body') << 'n' }
def hasMore = { browser.driver.executeScript("return Reveal.availableRoutes().right;") }
config.reporter = new geb.report.ScreenshotReporter()
config.reportsDir = new File(dirName)
cleanReportGroupDir()
go url
fullScreen()
while (idx++ < MAX_SLIDES) {
sleep SLEEP_MS
report sprintf("slide_%04d", idx)
if (!hasMore()) break
nextSlide()
}
}.quit()
"bin/png2pdf.sh ${dirName}".execute()
println "Rendered ${idx} slides to ${dirName}.pdf"