Asciidoctor mit Neon transformieren
ulrich
2021-10-26 8b9c74e666021152c73db133f772dc68f5efb36c
PDF ergaenzt (noch experimentell)
3 files modified
24 ■■■■ changed files
src/de/uhilger/httpserver/adoc/AdocActor.java 9 ●●●● patch | view | raw | blame | history
src/de/uhilger/httpserver/adoc/AdocFilter.java 6 ●●●● patch | view | raw | blame | history
src/de/uhilger/httpserver/adoc/AdocHandler.java 9 ●●●● patch | view | raw | blame | history
src/de/uhilger/httpserver/adoc/AdocActor.java
@@ -49,11 +49,16 @@
  public static final String HTML = "html";
  public static final String PDF = "pdf";
  
  public void handle(HttpExchange e, String fileBase, String fileName) throws IOException {
  public void handle(HttpExchange e, String fileBase, String fileName, boolean pdf) throws IOException {
    File adocfile = new File(fileBase, fileName);
    logger.fine("adocfile: " + adocfile.getAbsolutePath());
    AdocActor actor = new AdocActor();
    File outfile = actor.getTargetFile(adocfile, AdocActor.HTML);
    File outfile;
    if(pdf) {
      outfile = actor.getTargetFile(adocfile, AdocActor.PDF);
    } else {
      outfile = actor.getTargetFile(adocfile, AdocActor.HTML);
    }
    logger.fine("outfile: " + outfile.getAbsolutePath());
    HttpResponder fs = new HttpResponder();
    fs.serveFile(e, outfile);
src/de/uhilger/httpserver/adoc/AdocFilter.java
@@ -59,7 +59,11 @@
        String fileBase = exchange.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString();
        AdocActor actor = new AdocActor();
        HttpHelper helper = new HttpHelper();
        actor.processAdocFile(new File(fileBase, helper.getFileName(exchange)), Boolean.FALSE.toString());
        if(query != null && query.equalsIgnoreCase("pdf=true")) {
          actor.processAdocFile(new File(fileBase, helper.getFileName(exchange)), Boolean.TRUE.toString());
        } else {
          actor.processAdocFile(new File(fileBase, helper.getFileName(exchange)), Boolean.FALSE.toString());
        }
      }
    }    
    chain.doFilter(exchange);
src/de/uhilger/httpserver/adoc/AdocHandler.java
@@ -59,9 +59,14 @@
    String ctxPath = e.getHttpContext().getPath();
    String uriPath = e.getRequestURI().getPath();
    String fName = uriPath.substring(ctxPath.length());
    AdocActor actor = new AdocActor();
    actor.handle(e, e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), fName);
    String query = uri.getQuery();
    if(query != null && query.equalsIgnoreCase("pdf=true")) {
      actor.handle(e, e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), fName, true);
    } else {
      actor.handle(e, e.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), fName, false);
    }
  }