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

48
LINES

< > BotCompany Repo | #1017959 // Rule Info Web Bot [LIVE]

JavaX source code (desktop) [tags: butter use-pretranspiled] - run with: x30.jar - homepage

Download Jar. Libraryless. Click here for Pure Java version (8467L/58K).

!7

p { useLocalMechListCopies(); }

html {
  uri = dropPrefix("/", uri);
  Pair<L<IfThen>, LS> p = ai_activeRulesAndFacts();
  L<IfThen> rules = p.a;
  LS facts = p.b;
  S ruleID = urldecode(uri);
  
  if (empty(uri)) {
    // Rule list
    
    ret h2_title(n2(rules, "rule") + " (showing first trigger)")
    + ul(map_pcall(reversed(rules), func(IfThen rule) {
      S s = ahref("/rules/" + urlencode(rule.globalID), htmlencode(rule.globalID));
      Exp e = nlLogic_firstCondition(rule);
      if (e != null)
        s += " - " + htmlencode(e);
      ret tt(s);
    }));
  }
    
  L<IfThen> found = filterByField(rules, globalID := ruleID);
  if (empty(found)) ret "Rule " + htmlencode(ruleID) + " not found";
  
  new StringBuilder buf;
  
  if (l(found) > 1)
    buf.append(p("Bad: Multiple rules for ID " + htmlencode(ruleID) + "."));
    
  for (IfThen rule : found) {
    buf.append(h2_title("Rule " + htmlencode(rule.globalID)));
    buf.append(hsourcecode(/*str(rule)*/ rule.originalText));
    if (ai_ruleDifferentFromOriginalText(rule)) {
      buf.append(h3("Loaded as"));
      buf.append(hsourcecode(str(rule)));
    }
    LS ruleFacts = stringsContaining(facts, ruleID);
    if (nempty(ruleFacts)) {
      buf.append(h3("Facts about this rule"));
      buf.append(hsourcecode(ruleFacts));
    }
  }
  
  ret buf;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1017959
Snippet name: Rule Info Web Bot [LIVE]
Eternal ID of this version: #1017959/16
Text MD5: eb33a0c26333c307212b9b52b0b69965
Transpilation MD5: 454c97e9d64bc341a59f6acc6cc219fe
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-23 17:45:36
Source code size: 1379 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 462 / 2268
Version history: 15 change(s)
Referenced in: #1013896 - Eleutheria Main for butter.botcompany.de + Stefan's OS (LIVE)
#1024026 - Eleutheria Main for butter.botcompany.de (backup without Stefan's OS)