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).

1  
!7
2  
3  
p { useLocalMechListCopies(); }
4  
5  
html {
6  
  uri = dropPrefix("/", uri);
7  
  Pair<L<IfThen>, LS> p = ai_activeRulesAndFacts();
8  
  L<IfThen> rules = p.a;
9  
  LS facts = p.b;
10  
  S ruleID = urldecode(uri);
11  
  
12  
  if (empty(uri)) {
13  
    // Rule list
14  
    
15  
    ret h2_title(n2(rules, "rule") + " (showing first trigger)")
16  
    + ul(map_pcall(reversed(rules), func(IfThen rule) {
17  
      S s = ahref("/rules/" + urlencode(rule.globalID), htmlencode(rule.globalID));
18  
      Exp e = nlLogic_firstCondition(rule);
19  
      if (e != null)
20  
        s += " - " + htmlencode(e);
21  
      ret tt(s);
22  
    }));
23  
  }
24  
    
25  
  L<IfThen> found = filterByField(rules, globalID := ruleID);
26  
  if (empty(found)) ret "Rule " + htmlencode(ruleID) + " not found";
27  
  
28  
  new StringBuilder buf;
29  
  
30  
  if (l(found) > 1)
31  
    buf.append(p("Bad: Multiple rules for ID " + htmlencode(ruleID) + "."));
32  
    
33  
  for (IfThen rule : found) {
34  
    buf.append(h2_title("Rule " + htmlencode(rule.globalID)));
35  
    buf.append(hsourcecode(/*str(rule)*/ rule.originalText));
36  
    if (ai_ruleDifferentFromOriginalText(rule)) {
37  
      buf.append(h3("Loaded as"));
38  
      buf.append(hsourcecode(str(rule)));
39  
    }
40  
    LS ruleFacts = stringsContaining(facts, ruleID);
41  
    if (nempty(ruleFacts)) {
42  
      buf.append(h3("Facts about this rule"));
43  
      buf.append(hsourcecode(ruleFacts));
44  
    }
45  
  }
46  
  
47  
  ret buf;
48  
}

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: 362 / 1954
Version history: 15 change(s)
Referenced in: [show references]