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

41
LINES

< > BotCompany Repo | #1002638 - Web Log Bot (Web)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (2714L/19K/59K).

!752


static S webLogProgramID = "#1002576";
static S webLog = "webLog";

static S html(S subUri, Map<S, S> params) {
  if (!master()) ret "Sorry, not authorized.";
  
  L<S> keepFields = litlist("full", "n");
  
  boolean full = webTrue(params.get("full"));
  L data; // contains maps or structure()-d maps
  if (full)
    data = scanLog(getProgramFile(webLogProgramID, webLog));
  else
    data = (L) call(getMainBot(), "getRecentWebLog");
  new StringBuffer buf;
  
  pcall {
    int x = 0;

    int n;
    if (!empty(params.get("n")))
      n = parseInt(params.get("n"));
    else
      n = max(0, l(data)-1)/100*100;
      
    for (int i = min(n+100, l(data))-1; i >= n; i--) {
      S entry = structureOrText(data.get(i));
      buf.append("Entry " + (i+1) + ": " + entry + "\n");
    }
  }
  
  ret p(href(selfLink(params, keepFields, "full", "0"), "Recent Log")
    + " | "
    + href(selfLink(params, keepFields, "full", "1"), "Full Log"))
    + p("n=" + l(data))
    + pageNav(params, keepFields, l(data), "n") // has its own <p>
    + sourceCodeToHTML(buf);
}

Author comment

Began life as a copy of #1002378

download  show line numbers  debug dex   

Travelled to 11 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1002638
Snippet name: Web Log Bot (Web)
Eternal ID of this version: #1002638/1
Text MD5: 5bc1995be890efd6913c03ee16f58b4e
Transpilation MD5: b45613ad9f8a10a793b686a09c17bc1e
Author: stefan
Category: nl bots
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-31 05:01:31
Source code size: 1112 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 520 / 3825
Referenced in: [show references]

Formerly at http://tinybrain.de/1002638 & http://1002638.tinybrain.de