Skip to content

Commit 1e44a36

Browse files
committed
Add support for Raw data rendering
1 parent d6096f8 commit 1e44a36

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

filescanner-gtk-linux-x86_64/shared-src/main/java/de/carne/filescanner/swt/main/HtmlRenderServer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ class HtmlRenderServer {
5151
private static final String STYLESHEET_PATH = "/" + STYLESHEET_RESOURCE;
5252

5353
private final HttpServer httpServer;
54-
@Nullable
55-
private HttpHandler stylesheetHandler;
54+
private @Nullable HttpHandler stylesheetHandler;
5655
private final List<HttpHandler> persistentSessionHandlers = new ArrayList<>();
5756
private final List<HttpHandler> transientSessionHandlers = new ArrayList<>();
5857

filescanner-gtk-linux-x86_64/shared-src/main/java/de/carne/filescanner/swt/main/HtmlResultDocument.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,23 @@ public int emitMediaData(RenderStyle style, TransferSource source, boolean lineB
176176

177177
this.writer.write(counter.count("<span class=\""));
178178
this.writer.write(counter.count(style.name().toLowerCase()));
179-
this.writer.write(counter.count("\"><img src=\""));
180-
this.writer.write(counter.count(mediaDataSourcePath));
181-
this.writer.write(counter.count("\" alt=\""));
182-
this.writer.write(counter.count(encodeText(source.name())));
183-
this.writer.write(counter.count("\"></span>"));
179+
180+
String mimeType = source.transferType().mimeType();
181+
182+
if (mimeType.startsWith("image/")) {
183+
this.writer.write(counter.count("\"><img src=\""));
184+
this.writer.write(counter.count(mediaDataSourcePath));
185+
this.writer.write(counter.count("\" alt=\""));
186+
this.writer.write(counter.count(encodeText(source.name())));
187+
this.writer.write(counter.count("\">"));
188+
} else {
189+
this.writer.write(counter.count("\"><a href=\""));
190+
this.writer.write(counter.count(mediaDataSourcePath));
191+
this.writer.write(counter.count("\">["));
192+
this.writer.write(counter.count(encodeText(source.name())));
193+
this.writer.write(counter.count("]</a>"));
194+
}
195+
this.writer.write(counter.count("</span>"));
184196
if (lineBreak) {
185197
this.writer.write(counter.count("<br>\n"));
186198
}

0 commit comments

Comments
 (0)