-
- private String getTemplateIndexPreBanner(boolean banner)
- throws IOException {
- String favicon = "favicon.ico";
- String icon = Instance.getInstance().getUiConfig()
- .getString(UiConfig.PROGRAM_ICON);
- if (icon != null) {
- favicon = "icon_" + icon.replace("-", "_") + ".png";
- }
-
- String html = getTemplate("index.pre") //
- .replace("${title}", "Fanfix") //
- .replace("${favicon}", favicon) //
- ;
-
- if (banner) {
- html += getTemplate("index.banner") //
- .replace("${favicon}", favicon) //
- .replace("${version}",
- Version.getCurrentVersion().toString()) //
- ;
- }
-
- return html;
- }
-
- private String getTemplateBrowserOption(String name, String value,
- String selected) throws IOException {
- String selectedAttribute = "";
- if (value.equals(selected)) {
- selectedAttribute = " selected='selected'";
- }
-
- return getTemplate("browser.option" //
- .replace("${value}", value) //
- .replace("${selected}", selectedAttribute) //
- .replace("${name}", name) //
- );
- }
-
- private String getTemplate(String template) throws IOException {
- // TODO: check if it is "slow" -> map cache
- InputStream in = IOUtils.openResource(WebLibraryServerTemplates.class,
- template + ".html");
- try {
- return IOUtils.readSmallStream(in);
- } finally {
- in.close();
- }
- }