From 2e3bd1924b3f6bed7c30c21273d485bf961b6d48 Mon Sep 17 00:00:00 2001 From: "Roger D. Peng [amelia]" Date: Mon, 20 Jan 2014 22:57:03 -0500 Subject: [PATCH] PDF generators --- 05_ReproducibleResearch/makefile | 24 ++++++++++++++++++++++++ 05_ReproducibleResearch/makepdf.js | 10 ++++++++++ 2 files changed, 34 insertions(+) create mode 100644 05_ReproducibleResearch/makefile create mode 100644 05_ReproducibleResearch/makepdf.js diff --git a/05_ReproducibleResearch/makefile b/05_ReproducibleResearch/makefile new file mode 100644 index 0000000..07c62cb --- /dev/null +++ b/05_ReproducibleResearch/makefile @@ -0,0 +1,24 @@ +DELAY = 1000 +RMD_FILES = $(wildcard */index.Rmd) +HTML_FILES = $(patsubst %.Rmd, %.html, $(RMD_FILES)) +PDF_FILES = $(patsubst %/index.html, lectures/%.pdf, $(HTML_FILES)) + +listfiles: + @echo $(RMD_FILES) + @echo $(HTML_FILES) + @echo $(PDF_FILES) + + +html: $(HTML_FILES) +pdf: $(PDF_FILES) +all: html pdf + +zip: $(PDF_FILES) + zip all_pdf_files.zip $^ + +lectures/%.pdf: %/index.html + casperjs makepdf.js $< $@ $(DELAY) + +%/index.html: %/index.Rmd + cd $(dir $<) && Rscript -e "slidify::slidify('index.Rmd')" && cd .. + diff --git a/05_ReproducibleResearch/makepdf.js b/05_ReproducibleResearch/makepdf.js new file mode 100644 index 0000000..c01526f --- /dev/null +++ b/05_ReproducibleResearch/makepdf.js @@ -0,0 +1,10 @@ +var casper = require('casper').create({viewportSize:{width:1500,height:1000}}); +var args = casper.cli.args; +var imgfile = (args[1] || Math.random().toString(36).slice(2)) +casper.start(args[0], function() { + this.wait(args[2], function(){ + this.captureSelector(imgfile, "slides"); + }); +}); + +casper.run(); \ No newline at end of file