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

BuildTXMHTMLDoc.groovy (revision 1681)
7 7

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

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

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

  
20 21
if (!svnDir.exists()) {
21 22
	println "Error: Cannot find SVN files $svnDir. Aborting"
......
35 36
//} 
36 37

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

  
45 46
// Fix HTML files
46 47
// fix images source directory - remove SVN absolute path
47 48
svnpath = svnpath.replaceAll(" ", "%20")
48
new SearchReplaceInDirectoryMacro().process(htmlDir, "\\.xhtml", "UTF-8",
49
	 / src="\.\.\/\.\.\/$svnpath\//, 
50
	 ' src="', false)
51
// fix images source directory - remove "/" of some image paths
52
new SearchReplaceInDirectoryMacro().process(htmlDir, "\\.xhtml", "UTF-8",
53
	/\/ImagesTXM/,
54
	'ImagesTXM', false)
55
new SearchReplaceInDirectoryMacro().process(htmlDir, "\\.xhtml", "UTF-8",
56
	/<style media="all" type="text\/css">/, 
57
	'<link rel="stylesheet" type="text/css" href="style.css"/>\n<style media="all" type="text/css">', false)
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
}

Also available in: Unified diff