-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanifest.groovy
41 lines (40 loc) · 1.64 KB
/
manifest.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
new File("imsmanifest.xml").withWriter { writer ->
def lessons = new File("lessons.txt").readLines()
def xml = new groovy.xml.MarkupBuilder(writer)
def helper = new groovy.xml.MarkupBuilderHelper(xml)
helper.xmlDeclaration([version:'1.0', encoding:'UTF-8'])
def currentDir = new File('.')
xml.manifest(identifier:"bim-theory",schemaLocation:"http://www.imsglobal.org/xsd/imscp_v1p1 imscp_v1p1.xsd http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd"){
metadata() // TODO
organizations {
organization(identifier:"root",structure:"hierarchical"){
title("Building Information Modelling")
lessons.eachWithIndex { lessonTitle, lessonId ->
item(identifier:'0'+(lessonId+1)+'-00', identifierref:'r0'+(lessonId+1)+'-00', isvisible:'true'){
title( lessonTitle )
def chapterFiles = [] // use listFiles with Filefilter to sort
currentDir.eachFileMatch(~/lesson_0${lessonId+1}-\d\d.md/){ chapterFile -> chapterFiles << chapterFile }
chapterFiles.sort{ it.name }.each{ chapterFile ->
def chapterId = chapterFile.name[7..11]
if(chapterId[3..4]!='00') item(identifier:chapterId, identifierref:'r'+chapterId, isvisible:'true'){
title( chapterFile.withReader{ r -> r.readLine()[2..-1] } )
}
}
}}
}
}
resources {
def htmlFiles = []
currentDir.eachFileMatch(~/lesson_.*\.html/){ htmlFile ->
def htmlId = htmlFile.name[7..-6]
resource ( identifier: 'r'+ htmlId, type: 'webcontent', href: htmlFile.name){
file(href:htmlFile.name)
(new File("lesson_${htmlId}.md").text =~ /!\[.*\]\((.*)\)/).each{ full, match ->
file(href:match)
}
file(href:'styles.css')
}
}
}
}
}