Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / scripts / setup / BuildTXMHTMLDoc.groovy @ 1681

History | View | Annotate | Download (1.7 kB)

1
package org.txm.scripts.setup
2

    
3
import java.io.File;
4

    
5
import org.txm.macro.txt.SearchReplaceInDirectoryMacro;
6
import org.txm.utils.io.FileCopy;
7

    
8
String home = System.getProperty("user.home")
9
String svnpath = "SVN/TXMSVN/trunk/doc/user manuals"
10

    
11
File svnDir = new File(home, svnpath)
12
File svnImagesDir = new File(svnDir, "ImagesTXM")
13
//File odtFile = new File(home, "SVN/TXMSVN/trunk/doc/user manuals/Manuel de TXM 0.7 FR.odt")
14
File htmlDir = new File(svnDir, "txm-manual-fr.html")
15

    
16
//if (!htmlDir.listFiles()) {
17
//        println "Error: you must empty $htmlDir before. Aborting."
18
//        return;
19
//}
20

    
21
if (!svnDir.exists()) {
22
        println "Error: Cannot find SVN files $svnDir. Aborting"
23
        return
24
}
25

    
26
//// Update SVN // marche pas :(
27
//String cmd = "svn update \"$svnDir\""
28
//println "SVN update: "+cmd
29
//def proc = cmd.execute()
30
//proc.in.getText()
31
//proc.waitFor()
32
//if (proc.exitValue() != 0) {
33
//        println "SVN update error code: "+proc.exitValue()
34
//        println "Error: "+proc.err.getText()
35
//        return;
36
//} 
37

    
38
// Copy images
39
//File htmlImagesDir = new File(htmlDir, svnImagesDir.getName())
40
//FileCopy.copyFiles(svnImagesDir, htmlImagesDir)
41
//if (!htmlImagesDir.exists()) {
42
//        println "Failed to copy $htmlImagesDir"
43
//        return
44
//}
45

    
46
// Fix HTML files
47
// fix images source directory - remove SVN absolute path
48
svnpath = svnpath.replaceAll(" ", "%20")
49
def changes = [
50
        [/ src="\.\.\/\.\.\/$svnpath\//, ' src="'],
51
        [/"ImagesTXM/,        '"../ImagesTXM'],
52
        [/<style media="all" type="text\/css">/, '<link rel="stylesheet" type="text/css" href="style.css"/>\n<style media="all" type="text/css">']
53
]
54

    
55
for (def change : changes) {
56
        println change
57
        new SearchReplaceInDirectoryMacro().process(htmlDir, "\\.xhtml", "UTF-8",
58
                change[0], 
59
                change[1], false)
60
}