- From: Jean-Guilhem Rouel via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 20 Jan 2009 13:58:55 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/index
In directory hutz:/tmp/cvs-serv29415/org/w3c/css/index
Modified Files:
IndexGenerator.java
Log Message:
jar should now work as expected; reindented some files; fixed velocity paths (not very beautiful though, would need some more work)
Index: IndexGenerator.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/index/IndexGenerator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- IndexGenerator.java 10 Dec 2008 15:25:52 -0000 1.7
+++ IndexGenerator.java 20 Jan 2009 13:58:53 -0000 1.8
@@ -45,7 +45,7 @@
* @param args
*/
public static void main(String[] args) {
- IndexGenerator.generatesIndex(false);
+ IndexGenerator.generatesIndex(false);
}
/**
@@ -55,103 +55,103 @@
* the path is a bit different and need to be changed.
*/
public static synchronized void generatesIndex(boolean servlet) {
- if (done)
- return;
+ if (done)
+ return;
- String default_lang = "en";
- String k, name, path;
- ApplContext ac_default = new ApplContext(default_lang);
- File tmpFile;
- Iterator it;
+ String default_lang = "en";
+ String k, name, path;
+ ApplContext ac_default = new ApplContext(default_lang);
+ File tmpFile;
+ Iterator it;
- // Getting the differents languages informations (for the lang choice)
- HashMap[] languages = new HashMap[Messages.languages_name.size()];
- for (int i = 0; i < Messages.languages_name.size(); ++i) {
- name = String.valueOf(Messages.languages_name.get(i));
- HashMap<String,String> l = new HashMap<String,String>();
- l.put("name", name);
- l.put("real", ((Utf8Properties) Messages.languages.get(name)).getProperty("language_name"));
- languages[i] = l;
- }
- // Adding the result to the context
- vc.put("languages", languages);
+ // Getting the differents languages informations (for the lang choice)
+ HashMap[] languages = new HashMap[Messages.languages_name.size()];
+ for (int i = 0; i < Messages.languages_name.size(); ++i) {
+ name = String.valueOf(Messages.languages_name.get(i));
+ HashMap<String,String> l = new HashMap<String,String>();
+ l.put("name", name);
+ l.put("real", ((Utf8Properties) Messages.languages.get(name)).getProperty("language_name"));
+ languages[i] = l;
+ }
+ // Adding the result to the context
+ vc.put("languages", languages);
- try {
- //setting the path were to find the template
- path = IndexGenerator.class.getResource("").getPath();
- if (servlet)
- path = path.replace("file://localhost", "");
- else
- path = new URI(path).getPath();
+ try {
+ //setting the path were to find the template
+ path = IndexGenerator.class.getResource("").getPath();
+ if (servlet)
+ path = path.replace("file://localhost", "");
+ else
+ path = new URI(path).getPath();
- /*
- * This code set the velocity properties to be used
- * A new jar is needed to use file logging (avalon-logkit.jar)
- */
- Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);
- Velocity.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path + "../css/");
- Velocity.setProperty(Velocity.RUNTIME_LOG,
- "velocity-" + new SimpleDateFormat("yyyy-MM-dd_HHmm").format(new Date()) + ".log");
+ /*
+ * This code set the velocity properties to be used
+ * A new jar is needed to use file logging (avalon-logkit.jar)
+ */
+ Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);
+ Velocity.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path + "../../../../");
+ Velocity.setProperty(Velocity.RUNTIME_LOG,
+ "velocity-" + new SimpleDateFormat("yyyy-MM-dd_HHmm").format(new Date()) + ".log");
- Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.AvalonLogChute");
- Velocity.init();
- if (!new File(path + template_name).exists()) {
- template_name = "org/w3c/css/css/" + template_name;
- html_files_path = "";
- }
- Template tpl = Velocity.getTemplate(template_name, "UTF-8");
- int count = 0;
+ Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.AvalonLogChute");
+ Velocity.init();
+ if (!new File(path + template_name).exists()) {
+ template_name = template_name;
+ html_files_path = "";
+ }
+ Template tpl = Velocity.getTemplate(template_name, "UTF-8");
+ int count = 0;
- // For each language, we set the context are create the template
- for (int i = 0; i < Messages.languages_name.size(); ++i) {
- name = String.valueOf(Messages.languages_name.get(i));
- tmpFile = new File(path + html_files_path + "validator.html." + name);
+ // For each language, we set the context are create the template
+ for (int i = 0; i < Messages.languages_name.size(); ++i) {
+ name = String.valueOf(Messages.languages_name.get(i));
+ tmpFile = new File(path + html_files_path + "validator.html." + name);
- // Checking if the index files exists
- // and if they have been created after the last template modification
- if ((tmpFile.lastModified() < tpl.getLastModified()) || !tmpFile.exists()) {
- ApplContext ac = new ApplContext(name);
- vc.put("lang", name);
+ // Checking if the index files exists
+ // and if they have been created after the last template modification
+ if ((tmpFile.lastModified() < tpl.getLastModified()) || !tmpFile.exists()) {
+ ApplContext ac = new ApplContext(name);
+ vc.put("lang", name);
- if (ac.getLang().equals(default_lang)) {
- it = ac_default.getMsg().properties.keySet().iterator();
- while (it.hasNext()) {
- k = String.valueOf(it.next());
- vc.put(k, ac.getMsg().getString(k));
- }
- } else {
- it = ac_default.getMsg().properties.keySet().iterator();
- while (it.hasNext()) {
- k = String.valueOf(it.next());
- if (ac.getMsg().getString(k) == null)
- vc.put(k, ac_default.getMsg().getString(k));
- else
- vc.put(k, ac.getMsg().getString(k));
- }
- }
- OutputStreamWriter aFileWriter = new OutputStreamWriter(new FileOutputStream(tmpFile), "UTF-8");
- tpl.merge(vc, aFileWriter);
- aFileWriter.close();
- ++count;
- }
- }
- Velocity.getLog().info("IndexGenerator : " + count + " index file(s) created or modified");
- done = true;
- } catch (ResourceNotFoundException e) {
- e.printStackTrace();
- } catch (ParseErrorException e) {
- e.printStackTrace();
- } catch (MethodInvocationException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (URISyntaxException e1) {
- e1.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- done = true;
- }
+ if (ac.getLang().equals(default_lang)) {
+ it = ac_default.getMsg().properties.keySet().iterator();
+ while (it.hasNext()) {
+ k = String.valueOf(it.next());
+ vc.put(k, ac.getMsg().getString(k));
+ }
+ } else {
+ it = ac_default.getMsg().properties.keySet().iterator();
+ while (it.hasNext()) {
+ k = String.valueOf(it.next());
+ if (ac.getMsg().getString(k) == null)
+ vc.put(k, ac_default.getMsg().getString(k));
+ else
+ vc.put(k, ac.getMsg().getString(k));
+ }
+ }
+ OutputStreamWriter aFileWriter = new OutputStreamWriter(new FileOutputStream(tmpFile), "UTF-8");
+ tpl.merge(vc, aFileWriter);
+ aFileWriter.close();
+ ++count;
+ }
+ }
+ Velocity.getLog().info("IndexGenerator : " + count + " index file(s) created or modified");
+ done = true;
+ } catch (ResourceNotFoundException e) {
+ e.printStackTrace();
+ } catch (ParseErrorException e) {
+ e.printStackTrace();
+ } catch (MethodInvocationException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e1) {
+ e1.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ done = true;
+ }
}
}
Received on Tuesday, 20 January 2009 13:59:05 UTC