| | |
| | | import com.sun.net.httpserver.HttpContext; |
| | | import com.sun.net.httpserver.HttpExchange; |
| | | import de.uhilger.neon.FileServer; |
| | | import de.uhilger.neon.HttpHelper; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.URI; |
| | |
| | | @Override |
| | | public void doFilter(HttpExchange exchange, Chain chain) throws IOException { |
| | | URI uri = exchange.getRequestURI(); |
| | | String path = uri.getPath(); |
| | | //String path = uri.getPath(); |
| | | try { |
| | | String path = new HttpHelper().getFileName(exchange); |
| | | if(path.endsWith(".adoc")) { |
| | | HttpContext ctx = exchange.getHttpContext(); |
| | | String fileBase = ctx.getAttributes().get(FileServer.ATTR_FILE_BASE).toString(); |
| | |
| | | processAdocFile(new File(fileBase, fileName), false); |
| | | } |
| | | } |
| | | } catch (IllegalArgumentException ex) { |
| | | // ungueltiger Dateiname, keine Transformation noetig, also tue nichts |
| | | } finally { |
| | | chain.doFilter(exchange); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Eine Asciidoc-Quelldatei nach HTML und optional PDF transformieren, sofern |
| | | * eine HTML-Datei noch nicht existiert oder die HTML-Datei aelter ist, als |