-
- private String getContentOf(String file) {
- InputStream in = IOUtils.openResource(WebLibraryServerIndex.class,
- file);
- if (in != null) {
- try {
- return IOUtils.readSmallStream(in);
- } catch (IOException e) {
- Instance.getInstance().getTraceHandler().error(
- new IOException("Cannot get file: index.pre.html", e));
- }
- }
-
- return "";
- }
-
- private void appendPreHtml(StringBuilder builder, boolean banner) {
- String favicon = "favicon.ico";
- String icon = Instance.getInstance().getUiConfig()
- .getString(UiConfig.PROGRAM_ICON);
- if (icon != null) {
- favicon = "icon_" + icon.replace("-", "_") + ".png";
- }
-
- builder.append(
- getContentOf("index.pre.html").replace("favicon.ico", favicon));
-
- if (banner) {
- builder.append("<div class='banner'>\n");
- builder.append("\t<img class='ico' src='/") //
- .append(favicon) //
- .append("'/>\n");
- builder.append("\t<h1>Fanfix</h1>\n");
- builder.append("\t<h2>") //
- .append(Version.getCurrentVersion()) //
- .append("</h2>\n");
- builder.append("</div>\n");
- }
- }
-
- private void appendPostHtml(StringBuilder builder) {
- builder.append(getContentOf("index.post.html"));
- }
-
- private void appendOption(StringBuilder builder, int depth, String name,
- String value, String selected) {
- for (int i = 0; i < depth; i++) {
- builder.append("\t");
- }
- builder.append("<option value='").append(value).append("'");
- if (value.equals(selected)) {
- builder.append(" selected='selected'");
- }
- builder.append(">").append(name).append("</option>\n");
- }
-
- private void appendTableRow(StringBuilder builder, int depth,
- String... tds) {
- for (int i = 0; i < depth; i++) {
- builder.append("\t");
- }
-
- int col = 1;
- builder.append("<tr>");
- for (String td : tds) {
- builder.append("<td class='col");
- builder.append(col++);
- builder.append("'>");
- builder.append(td);
- builder.append("</td>");
- }
- builder.append("</tr>\n");
- }
-
- private void appendItemA(StringBuilder builder, int depth, String link,
- String name, boolean selected) {
- for (int i = 0; i < depth; i++) {
- builder.append("\t");
- }
-
- builder.append("<a href='");
- builder.append(link);
- builder.append("' class='item goto");
- if (selected) {
- builder.append(" selected");
- }
- builder.append("'>");
- builder.append(name);
- builder.append("</a>\n");
- }