Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

53
LINES

< > BotCompany Repo | #1034707 // snippetTranspileWebBot

JavaX fragment (include)

sO snippetTranspileWebBot(S uri, SS params, int refreshDelay) {
  if (eq("1", params.get('medium))) {
    veryQuickJava_mediumRefresh();
    print("Medium-refreshed transpiler.");
  }
  
  if (eq("1", params.get('fresh))) {
    refreshTranspiler();
    print("Refreshed transpiler.");
  }
  
  // use new TranspileForServer class (now default)
  //bool useNewTFS = eq("1", params.get("newTFS"));
  bool useNewTFS = !eq("0", params.get("newTFS"));
  
  uri = dropPrefixSlash(uri);
  if (isSnippetID(uri)) params.put(snippetID := uri);
  
  if (empty(params.get('snippetID))) ret "OK";
  
  sendToSnippetUpdatesBot("/transpiling/" + psI(params.get('snippetID)));
  
  final bool compile = eq("1", params.get('compile));
  
  final new Flag ok;
  print_byThread = new InheritableThreadLocal;
  S text = hijackPrint_tee(r {
    S snippetID = fsI(params.get('snippetID));
    pcall {
      bool isInclude = getSnippetType(snippetID) == snippetType_JavaXInclude();
      transpileRaw_translator();
      set(transpileRaw_trans, +print_byThread);
      print("Set print_byThread (" + print_byThread! + ") in " + systemHashCode(transpileRaw_trans));
      temp tempSetTL(transpileRaw_asInclude, isInclude);
      
      if (useNewTFS)
        new TranspileForServer(snippetID).run();
      else {
        temp tempSetTL(transpileForServer_compile, compile);
        transpileForServer(snippetID);
      }
      
      ok.raise();
    }
  });
  
  S redirect = params.get('redirect);
  
  ret hhtml(hhead(htitle((ok.isUp() ? "OK" : "Failed") + " Transpilation")
    + (ok.isUp() && nempty(redirect) ? hrefresh(refreshDelay, redirect) : ""))
    + hbody(hsourcecode(text)))
    + (ok.isUp() ? "" : hjs_scrollDownOnPageLoad());
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034707
Snippet name: snippetTranspileWebBot
Eternal ID of this version: #1034707/4
Text MD5: 952401a2081af7b181a863ff483bfc46
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-06 16:24:07
Source code size: 1770 bytes / 53 lines
Pitched / IR pitched: No / No
Views / Downloads: 141 / 172
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)