-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex-webpage.groovy
More file actions
40 lines (33 loc) · 1.12 KB
/
index-webpage.groovy
File metadata and controls
40 lines (33 loc) · 1.12 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
// generate ListOfTimelines.json file, for hipo files in the online directory's subdirectories
import static groovy.io.FileType.FILES
import groovy.json.JsonOutput
if(args.length!=1) {
System.err.println """
USAGE: groovy ${this.class.getSimpleName()}.groovy [WEBSERVER_DIRECTORY]
"""
System.exit(101)
}
def wwwDirName = args[0]
def wwwDir = new File(wwwDirName)
def subDirs = []
wwwDir.traverse(type: groovy.io.FileType.DIRECTORIES, maxDepth: 0 ) {
subDirs << it.getName()
}
println "GENERATING INDEX PAGE FOR $wwwDirName"
subDirs.sort()
println "SUBDIRECTORIES:"
println subDirs
def fileTreeList = []
subDirs.each { subDirName ->
def timelineList = []
def fileTree = [:]
fileTree.put('subsystem', subDirName)
def subDir = new File("$wwwDirName/$subDirName")
subDir.traverse( type: groovy.io.FileType.FILES, nameFilter: ~/.*\.hipo/ ) {
timelineList << it.getName().replaceAll(/\.hipo$/,"")
}
fileTree.put('variables', timelineList)
fileTreeList << fileTree
}
//println JsonOutput.prettyPrint(JsonOutput.toJson(fileTreeList))
new File("$wwwDirName/ListOfTimelines.json").write(JsonOutput.toJson(fileTreeList))