Commit 26c74233 authored by Nico Mack's avatar Nico Mack

Changes required for template lookup to work from within jar file

parent 33f18144
......@@ -125,8 +125,8 @@ public class TangibleInterfaceManager extends Stage {
protected static final Logger LOGGER = LoggerFactory.getLogger(TangibleInterfaceManager.class.getSimpleName());
private static final String ABOUT_HTML_TEMPLATE = "about.html";
private static final String PACKAGE_HTML_TEMPLATE = "package.html";
private static final String ABOUT_HTML_TEMPLATE = "/about.html";
private static final String PACKAGE_HTML_TEMPLATE = "/tulip_package.html";
private static final Pattern VARIABLE_PATTERN = Pattern.compile("\\$\\{([a-z0-9\\-_]+)\\}", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
private static final Pattern URI_PATTERN = Pattern.compile("^file:(.*?)$", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
......@@ -182,6 +182,8 @@ public class TangibleInterfaceManager extends Stage {
about.put(About.FILE_NAME, scenario.getName());
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); //$NON-NLS-1$
about.put(About.LAST_MODIFIED, dateFormat.format(scenario.lastModified()));
} else {
LOGGER.warn("Unable to locate scenario file {}!", uriMatcher.group(1));
}
}
......@@ -201,13 +203,26 @@ public class TangibleInterfaceManager extends Stage {
// ---------------------------------------------------------------------------
// private String readHtmlTemplate(String templatePath) {
// String html = null;
//
// if ((templatePath != null) && !templatePath.isEmpty()) {
// ClassLoader loader = TangibleInterfaceManager.class.getClassLoader();
//
// try (Reader templateReader = new InputStreamReader(loader.getResourceAsStream(templatePath))) {
// html = IOUtils.toString(templateReader);
// } catch (IOException e) {
// LOGGER.warn("Error while reading HTML template {}!", templatePath, e); //$NON-NLS-1$
// }
// }
// return html;
// }
private String readHtmlTemplate(String templatePath) {
String html = null;
if ((templatePath != null) && !templatePath.isEmpty()) {
ClassLoader loader = TangibleInterfaceManager.class.getClassLoader();
try (Reader templateReader = new InputStreamReader(loader.getResourceAsStream(templatePath))) {
try (Reader templateReader = new InputStreamReader(TangibleInterfaceManager.class.getResourceAsStream(templatePath))) {
html = IOUtils.toString(templateReader);
} catch (IOException e) {
LOGGER.warn("Error while reading HTML template {}!", templatePath, e); //$NON-NLS-1$
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment