X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Foutput%2Ftemplate%2FTemplate.java;h=2a2bba6a4329b9146d4742ae6078bcbf66247334;hb=49d8f1404d62a69e552c12e61d78a33c6f903e20;hp=4789a36573c6bae3b230f3485f543b85f50d2827;hpb=0d1d3c357c8274c519270abc61b668bff637c40a;p=gigi.git diff --git a/src/org/cacert/gigi/output/template/Template.java b/src/org/cacert/gigi/output/template/Template.java index 4789a365..2a2bba6a 100644 --- a/src/org/cacert/gigi/output/template/Template.java +++ b/src/org/cacert/gigi/output/template/Template.java @@ -9,13 +9,14 @@ import java.io.PrintWriter; import java.io.Reader; import java.net.URISyntaxException; import java.net.URL; +import java.util.Date; import java.util.LinkedList; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.cacert.gigi.DevelLauncher; import org.cacert.gigi.localisation.Language; +import org.cacert.gigi.output.DateSelector; import org.cacert.gigi.util.HTMLEncoder; public class Template implements Outputable { @@ -55,7 +56,7 @@ public class Template implements Outputable { private File source; - private static final Pattern CONTROL_PATTERN = Pattern.compile(" ?([a-z]+)\\(\\$([^)]+)\\) ?\\{ ?"); + private static final Pattern CONTROL_PATTERN = Pattern.compile(" ?([a-zA-Z]+)\\(\\$([^)]+)\\) ?\\{ ?"); private static final Pattern ELSE_PATTERN = Pattern.compile(" ?\\} ?else ?\\{ ?"); @@ -63,7 +64,7 @@ public class Template implements Outputable { try { Reader r = new InputStreamReader(u.openStream(), "UTF-8"); try { - if (u.getProtocol().equals("file") && DevelLauncher.DEVEL) { + if (u.getProtocol().equals("file")) { source = new File(u.toURI()); lastLoaded = source.lastModified() + 1000; } @@ -166,17 +167,15 @@ public class Template implements Outputable { @Override public void output(PrintWriter out, Language l, Map vars) { - if (source != null && DevelLauncher.DEVEL) { - if (lastLoaded < source.lastModified()) { - try { - System.out.println("Reloading template.... " + source); - InputStreamReader r = new InputStreamReader(new FileInputStream(source), "UTF-8"); - data = parse(r).getBlock(null); - r.close(); - lastLoaded = source.lastModified() + 1000; - } catch (IOException e) { - e.printStackTrace(); - } + if (source != null && lastLoaded < source.lastModified()) { + try { + System.out.println("Reloading template.... " + source); + InputStreamReader r = new InputStreamReader(new FileInputStream(source), "UTF-8"); + data = parse(r).getBlock(null); + r.close(); + lastLoaded = source.lastModified() + 1000; + } catch (IOException e) { + e.printStackTrace(); } } data.output(out, l, vars); @@ -190,6 +189,8 @@ public class Template implements Outputable { } if (s instanceof Outputable) { ((Outputable) s).output(out, l, vars); + } else if (s instanceof Date) { + out.print(DateSelector.getDateFormat().format(s)); } else { out.print(s == null ? "null" : (unescaped ? s.toString() : HTMLEncoder.encodeHTML(s.toString()))); }