Revision 1681

tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/setup/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
}
tmp/org.txm.treetagger.core/src/org/txm/importer/xmltxm/Annotate.groovy (revision 1681)
444 444
			if (!(srcfile.delete() && temp.renameTo(srcfile)))
445 445
				println "Warning can't rename file "+temp+" to "+srcfile
446 446
		}
447
		
447 448
		println("")
448 449
		return true;
449 450
	}
tmp/org.txm.core/src/java/org/txm/importer/StaxIdentityParser.java (revision 1681)
127 127
		if (parser != null) {
128 128
			try {parser.close();} catch(Exception e){System.out.println("parser exep: "+e); return false;}
129 129
		}
130

  
130 131
		return ret;
131 132
	}
132 133

  
tmp/org.txm.core/src/java/org/txm/importer/scripts/xmltxm/AnnotationInjection.groovy (revision 1681)
1

  
2

  
1 3
// Copyright © 2010-2013 ENS de Lyon.
2 4
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3 5
// Lyon 2, University of Franche-Comté, University of Nice
......
32 34
import org.txm.importer.StaxIdentityParser
33 35
import org.txm.importer.filters.*
34 36
import org.txm.importer.PersonalNamespaceContext
35
// TODO: Auto-generated Javadoc
37
import java.io.File
38
import java.io.IOException
39

  
40
import javax.xml.stream.XMLStreamException
41

  
36 42
/**
37 43
 * The Class AnnotationInjection.
38 44
 *
......
213 219
			}
214 220
		}
215 221
	}
222
	
223
	public boolean process(File outfile) throws XMLStreamException, IOException
224
	{
225
		boolean ret = super.process(outfile);
226
		releaseLinkParsers();
227
	}
228
	
229
	/**
230
	 * Release the link parsers.
231
	 */
232
	private void releaseLinkParsers() {
233
		if (linkparsers == null) return;
234
		
235
		for (String l : linkparsers.keySet()) {
236
			XMLStreamReader p = linkparsers.get(l);
237
			if (p != null) {
238
				try {
239
					p.close();
240
				} catch(Exception e) {
241
					println "** Can not close $l link parser $p: $e"
242
				}
243
			}
244
		}
245
	}
216 246

  
217 247
	/**
218 248
	 * get the next tei:link value of a tei:LinkGrp.

Also available in: Unified diff