-
Notifications
You must be signed in to change notification settings - Fork 43
/
build.gradle
275 lines (243 loc) · 10.7 KB
/
build.gradle
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
import com.neo4j.gradle.zendesk.ZenDeskUploadTask
import org.asciidoctor.gradle.jvm.AsciidoctorTask
import org.yaml.snakeyaml.Yaml
buildscript {
dependencies {
classpath("org.yaml:snakeyaml:1.17")
}
}
plugins {
id 'org.asciidoctor.jvm.gems' version '3.3.2' apply false
id 'org.asciidoctor.jvm.convert' version '3.3.2' apply false
id "com.neo4j.gradle.zendesk.ZenDeskPlugin" version "0.3.0"
}
apply plugin: 'org.asciidoctor.jvm.gems'
repositories {
mavenCentral()
ruby {
gems()
}
}
dependencies {
asciidoctorGems 'rubygems:neo4j-asciidoctor-extensions:1.0.2'
}
zendesk {
email = project.hasProperty('zendesk-email') ? project.property('zendesk-email') : 'user@neo4j.com'
apiToken = project.hasProperty('zendesk-apitoken') ? project.property('zendesk-apitoken') : ''
}
def stage = project.findProperty('stage')
asciidoctorj {
jrubyVersion = '9.4.0.0'
version = '2.5.7'
//pdfVersion = '2.3.4'
requires "${rootProject.projectDir}/resources/extensions.rb"
attributes 'allow-uri-read': '',
'assets-cdn': 'https://s3.amazonaws.com/dev.assets.neo4j.com/kb-content',
'linkattrs': '',
'source-highlighter': 'codemirror',
'enterprise@': '', // publish on support.neo4j.com
'stage': stage != null ? stage : '',
'document-metadata-attrs-include': 'author,slug,zendesk-id,taxonomies*<>,zendesk_publishing_targets*<>'
}
// Set author tags
ext.setAuthorTags = { files, tags ->
for (file in files.getAsFileTree()) {
if (file.name.endsWith('.html')) {
File yamlFile = new File(file.parent, "${file.name.take(file.name.lastIndexOf('.'))}.yml")
InputStream input = new FileInputStream(yamlFile)
Yaml yaml = new Yaml()
Map<String, Object> data = (Map<String, Object>) yaml.load(input)
Map<String, Object> author = data["author"]
if (author != null) {
author["tags"] = tags
yamlFile.withWriter('utf-8') { writer ->
yaml.dump(data, writer)
}
}
}
}
}
ext.showTaxonomies = { files ->
List<String> developerTags = new ArrayList()
List<String> developerCategories = new ArrayList()
List<String> neo4jVersions = new ArrayList()
List<String> environments = new ArrayList<>()
for (file in files.getAsFileTree()) {
if (file.name.endsWith('.html')) {
File yamlFile = new File(file.parent, "${file.name.take(file.name.lastIndexOf('.'))}.yml")
InputStream input = new FileInputStream(yamlFile)
Yaml yaml = new Yaml()
Map<String, Object> data = (Map<String, Object>) yaml.load(input)
List<Map<String, Object>> taxonomies = data["taxonomies"]
Map<String, Object> developerTagsTaxonomy = taxonomies.find { taxonomy -> taxonomy["key"] == "developer_tag"}
if (developerTagsTaxonomy != null) {
developerTags.addAll(developerTagsTaxonomy["values"])
}
Map<String, Object> developerCategoriesTaxonomy = taxonomies.find { taxonomy -> taxonomy["key"] == "developer_category"}
if (developerCategoriesTaxonomy != null) {
developerCategories.addAll(developerCategoriesTaxonomy["values"])
}
Map<String, Object> neo4jVersionsTaxonomy = taxonomies.find { taxonomy -> taxonomy["key"] == "neo4j_version"}
if (neo4jVersionsTaxonomy != null) {
neo4jVersions.addAll(neo4jVersionsTaxonomy["values"])
}
Map<String, Object> environmentsTaxonomy = taxonomies.find { taxonomy -> taxonomy["key"] == "environment"}
if (environmentsTaxonomy != null) {
environments.addAll(environmentsTaxonomy["values"])
}
}
}
println("---\ndeveloper_tag\n" + developerTags.groupBy().collectEntries { [(it.key) : it.value.size()] }.sort { -it.value })
println("\n---\ndeveloper_category\n" + developerCategories.groupBy().collectEntries { [(it.key) : it.value.size()] }.sort { -it.value })
println("\n---\nneo4j_version\n" + neo4jVersions.groupBy().collectEntries { [(it.key) : it.value.size()] }.sort { -it.value })
println("\n---\nenvironment\n" + environments.groupBy().collectEntries { [(it.key) : it.value.size()] }.sort { -it.value })
}
ext.getTaxonomies = { taxonomyName, files ->
Set<String> values = new HashSet()
for (file in files.getAsFileTree()) {
if (file.name.endsWith('.html')) {
File yamlFile = new File(file.parent, "${file.name.take(file.name.lastIndexOf('.'))}.yml")
InputStream input = new FileInputStream(yamlFile)
Yaml yaml = new Yaml()
Map<String, Object> data = (Map<String, Object>) yaml.load(input)
List<Map<String, Object>> taxonomies = data["taxonomies"]
Map<String, Object> taxonomy = taxonomies.find { t -> t["key"] == taxonomyName}
if (taxonomy != null) {
values.addAll(taxonomy["values"])
}
}
}
return values.toList()
}
task convertHtml(type: AsciidoctorTask) {
dependsOn asciidoctorGemsPrepare
asciidoctorj {
options standalone: true
}
baseDir file("${projectDir}/articles/modules/ROOT/pages")
sourceDir file("${projectDir}/articles/modules/ROOT/pages")
sources {
excludes.addAll(['tags.adoc', 'categories.adoc', 'index.adoc'])
}
outputDir file("${projectDir}/build/html")
}
task showTaxonomies {
dependsOn convertHtml
doLast {
project.showTaxonomies(convertHtml.outputs.files)
}
}
task convertZenDeskHtml(type: AsciidoctorTask) {
dependsOn asciidoctorGemsPrepare
asciidoctorj {
options standalone: false,
template_dirs: ["${rootProject.projectDir}/_templates"]
}
baseDir file("${projectDir}/articles/modules/ROOT/pages")
sourceDir file("${projectDir}/articles/modules/ROOT/pages")
sources {
excludes.addAll(['tags.adoc', 'categories.adoc', 'index.adoc'])
}
outputDir file("${projectDir}/build/zendesk/html")
doLast {
// Add the "neo4jstaff" tag to authors
project.setAuthorTags(convertZenDeskHtml.outputs.files, ["neo4jstaff"])
}
}
task convert {
dependsOn convertZenDeskHtml
}
ext.getZenDeskArticles = { publishingTargetEnvironment, publishingTargetSection, files ->
List<String> paths = new ArrayList<String>()
for (file in files.getAsFileTree()) {
if (file.name.endsWith('.html')) {
File yamlFile = new File(file.parent, "${file.name.take(file.name.lastIndexOf('.'))}.yml")
InputStream input = new FileInputStream(yamlFile)
Yaml yaml = new Yaml()
Map<String, Object> data = (Map<String, Object>) yaml.load(input)
List<Map<String, Object>> publishingTargets = data["zendesk_publishing_targets"]
Map<String, Object> publishingTarget = publishingTargets.find { t -> t["key"] == publishingTargetEnvironment}
if (publishingTarget != null && publishingTarget["values"] != null && ((List<String>) publishingTarget["values"]).contains(publishingTargetSection)) {
paths.push(file.getAbsolutePath())
}
}
}
return paths
}
task zenDeskEnterpriseUpload(type: ZenDeskUploadTask) {
dependsOn convertZenDeskHtml
host = 'support.neo4j.com'
scheme = 'https'
source = convertZenDeskHtml.outputs.files
userSegmentId = 1716387
permissionGroupId = 136448
sectionId = 200574983
// notify subscribers when creating a new article (default: false)
// can be configured using the project property "notify" (for instance, via the "-P" command line option): "-Pnotify=true"
notifySubscribers = project.hasProperty('notify') ? project.property('notify') : false
}
task zenDeskAuraKnowledgeBaseUpload(type: ZenDeskUploadTask) {
dependsOn convertZenDeskHtml
doFirst {
def task = tasks.findByName('zenDeskAuraUpload')
if (task != null) {
task.configure {
source = project.getZenDeskArticles('aura', 'help-center/knowledge-base', convertZenDeskHtml.outputs.files)
}
}
}
host = 'aura.support.neo4j.com'
scheme = 'https'
userSegmentId = 1716387
permissionGroupId = 136408
sectionId = 360005376634
// notify subscribers when creating a new article (default: false)
// can be configured using the project property "notify" (for instance, via the "-P" command line option): "-Pnotify=true"
notifySubscribers = project.hasProperty('notify') ? project.property('notify') : false
}
task zenDeskTechSupportUpload(type: ZenDeskUploadTask) {
dependsOn convertZenDeskHtml
host = 'techsupport.neo4j.com'
scheme = 'https'
source = convertZenDeskHtml.outputs.files
userSegmentId = 4420374416909
permissionGroupId = 4420367189517
sectionId = 4422945149581
// notify subscribers when creating a new article (default: false)
// can be configured using the project property "notify" (for instance, via the "-P" command line option): "-Pnotify=true"
notifySubscribers = project.hasProperty('notify') ? project.property('notify') : false
}
// If you want to publish in other sections:
// - Copy and paste this task
// - Update the task title (for instance, `zenDeskAuraImportUpload`)
// - Update the second argument in `project.getZenDeskArticles('aura', 'home-page/getting-started', convertZenDeskHtml.outputs.files)`
// ** Set the same value in your article for the attribute `:aura:`. For instance, if the value is `home-page/import`,
// you should declare `:aura: home-page/import`.
// - Update the sectionId value (for the section "Home Page > Import" the value would be `360005850833`)
// - Add this new task in the `dependsOn` list on the `zenDeskAuraUpload` task
//
task zenDeskAuraGettingStartedUpload(type: ZenDeskUploadTask) {
dependsOn convertZenDeskHtml
doFirst {
def task = tasks.findByName('zenDeskAuraUpload')
if (task != null) {
task.configure {
source = project.getZenDeskArticles('aura', 'home-page/getting-started', convertZenDeskHtml.outputs.files)
}
}
}
host = 'aura.support.neo4j.com'
scheme = 'https'
userSegmentId = 1716387
permissionGroupId = 136408
sectionId = 360005850813
// notify subscribers when creating a new article (default: false)
// can be configured using the project property "notify" (for instance, via the "-P" command line option): "-Pnotify=true"
notifySubscribers = project.hasProperty('notify') ? project.property('notify') : false
}
task zenDeskAuraUpload {
dependsOn zenDeskAuraKnowledgeBaseUpload, zenDeskAuraGettingStartedUpload
}
task zenDeskUpload {
dependsOn zenDeskEnterpriseUpload, zenDeskAuraUpload
}