* zimWiki to mediaWiki
*/
public SimpleArticle readData(String name, int properties)
throws ActionException, ProcessException {
File f = new File(getRootFolder(), name + ZIMEXT);
SimpleArticle sa = new SimpleArticle();
sa.setTitle(name);
StringBuffer text = new StringBuffer();
// create a file reader
try {
BufferedReader myInput = new BufferedReader(new FileReader(f));
String line = "";
String cont = "";
// if we are reading content, than
while ((line = myInput.readLine()) != null) {
// omit the headline
if (line.startsWith("====== " + name + " ======")) {
// store every line in 'text' and add a newline
while ((cont = myInput.readLine()) != null) {
// zim encapsulates bold letters with **
// media wiki encapsulates bold letters with '''
cont = cont.replace("**", "'''");
// images are written in zim:
// {{../MatlabSVM_01.png?width=400}}
// in media wiki:
// [[MatlabSVM_01.png|45px|none|MatlabSVM_01]]
cont = cont.replace("{{../", "[[Image:");
cont = cont.replace("?width=", "|");
cont = cont.replace("}}", "|none| " + name + "]]");
text.append( cont + "\n");
}
}
}
} catch (Exception e) {
e.printStackTrace(); // TODO transform to system exception
}
sa.setText(text.toString());
return sa;
}