forked from jxtx/covid-lessons
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jakefile
83 lines (56 loc) · 2.6 KB
/
Jakefile
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const { task, rule, Task } = require('jake')
const exec = require('child_process').execSync
const html_style = "+native_spans+native_divs"
const md_style = "+fenced_divs+bracketed_spans+definition_lists+yaml_metadata_block"
const slidy_style = ""
const acc_key = "" /** enter your AWS_ACCESS_KEY_ID */
const secret_key = "" /** enter your AWS_SECRET_ACCESS_KEY */
/**
* Build rules for making HTML and PDF slides from annotated Markdown,
* extracting narration scripts, and building videos (with ari).
*/
/** Build slides HTML from Markdown with pandoc */
rule(`dist/%-slides.html`, 'src/%.md', ['src/slides.css'], function () {
exec(`pandoc --webtex -t slidy${slidy_style} ${this.source} -f markdown${md_style} \
-o ${this.name} --self-contained --css src/slides.css 2>&1`)
})
/** Build document HTML from Markdown with pandoc */
rule(`dist/%-document.html`, 'src/%.md', ['src/document.css'], function () {
exec(`pandoc -f markdown${md_style} -t html${html_style} ${this.source} \
-o ${this.name} --section-divs --self-contained --css src/document.css 2>&1`)
})
/** Build script from HTML */
rule(`dist/%.script`, 'dist/%-slides.html', function () {
exec(`node ./scripts/extract-script-from-html.js ${this.source} --translate=script-rewrite-words.yaml > ${this.name} 2>&1 `)
})
/** Build slide images */
rule(`dist/%.001.png`, 'dist/%.script', function () {
let basename = this.name.substring(0, this.name.indexOf('.'))
exec(`bash ./scripts/create_images.sh -h ${basename}-slides.html -s ${this.source} -o ${basename} 2>&1`)
})
/** Build slide pdf */
rule(`dist/%-slides.pdf`, 'dist/%-slides.html' ,['src/topdf.css'], function () {
exec(`weasyprint -s src/topdf.css ${this.source} ${this.name} 2>&1`)
})
/** Build video from images and script using ari */
rule(`dist/%.mp4`, `dist/%.001.png`, function () {
let basename = this.name.substring(0, this.name.lastIndexOf('.'))
// Run ari
exec(`./scripts/run_ari_spin.R ${this.name} ${basename}.script ${acc_key} ${secret_key} ${basename}.*.png 2>&1`)
})
/** Default task: build HTML slides */
task('slides-html', ['dist/%-slides.html'])
/** Default task: build full page HTML document */
task('document-html', ['dist/%-document.html'])
/** Build PDF files from slides */
task('slides-pdf', ['dist/%-slides.pdf'])
/** Build images */
/** task('slides-img', ['dist/%.001.png']) */
/** Build script */
/** task('slides-script', ['dist/%.script']) */
/** Build video files */
task('slides-video', ['dist/%-slides.mp4'])
/** Build vuepress site that provides overall index */
task('site', function () {
exec('vuepress build src')
})