Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
257 lines (228 loc) · 8.37 KB
/
Copy pathbuild.gradle
File metadata and controls
257 lines (228 loc) · 8.37 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
import org.ajoberstar.grgit.*
import com.sun.net.httpserver.*
import groovy.json.*
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'uk.co.cacoethes:lazybones-gradle:1.2.4'
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
classpath 'com.github.jruby-gradle:jruby-gradle-plugin:1.4.0'
classpath 'org.ysb33r.gradle:vfs-gradle-plugin:1.0'
classpath 'commons-httpclient:commons-httpclient:3.1'
classpath 'org.ajoberstar:gradle-git:1.7.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.14.0'
}
}
plugins {
id 'org.asciidoctor.convert' version '1.5.3'
id 'com.github.jruby-gradle.base' version '1.2.1'
}
apply plugin: 'com.github.jruby-gradle.base'
apply plugin: 'org.ysb33r.vfs'
apply plugin: 'groovy'
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'uk.co.cacoethes.lazybones-templates'
apply plugin: 'idea'
apply plugin: 'com.github.ben-manes.versions'
version = '1.0.0-SNAPSHOT'
ext {
revealjsVersion = '3.4.1'
revealjs_version = '3.4.1' // TODO
asciidoctorBackendVersion = 'master'
downloadDir = new File(buildDir, 'download')
templateDir = new File(downloadDir, 'templates')
revealjsDir = new File(downloadDir, 'reveal.js')
javafxHome = System.env['JAVAFX_HOME']
}
repositories {
jcenter()
}
dependencies {
gems 'rubygems:asciidoctor-diagram:1.4.0'
gems 'rubygems:slim:3.0.6'
gems 'rubygems:thread_safe:0.3.5'
compile 'org.codehaus.groovy:groovy-all:2.4.10'
compile 'org.groovyfx:groovyfx:8.0.0'
compile 'org.controlsfx:controlsfx:8.40.12'
compile 'com.miglayout:miglayout-javafx:5.0'
compile files("${javafxHome}/rt/lib/jfxrt.jar")
}
idea {
project {
ipr {
withXml { provider ->
def node = provider.asNode()
//configure git support for the project in idea
node.component.find { it.'@name' == 'VcsDirectoryMappings' }?.mapping[0].'@vcs' = 'Git'
}
}
}
}
task download << {
mkdir downloadDir
vfs {
//cp "zip:https://github.com/asciidoctor/asciidoctor-reveal.js/archive/${asciidoctorBackendVersion}.zip!asciidoctor-reveal.js-${asciidoctorBackendVersion}",
// templateDir, recursive: true, overwrite: true
cp "zip:https://github.com/hakimel/reveal.js/archive/${revealjsVersion}.zip!reveal.js-${revealjsVersion}", revealjsDir, recursive: true, overwrite: true
}
if (!templateDir.exists()) {
Grgit.clone(dir: templateDir, uri: 'https://github.com/asciidoctor/asciidoctor-reveal.js')
}
}
download {
description "Download extra revealjs resources"
outputs.dir templateDir
outputs.dir revealjsDir
}
asciidoctorj {
version = '1.5.4'
}
asciidoctor {
sources {
include 'index.adoc'
include 'master.adoc'
}
/*
gemPath = jrubyPrepareGems.outputDir
requires = ['asciidoctor-diagram']
*/
resources {
from(downloadDir) {
include 'reveal.js/**'
}
from(sourceDir) {
include 'images/**'
include 'theme/**'
include 'reveal.js/**'
}
}
backends 'revealjs'
attributes 'build-gradle': file('build.gradle'),
'sourcedir': project.sourceSets.main.groovy.srcDirs[0],
'endpoint-url': 'http://example.org',
//'source-highlighter': 'coderay',
'source-highlighter': 'highlightjs',
'imagesoutdir': 'images',
'imagesdir': './images',
'toc': 'left',
'icons': 'font',
'setanchors': 'true',
'idprefix': '',
'idseparator': '-',
'docinfo1': 'true',
'revealjs_width': 1024,
'revealjs_height': 700,
//'revealjs_theme': 'black',
'revealjs_customtheme': 'theme/cc.css',
'revealjs_transition': 'linear',
'revealjs_history': 'true',
'revealjs_slideNumber': 'true',
'revealjs_center': 'false',
'highlightjs-theme': 'reveal.js/plugin/highlight/styles/atelier-forest.light.css',
'linkattrs': true,
'experimental': true
options template_dirs: [new File(templateDir, 'templates/slim').absolutePath]
dependsOn download
}
task publish(type: GradleBuild) {
buildFile = 'publish.gradle'
tasks = ['publishGhages']
System.setProperty('jna.nosys', "true")
}
task configureChalkboard << {
File indexFile = file("$buildDir/asciidoc/revealjs/index.html")
def init = indexFile.text
def pattern = /(?ms)Reveal\.initialize\((\{.*\})\);<\\/script>/
def json = (init =~ pattern)[0][1]
json = json.readLines().collect { line ->
switch (line) {
case { it.trim() == '{' }:
return """{
chalkboard: {
src: null,
readOnly: false,
toggleChalkboardButton: { left: "30px", bottom: "30px", top: "auto", right: "auto" },
toggleNotesButton: { left: "60px", bottom: "30px", top: "auto", right: "auto" },
transition: 0,
theme: "chalkboard",
// configuration options for notes canvas and chalkboard
color: [ 'rgba(255,136,0,0.5)', 'rgba(255,136,0,0.5)' ],
background: [ 'rgba(127,127,127,0.1)' , 'rgba(127,127,127,0.1)' ],
pen: [ 'url(reveal.js/plugin/chalkboard/img/boardmarker.png), auto', 'url(reveal.js/plugin/chalkboard/img/chalk.png), auto' ],
},"""
case { it.trim() == 'dependencies: [' }:
return line + '\n' + "{ src: 'reveal.js/plugin/chalkboard/chalkboard.js' },"
case { it.trim() == 'keyboard: true,' }:
return """\
keyboard: {
67: function() { RevealChalkboard.toggleNotesCanvas() }, // toggle notes canvas when 'c' is pressed
66: function() { RevealChalkboard.toggleChalkboard() }, // toggle chalkboard when 'b' is pressed
46: function() { RevealChalkboard.clear() }, // clear chalkboard when 'DEL' is pressed
8: function() { RevealChalkboard.reset() }, // reset chalkboard data on current slide when 'BACKSPACE' is pressed
68: function() { RevealChalkboard.download() }, // downlad recorded chalkboard drawing when 'd' is pressed
},"""
default:
return line
}
}
indexFile.text = init.replaceAll(pattern, """Reveal.initialize(${json.join('\n')});</script></body></html>
""")
}
task toPdf << {
/*
final TYPES = [
"css" : "text/css",
"gif" : "image/gif",
"html": "text/html",
"jpg" : "image/jpeg",
"js" : "application/javascript",
"png" : "image/png",
"svg" : "image/svg+xml",
]
def port = 18181
def root = "build/asciidoc/revealjs"
def server = HttpServer.create(new InetSocketAddress(port), 0)
server.createContext("/", { HttpExchange exchange ->
println "-"*20
try {
if (!"GET".equalsIgnoreCase(exchange.requestMethod)) {
exchange.sendResponseHeaders(405, 0)
exchange.responseBody.close()
return
}
def path = exchange.requestURI.path
println "GET $path"
def file = new File(root, path.substring(1))
if (file.isDirectory()) {
file = new File(file, "index.html")
}
if (file.exists()) {
exchange.responseHeaders.set("Content-Type", TYPES[file.name.split(/\./)[-1]] ?: "text/plain")
exchange.sendResponseHeaders(200, 0)
file.withInputStream {
exchange.responseBody << it
}
exchange.responseBody.close()
} else {
exchange.sendResponseHeaders(404, 0)
exchange.responseBody.close()
}
} catch (e) {
e.printStackTrace()
}
} as HttpHandler)
server.start()
println "started simple web server on port ${port}"
*/
def cmd = "docker run --rm --net=host -v $project.buildDir/asciidoc/revealjs:/pwd astefanutti/decktape reveal /pwd/index.html /pwd/${project.name}.pdf"
Process proc = cmd.execute()
println "exporting to pdf ..."
proc.waitForProcessOutput(System.out, System.err)
proc.waitFor()
println "... finished"
// server.stop(0)
// println "stopped simple web server on port ${port}"
}
asciidoctor.finalizedBy configureChalkboard