Révision 1063
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/fileexplorer/MacroExplorer.java (revision 1063) | ||
---|---|---|
80 | 80 |
|
81 | 81 |
/** The home. */ |
82 | 82 |
protected static String home = Toolbox.getTxmHomePath(); |
83 |
protected static String homeUser = Toolbox.getTxmHomePath(); |
|
83 |
//protected static String homeUser = Toolbox.getTxmHomePath();
|
|
84 | 84 |
|
85 | 85 |
protected static File currentRootDir; |
86 | 86 |
|
87 |
protected static File currentUserRootDir; |
|
87 |
//protected static File currentUserRootDir;
|
|
88 | 88 |
|
89 | 89 |
protected static boolean showAll = false; |
90 | 90 |
|
... | ... | |
105 | 105 |
home = Toolbox.getTxmHomePath(); |
106 | 106 |
if (home == null) home = System.getProperty("user.home"); //$NON-NLS-1$ |
107 | 107 |
|
108 |
File scriptsUserDir = new File(home, "scripts/groovy/user/"); //$NON-NLS-1$ |
|
109 |
File scriptsDir = new File(home, "scripts/groovy/system/"); //$NON-NLS-1$
|
|
108 |
//File scriptsUserDir = new File(home, "scripts/groovy/user/"); //$NON-NLS-1$
|
|
109 |
File scriptsDir = new File(home, "scripts/groovy/user/"); //$NON-NLS-1$
|
|
110 | 110 |
currentRootDir = new File(scriptsDir, "org/txm/macro"); //$NON-NLS-1$ |
111 |
currentUserRootDir = new File(scriptsUserDir, "org/txm/macro"); //$NON-NLS-1$ |
|
111 |
//currentUserRootDir = new File(scriptsUserDir, "org/txm/macro"); //$NON-NLS-1$
|
|
112 | 112 |
home = currentRootDir.getAbsolutePath(); |
113 |
homeUser = currentUserRootDir.getAbsolutePath(); |
|
113 |
//homeUser = currentUserRootDir.getAbsolutePath();
|
|
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
public String getHome() { return home;} |
117 |
public String getUserHome() { return homeUser;} |
|
117 |
//public String getUserHome() { return homeUser;}
|
|
118 | 118 |
|
119 | 119 |
/** |
120 | 120 |
* Refresh. |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyScript.java (revision 1063) | ||
---|---|---|
213 | 213 |
String dir = currentRootDir.getAbsolutePath(); |
214 | 214 |
String path = scriptfile.getAbsolutePath(); |
215 | 215 |
if (!path.startsWith(dir)) { |
216 |
System.out.println(TXMUIMessages.bind(TXMUIMessages.ExecuteGroovyScriptFromFile_2, dir)); |
|
216 |
System.out.println(TXMUIMessages.bind(TXMUIMessages.ExecuteGroovyScriptFromFile_2, dir, path));
|
|
217 | 217 |
return; |
218 | 218 |
} |
219 | 219 |
final String relativepath = path.substring(dir.length()+1); |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages.properties (revision 1063) | ||
---|---|---|
293 | 293 |
|
294 | 294 |
Error_creating_partition = Error while creating a partition: {0} |
295 | 295 |
|
296 |
ExecuteGroovyScriptFromFile_2 = The groovy script must be in the folder: {0}
|
|
296 |
ExecuteGroovyScriptFromFile_2 = The {1} Groovy script must be in the {0} folder.
|
|
297 | 297 |
|
298 | 298 |
ExecuteGroovyScript_0 = \ ms |
299 | 299 |
ExecuteGroovyScript_1 = Error during parameters initialisation |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages_ru.properties (revision 1063) | ||
---|---|---|
226 | 226 |
|
227 | 227 |
Error_creating_partition = ** Ошибка во время создания распределения: {0} |
228 | 228 |
|
229 |
ExecuteGroovyScriptFromFile_2 = Скрипт Groovy должен находиться в папке |
|
229 |
ExecuteGroovyScriptFromFile_2 = Скрипт Groovy должен находиться в папке {0} {1}
|
|
230 | 230 |
|
231 | 231 |
ExecuteGroovyScript_0 = \ мс |
232 | 232 |
ExecuteGroovyScript_1 = N/A_Error during parameters initialisation |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages_fr.properties (revision 1063) | ||
---|---|---|
262 | 262 |
|
263 | 263 |
Error_creating_partition = ** Erreur lors de la création de la partition : {0} |
264 | 264 |
|
265 |
ExecuteGroovyScriptFromFile_2 = Le script Groovy doit être dans le dossier {0} |
|
265 |
ExecuteGroovyScriptFromFile_2 = Le script Groovy {1} doit être dans le dossier {0}
|
|
266 | 266 |
|
267 | 267 |
ExecuteGroovyScript_0 = \ ms |
268 | 268 |
ExecuteGroovyScript_1 = Erreur lors de l'initialisation des paramètres |
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java (revision 1063) | ||
---|---|---|
54 | 54 |
public int compare(IConfigurationElement o1, IConfigurationElement o2) { |
55 | 55 |
return o1.getAttribute("position").compareTo(o2.getAttribute("position")); |
56 | 56 |
} |
57 |
|
|
58 | 57 |
}); |
59 |
Log.warning("Installing ConcordanceEditorExtension...");
|
|
58 |
Log.warning("Installing AnnotationExtension...");
|
|
60 | 59 |
Log.warning(Arrays.toString(config)); |
61 | 60 |
|
62 | 61 |
System.out.println("Installing annotation modes... "); |
tmp/org.txm.tigersearch.rcp/groovy/org/txm/scripts/importer/tigersearch/TSImport.groovy (revision 1063) | ||
---|---|---|
26 | 26 |
public void init(BaseParameters p) { |
27 | 27 |
super.init(p); |
28 | 28 |
|
29 |
importer = new TSImporter(this); // only to build metadata
|
|
29 |
importer = new TSImporter(this); // select TIGER XML files then do XTZImporter step
|
|
30 | 30 |
compiler = new XTZCompiler(this) |
31 | 31 |
annotater = null; // no annotater step to do |
32 | 32 |
pager = new XTZPager(this) |
... | ... | |
37 | 37 |
*/ |
38 | 38 |
@Override |
39 | 39 |
public void start() throws InterruptedException { |
40 |
File tigerSrcDir = sourceDirectory |
|
41 |
|
|
42 |
def xmlFiles = [] |
|
43 |
sourceDirectory.listFiles(new FileFilter() { |
|
44 |
boolean accept(File file) { |
|
45 |
if (file.isDirectory()) return false; |
|
46 |
if (file.isHidden()) return false; |
|
47 |
if (file.getName().equals("import.xml")) return false; |
|
48 |
if (!file.getName().endsWith(".xml")) return false; |
|
49 |
|
|
50 |
xmlFiles << file |
|
51 |
} |
|
52 |
}); |
|
53 |
|
|
54 |
xmlFiles.remove(new File(sourceDirectory, "import.xml")) |
|
55 |
|
|
56 |
if (xmlFiles.size() == 0) { |
|
57 |
println "Error no XML file found in $sourceDirectory" |
|
58 |
isSuccessful = false; |
|
59 |
return; |
|
60 |
} |
|
61 |
|
|
62 |
File master = xmlFiles[0]; |
|
63 |
println "Main TIGER XML file found: $master" |
|
64 |
|
|
65 |
File tsXSLFile = new File(Toolbox.getTxmHomePath(), "xsl/ts.xsl"); |
|
66 |
BundleUtils.copyFiles("org.txm.tigersearch.rcp", "groovy", "org/txm/scripts/importer/tigersearch", "ts.xsl", tsXSLFile.getParentFile()); |
|
67 |
|
|
68 |
File xmltxmSrcDir = new File(binaryDirectory, "src"); // output directory of the TS XSL transformation |
|
69 |
xmltxmSrcDir.mkdirs(); |
|
70 |
FileCopy.copy(master, new File(xmltxmSrcDir, master.getName())); |
|
71 |
|
|
72 |
if (!ApplyXsl2.processImportSources(tsXSLFile, xmltxmSrcDir, xmltxmSrcDir)) { |
|
73 |
println "Error while applying TS XSL file to $tigerSrcDir" |
|
74 |
isSuccessful = false; |
|
75 |
return; |
|
76 |
} |
|
77 |
|
|
78 |
File[] files = xmltxmSrcDir.listFiles(); |
|
79 |
if (files == null || files.length == 0) { |
|
80 |
println "Error while applying TS XSL file to $xmltxmSrcDir is empty" |
|
81 |
isSuccessful = false; |
|
82 |
return; |
|
83 |
} |
|
84 |
|
|
85 |
sourceDirectory = xmltxmSrcDir; // hop |
|
86 |
File txmDir = new File(binaryDirectory, "txm/"+corpusName); |
|
87 |
txmDir.mkdirs(); |
|
88 |
FileCopy.copyFiles(sourceDirectory, txmDir) // the compiler step will use these files |
|
89 |
|
|
40 |
|
|
90 | 41 |
super.start(); // call the usual XTZ import |
91 |
|
|
42 |
|
|
92 | 43 |
if (isSuccessful) { |
93 | 44 |
|
94 |
File tigerDir = new File(binaryDirectory, "tiger"); |
|
45 |
File tigerDir = new File(this.binaryDirectory, "tiger");
|
|
95 | 46 |
tigerDir.mkdir(); |
96 | 47 |
|
97 | 48 |
File logprop = new File(tigerDir, "tigersearch.logprop"); |
... | ... | |
107 | 58 |
log4j.appender.Logfile.layout=org.apache.log4j.PatternLayout |
108 | 59 |
log4j.appender.Logfile.layout.ConversionPattern=%5r %-5p [%t] %c{2} - %m%n""") |
109 | 60 |
} |
110 |
|
|
61 |
|
|
111 | 62 |
BasicConfigurator.configure(); |
112 |
String uri = master.getAbsolutePath(); |
|
63 |
File master = new File(this.sourceDirectory, "main.xml"); |
|
64 |
if (!master.exists()) { |
|
65 |
def xmlFiles = sourceDirectory.listFiles(new FileFilter() { |
|
66 |
boolean accept(File file) { |
|
67 |
if (file.isDirectory()) return false; |
|
68 |
if (file.isHidden()) return false; |
|
69 |
String filename = file.getName() |
|
70 |
if (filename.equals("import.xml")) return false; |
|
71 |
if (!filename.endsWith(".xml")) return false; |
|
72 |
|
|
73 |
return true; |
|
74 |
} |
|
75 |
}); |
|
76 |
|
|
77 |
master = xmlFiles[0] |
|
78 |
} |
|
79 |
String uri = master.getAbsolutePath(); // TIGER corpus source root file |
|
113 | 80 |
File tigerBinDir = new File(tigerDir, corpusName) |
114 | 81 |
tigerBinDir.mkdir() |
115 | 82 |
try { |
tmp/org.txm.tigersearch.rcp/groovy/org/txm/scripts/importer/tigersearch/TSImporter.groovy (revision 1063) | ||
---|---|---|
6 | 6 |
import org.txm.utils.io.FileCopy |
7 | 7 |
import org.txm.importer.xtz.* |
8 | 8 |
import org.txm.scripts.importer.xtz.* |
9 |
import org.txm.importer.ApplyXsl2; |
|
10 |
|
|
9 | 11 |
/** |
10 | 12 |
* Only build the Metadatas object since all XML-TXM files already exists. |
11 | 13 |
* Metadatas is used to build text order. |
... | ... | |
19 | 21 |
public TSImporter(ImportModule module) { |
20 | 22 |
super(module); |
21 | 23 |
} |
22 |
|
|
24 |
|
|
23 | 25 |
@Override |
24 | 26 |
public void process() { |
25 |
File binDir = module.getBinaryDirectory(); |
|
26 | 27 |
|
27 | 28 |
//prepare metadata if any |
28 | 29 |
File allMetadataFile = Metadatas.findMetadataFile(inputDirectory); |
29 |
println allMetadataFile |
|
30 | 30 |
if (allMetadataFile.exists()) { |
31 |
File copy = new File(binDir, allMetadataFile.getName())
|
|
31 |
File copy = new File(module.getBinaryDirectory(), allMetadataFile.getName())
|
|
32 | 32 |
if (!FileCopy.copy(allMetadataFile, copy)) { |
33 | 33 |
println "Error: could not create a copy of the metadata file "+allMetadataFile.getAbsoluteFile(); |
34 | 34 |
return; |
35 | 35 |
} |
36 |
this.metadata = new Metadatas(copy,
|
|
37 |
Toolbox.getPreference(Toolbox.METADATA_ENCODING),
|
|
38 |
Toolbox.getPreference(Toolbox.METADATA_COLSEPARATOR),
|
|
39 |
Toolbox.getPreference(Toolbox.METADATA_TXTSEPARATOR), 1)
|
|
36 |
metadata = new Metadatas(copy, |
|
37 |
Toolbox.getPreference(TBXPreferences.METADATA_ENCODING),
|
|
38 |
Toolbox.getPreference(TBXPreferences.METADATA_COLSEPARATOR),
|
|
39 |
Toolbox.getPreference(TBXPreferences.METADATA_TXTSEPARATOR), 1)
|
|
40 | 40 |
} |
41 |
isSuccessFul = true; |
|
41 |
|
|
42 |
|
|
43 |
File sourceDirectory = inputDirectory |
|
44 |
File binaryDirectory = module.getBinaryDirectory() |
|
45 |
|
|
46 |
File master = new File(sourceDirectory, "main.xml") |
|
47 |
|
|
48 |
def xmlFiles = [] // the TIGER XML files |
|
49 |
|
|
50 |
if (!master.exists() ) { |
|
51 |
// master = new File(sourceDirectory, "main.xml") |
|
52 |
// String subcorpora = ""; |
|
53 |
xmlFiles = sourceDirectory.listFiles(new FileFilter() { |
|
54 |
boolean accept(File file) { |
|
55 |
if (file.isDirectory()) return false; |
|
56 |
if (file.isHidden()) return false; |
|
57 |
String filename = file.getName() |
|
58 |
if (filename.equals("import.xml")) return false; |
|
59 |
if (!filename.endsWith(".xml")) return false; |
|
60 |
|
|
61 |
return true; |
|
62 |
} |
|
63 |
}); |
|
64 |
|
|
65 |
if (xmlFiles.size() > 1) { |
|
66 |
println "Error, the source directory contains more than one TIGER XML file ?" |
|
67 |
isSuccessful = false; |
|
68 |
return; |
|
69 |
} |
|
70 |
if (xmlFiles.size() == 0) { |
|
71 |
println "Error no XML file found in $sourceDirectory directory" |
|
72 |
isSuccessful = false; |
|
73 |
return; |
|
74 |
} |
|
75 |
println "No TIGER XML 'main.xml' file found. Using $xmlFiles as TIGER XML source file " |
|
76 |
|
|
77 |
} else { // parse the master file |
|
78 |
for (def s : new XmlSlurper().parse(master).body.subcorpus) { |
|
79 |
String name = ""+s.@external |
|
80 |
if (name.startsWith("file:")) { |
|
81 |
xmlFiles << new File(sourceDirectory, name.substring(5)) |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
if (xmlFiles.size() == 0) { |
|
86 |
println "Error no XML file found in $master file" |
|
87 |
isSuccessful = false; |
|
88 |
return; |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
// get the last version of the TIGER XML -> XML-TXM XSL |
|
93 |
File tsXSLFile = new File(Toolbox.getTxmHomePath(), "xsl/ts.xsl"); |
|
94 |
BundleUtils.copyFiles("org.txm.tigersearch.rcp", "groovy", "org/txm/scripts/importer/tigersearch", "ts.xsl", tsXSLFile.getParentFile()); |
|
95 |
|
|
96 |
File xmltxmSrcDir = new File(binaryDirectory, "src"); // output directory of the TS XSL transformation |
|
97 |
xmltxmSrcDir.mkdirs(); |
|
98 |
println "Main.xml files: "+xmlFiles |
|
99 |
println "N="+xmlFiles.size() |
|
100 |
for (File xmlTigerFile : xmlFiles) { |
|
101 |
FileCopy.copy(xmlTigerFile, new File(xmltxmSrcDir, xmlTigerFile.getName())); |
|
102 |
} |
|
103 |
|
|
104 |
File tokenizedDir = new File(module.getBinaryDirectory(),"tokenized"); |
|
105 |
|
|
106 |
if (!ApplyXsl2.processImportSources(tsXSLFile, xmltxmSrcDir, tokenizedDir)) { |
|
107 |
println "Error while applying TS XSL file to $xmltxmSrcDir" |
|
108 |
isSuccessful = false; |
|
109 |
return; |
|
110 |
} |
|
111 |
|
|
112 |
File[] files = tokenizedDir.listFiles(); |
|
113 |
if (files == null || files.length == 0) { |
|
114 |
println "Error while applying TS XSL file to $xmltxmSrcDir is empty" |
|
115 |
isSuccessful = false; |
|
116 |
return; |
|
117 |
} |
|
118 |
|
|
119 |
if (!doToXMLTXMStep()) return; |
|
120 |
if (!doInjectMetadataStep()) return; |
|
121 |
|
|
122 |
File txmdDir = new File(module.getBinaryDirectory(),"txm"); |
|
123 |
isSuccessFul = txmdDir.listFiles().size() > 0 |
|
42 | 124 |
} |
43 | 125 |
} |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZPager.groovy (revision 1063) | ||
---|---|---|
43 | 43 |
|
44 | 44 |
public void process(ArrayList<File> files) { |
45 | 45 |
super.process(files); |
46 |
|
|
46 |
|
|
47 | 47 |
if (files == null) { |
48 | 48 |
files = inputDirectory.listFiles(); |
49 | 49 |
if (files != null) Collections.sort(files); |
50 | 50 |
} |
51 |
|
|
51 |
|
|
52 | 52 |
if (!doDefaultEditionStep()) return; |
53 | 53 |
if (!doFacsEditionStep()) return; |
54 | 54 |
if (!doPostEditionXSLStep()) return; |
... | ... | |
58 | 58 |
} |
59 | 59 |
|
60 | 60 |
public boolean doDefaultEditionStep() { |
61 |
|
|
61 |
|
|
62 | 62 |
boolean build_edition = module.getParameters().getDoEdition("default") |
63 | 63 |
if (!build_edition) { |
64 | 64 |
return true; |
65 | 65 |
} |
66 |
|
|
66 |
|
|
67 | 67 |
def second = 0 |
68 | 68 |
|
69 | 69 |
println "-- Building 'default' edition of ${files.size()} texts..." |
... | ... | |
79 | 79 |
css << "css/"+cssFile.getName(); |
80 | 80 |
} |
81 | 81 |
} |
82 |
|
|
82 | 83 |
ConsoleProgressBar cpb = new ConsoleProgressBar(files.size()) |
83 | 84 |
for (File txmFile : files) { |
84 |
cpb.tick() |
|
85 |
String textname = txmFile.getName(); |
|
86 |
int i = textname.lastIndexOf("."); |
|
87 |
if (i > 0) textname = textname.substring(0, i); |
|
85 |
try { |
|
86 |
cpb.tick() |
|
87 |
String textname = txmFile.getName(); |
|
88 |
int i = textname.lastIndexOf("."); |
|
89 |
if (i > 0) textname = textname.substring(0, i); |
|
88 | 90 |
|
89 |
File firstHTMLPageFile = new File(outputDirectory, textname+"_1.html"); |
|
90 |
if (firstHTMLPageFile.exists() && firstHTMLPageFile.lastModified() >= txmFile.lastModified()) continue; |
|
91 |
File firstHTMLPageFile = new File(outputDirectory, textname+"_1.html");
|
|
92 |
if (firstHTMLPageFile.exists() && firstHTMLPageFile.lastModified() >= txmFile.lastModified()) continue;
|
|
91 | 93 |
|
92 |
List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang); |
|
93 |
List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang); |
|
94 |
List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang);
|
|
95 |
List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang);
|
|
94 | 96 |
|
95 |
Element texts = params.getTextsElement(corpusElem); |
|
96 |
Element text = params.getTextElement(texts, textname); |
|
97 |
if (text == null) { // just in case |
|
98 |
text = params.addText(corpusElem, textname, txmFile) |
|
99 |
} |
|
100 |
def ed = new XTZDefaultPagerStep(this, txmFile, textname, NoSpaceBefore, NoSpaceAfter, css); |
|
101 |
Element edition = params.getEditionElement(text, "default"); |
|
102 |
if (edition == null) { |
|
103 |
edition = params.addEdition(text, "default", outputDirectory.getAbsolutePath(), "html"); |
|
104 |
} else { // remove existing pages if any |
|
105 |
def children = edition.getChildNodes(); |
|
106 |
while (children.getLength() > 0 ) { |
|
107 |
edition.removeChild(children.item(0)) |
|
97 |
Element texts = params.getTextsElement(corpusElem); |
|
98 |
Element text = params.getTextElement(texts, textname); |
|
99 |
if (text == null) { // just in case |
|
100 |
text = params.addText(corpusElem, textname, txmFile) |
|
108 | 101 |
} |
109 |
} |
|
102 |
def ed = new XTZDefaultPagerStep(this, txmFile, textname, NoSpaceBefore, NoSpaceAfter, css); |
|
103 |
if (!ed.process()) { |
|
104 |
println "Fail to build 'default' edition for text: $txmFile" |
|
105 |
continue; |
|
106 |
} |
|
107 |
Element edition = params.getEditionElement(text, "default"); |
|
108 |
if (edition == null) { |
|
109 |
edition = params.addEdition(text, "default", outputDirectory.getAbsolutePath(), "html"); |
|
110 |
} else { // remove existing pages if any |
|
111 |
def children = edition.getChildNodes(); |
|
112 |
while (children.getLength() > 0 ) { |
|
113 |
edition.removeChild(children.item(0)) |
|
114 |
} |
|
115 |
} |
|
110 | 116 |
|
111 |
for (i = 0 ; i < ed.getPageFiles().size();) { |
|
112 |
File f = ed.getPageFiles().get(i); |
|
113 |
String wordid = ed.getIdx().get(i); |
|
114 |
params.addPage(edition, ""+(++i), wordid); |
|
117 |
for (i = 0 ; i < ed.getPageFiles().size();) { |
|
118 |
File f = ed.getPageFiles().get(i); |
|
119 |
String wordid = ed.getIdx().get(i); |
|
120 |
params.addPage(edition, ""+(++i), wordid); |
|
121 |
} |
|
122 |
} catch(Exception e) { |
|
123 |
println "Error: could not create $txmFile 'default' edition: "+e |
|
115 | 124 |
} |
116 | 125 |
} |
117 |
|
|
126 |
|
|
118 | 127 |
// copy default TXM css file in the "facs" edition directory |
119 | 128 |
File csshtmlDirectory = new File(outputDirectory, "css") |
120 | 129 |
csshtmlDirectory.mkdirs() |
121 | 130 |
BundleUtils.copyFiles("org.txm.core", "res", "org/txm/css", "txm.css", csshtmlDirectory); |
122 |
|
|
131 |
|
|
123 | 132 |
// copy CSS files in the "default" edition directory |
124 | 133 |
if (cssDirectory.exists()) { |
125 | 134 |
FileCopy.copyFiles(cssDirectory, csshtmlDirectory) |
... | ... | |
142 | 151 |
|
143 | 152 |
boolean mustBuildFacsEdition = module.getParameters().getDoFacsEdition(); |
144 | 153 |
if (!mustBuildFacsEdition) return true; |
145 |
|
|
154 |
|
|
146 | 155 |
String imageDirectoryPath = module.getParameters().getFacsEditionImageDirectory().trim(); |
147 | 156 |
File imageDirectory = new File(imageDirectoryPath); |
148 | 157 |
if (!imageDirectoryPath.startsWith("http") && imageDirectoryPath.length()== 0 && !imageDirectory.exists() && !imageDirectory.isDirectory()) { |
... | ... | |
193 | 202 |
try { |
194 | 203 |
def ed = new XTZFacsPagerStep(txmFile, newEditionDirectory, imageDirectory, txtname, corpusname, "pb", "facs", wordTag, debug); |
195 | 204 |
if (!ed.process()) { |
196 |
println "Fail to build edition for text: $txmFile" |
|
205 |
println "Fail to build 'facs' edition for text: $txmFile"
|
|
197 | 206 |
continue; |
198 | 207 |
} |
199 | 208 |
|
200 |
|
|
209 |
|
|
201 | 210 |
def pages = ed.getPageFiles() |
202 | 211 |
for (i = 0 ; i < pages.size();) { |
203 | 212 |
File f = pages[i][0]; |
204 | 213 |
String wordid = pages[i][1] |
205 | 214 |
//TODO replace '""+(++i)' with something that fetch/findout the page 'name' |
206 |
// TODO or move the Edition and Page corpus declaration in the XTZDefaultPagerStep
|
|
215 |
// TODO or move the Edition and Page corpus declaration in the XTZDefaultPagerStep |
|
207 | 216 |
params.addPage(edition, ""+(++i), wordid); |
208 | 217 |
//println "add facs page: $f $wordid" |
209 | 218 |
} |
... | ... | |
219 | 228 |
editionImagesDirectory.mkdirs(); |
220 | 229 |
FileCopy.copyFiles(imageDirectory, editionImagesDirectory); |
221 | 230 |
} |
222 |
|
|
231 |
|
|
223 | 232 |
// copy SimpleViewer files in the "facs" edition directory |
224 | 233 |
File jshtmlDirectory = new File(newEditionDirectory, "js") |
225 | 234 |
jshtmlDirectory.mkdirs() |
226 | 235 |
BundleUtils.copyFiles("org.txm.core", "res", "org/txm/js", "viewer", jshtmlDirectory); |
227 | 236 |
BundleUtils.copyFiles("org.txm.core", "res", "org/txm/", "images", newEditionDirectory); |
228 |
|
|
237 |
|
|
229 | 238 |
// copy default TXM css file in the "facs" edition directory |
230 | 239 |
File csshtmlDirectory = new File(newEditionDirectory, "css") |
231 | 240 |
csshtmlDirectory.mkdirs() |
232 | 241 |
BundleUtils.copyFiles("org.txm.core", "res", "org/txm/css", "txm.css", csshtmlDirectory); |
233 |
|
|
242 |
|
|
234 | 243 |
// copy CSS/JS/Images sources files in the "facs" edition directory |
235 | 244 |
if (cssDirectory.exists()) { |
236 | 245 |
FileCopy.copyFiles(cssDirectory, csshtmlDirectory) |
... | ... | |
242 | 251 |
File imageshtmlDirectory = new File(newEditionDirectory, "images") |
243 | 252 |
FileCopy.copyFiles(imagesDirectory, imageshtmlDirectory) |
244 | 253 |
} |
245 |
|
|
254 |
|
|
246 | 255 |
Element editionsElement = params.getEditionsElement(corpusElem); |
247 | 256 |
editionsElement.setAttribute("default","default,facs"); |
248 | 257 |
|
... | ... | |
264 | 273 |
String s = module.getParameters().getWordsPerPage("default"); |
265 | 274 |
if (s != null && s.length() > 0) |
266 | 275 |
|
267 |
// shared XSL parameters |
|
268 |
xslParams["number-words-per-page"] = Integer.parseInt(s); |
|
276 |
// shared XSL parameters
|
|
277 |
xslParams["number-words-per-page"] = Integer.parseInt(s);
|
|
269 | 278 |
xslParams["pagination-element"] = module.getParameters().getPageElement("default") |
270 | 279 |
xslParams["import-xml-path"] = module.getParameters().paramFile.toURI().toString() |
271 | 280 |
//println "XSL PARAMS: "+xslParams |
... | ... | |
276 | 285 |
for (File xslFile : xslFiles) { |
277 | 286 |
if (xslFile.isDirectory() || xslFile.isHidden() || !xslFile.getName().endsWith(".xsl")) continue; |
278 | 287 |
if (!xslFile.getName().matches("[1-9]-.+")) continue; |
279 |
|
|
288 |
|
|
280 | 289 |
String xslName = xslFile.getName().substring(2); // remove the "1-", "2-", etc. |
281 | 290 |
int idx2 = xslName.indexOf(".") |
282 | 291 |
if (idx2 > 0) xslName = xslName.substring(0, idx2) |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZDefaultPagerStep.groovy (revision 1063) | ||
---|---|---|
129 | 129 |
String elems = pager.getImportModule().getParameters().getOutSideTextTagsAndKeepContentElement().getTextContent() |
130 | 130 |
if (elems != null) for (def s : elems.split(",")) outOfTextElements << s; |
131 | 131 |
|
132 |
process(); |
|
132 |
//process();
|
|
133 | 133 |
} |
134 | 134 |
|
135 | 135 |
public String getAttributeValue(def parser, String ns, String name) { |
... | ... | |
396 | 396 |
|
397 | 397 |
break; |
398 | 398 |
case "p": |
399 |
case "lg": |
|
399 |
//case "lg":
|
|
400 | 400 |
pagedWriter.write("\n"); |
401 | 401 |
pagedWriter.writeStartElement("p", ["class":rend]) |
402 | 402 |
break; |
403 | 403 |
case "lb": |
404 |
case "l": |
|
404 |
//case "l":
|
|
405 | 405 |
pagedWriter.writeEmptyElement("br", ["class":rend]) |
406 | 406 |
break; |
407 | 407 |
case wordTag: |
... | ... | |
432 | 432 |
flagNote = true; |
433 | 433 |
noteContent = "" |
434 | 434 |
} |
435 |
// else { |
|
436 |
// pagedWriter.writeStartElement("span", ["class":localname]) |
|
437 |
// } |
|
435 | 438 |
break; |
436 | 439 |
} |
437 | 440 |
break; |
... | ... | |
442 | 445 |
|
443 | 446 |
switch (localname) { |
444 | 447 |
case "p": |
445 |
case "lg": |
|
448 |
//case "lg":
|
|
446 | 449 |
pagedWriter.writeEndElement() // </p> |
447 | 450 |
pagedWriter.write("\n"); |
448 | 451 |
break; |
... | ... | |
517 | 520 |
pagedWriter.writeEndElement() // </sub> |
518 | 521 |
pagedWriter.writeEndElement() // </span> |
519 | 522 |
} |
520 |
} |
|
523 |
} |
|
524 |
// else { |
|
525 |
// pagedWriter.writeEndElement() // the element |
|
526 |
// } |
|
521 | 527 |
break; |
522 | 528 |
} |
523 | 529 |
break; |
... | ... | |
538 | 544 |
} |
539 | 545 |
closeMultiWriter(); |
540 | 546 |
} |
547 |
|
|
541 | 548 |
} |
Formats disponibles : Unified diff