Download Jar. Libraryless. Click here for Pure Java version (16680L/115K).
1 | !7 |
2 | |
3 | concept Rule > ConceptWithGlobalID { |
4 | S input, output, variables /* comma-separated */, comment; |
5 | sS _fieldOrder = "globalID input output variables comment"; |
6 | } |
7 | |
8 | concept PossibleExample > ConceptWithGlobalID { |
9 | Rule rule; |
10 | S input, output; |
11 | SS mapping; |
12 | sS _fieldOrder = "globalID rule input output mapping"; |
13 | } |
14 | |
15 | concept Input > ConceptWithGlobalID { |
16 | S input; |
17 | } |
18 | |
19 | p { |
20 | db(); |
21 | indexConceptFields(PossibleExample, 'rule); |
22 | indexConceptFieldsCI(Input, 'input, Rule, 'input); |
23 | indexConceptFieldsOrdered(Rule, 'globalID); |
24 | } |
25 | |
26 | static HCRUD rulesCRUD() { |
27 | ret new HCRUD(rawLink("admin"), new HCRUD_Concepts<Rule>(Rule) { |
28 | MapSO itemToMap(Rule r) { |
29 | ret mapPlus(super.itemToMap(r), "Possible Examples" := countConcepts(PossibleExample, rule := r)); |
30 | } |
31 | |
32 | Cl<Rule> listConcepts() { |
33 | ret conceptsSortedByFieldCI(Rule, 'input); |
34 | } |
35 | }.fieldHelp(variables := "comma-separated") |
36 | ) { |
37 | S renderValue(S field, O value) { |
38 | S html = super.renderValue(field, value); |
39 | if (eq(field, 'globalID)) |
40 | ret ahref(rawLink(str(value)), html); |
41 | if (eq(field, 'input)) |
42 | ret b(html); |
43 | ret html; |
44 | } |
45 | }; |
46 | } |
47 | |
48 | static HCRUD inputsCRUD() { |
49 | ret new HCRUD(new HCRUD_Concepts<Input>(Input.class)); |
50 | } |
51 | |
52 | html { |
53 | bool authed = webAuthed(params); |
54 | |
55 | if (eqic(uri = dropSlashPrefix(uri), "admin")) { |
56 | try object checkWebAuthed(params); |
57 | ret rulesCRUD().renderPage(params); |
58 | } |
59 | |
60 | if (empty(uri)) |
61 | ret htitle_h1("Rules") |
62 | + (webAuthed(params) ? p(ahref(rawLink("admin"), "Admin")) : "") |
63 | + ul_noEncode(map(list(Rule), r -> ahref(rawLink(r.globalIDStr()), htmlEncode2(r.input + " => " + r.output)))); |
64 | |
65 | // serve rule |
66 | if (possibleGlobalID(uri)) { |
67 | Rule r = conceptWhere(Rule, globalID := GlobalID(uri)); |
68 | if (r == null) ret subBot_serve404("Rule not found"); |
69 | S html = htitle_h1("Rule " + r.globalID) |
70 | + htmlTable2(mapToTwoElementMaps("Field", "Value", litorderedmap("Input" := r.input, "Output" := r.output, "Variables" := r.variables, "Comment" := r.comment))); |
71 | //html += conceptsWhere Input(rule := r); |
72 | /*if (webAuthed(params)) |
73 | html += new HCRUD(rawLink(r.globalIDStr()), new HCRUD_Concepts<PossibleInput>(PossibleInput.class).addFilter(rule := r)) |
74 | .makeFrame((title, contents) -> h3(title) + contents) |
75 | .renderPage(params);*/ |
76 | ret html; |
77 | } |
78 | |
79 | new Matches m; |
80 | if (swic(uri, "multi/", m)) |
81 | ret new HMultiCRUD(rawLink("multi"), Rule, Input, PossibleExample) { |
82 | HCRUD makeCRUD(S className) { |
83 | if (eq(className, "Rule")) ret rulesCRUD(); |
84 | if (eq(className, "Input")) ret inputsCRUD(); |
85 | null; |
86 | } |
87 | } .mainTitle("Rules + Inputs") |
88 | .mutationRights(authed) |
89 | .renderPage(m.rest(), params); |
90 | |
91 | ret subBot_serve404(); |
92 | } |
Began life as a copy of #1026126
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1026160 |
Snippet name: | Rules + Inputs Web Bot backup |
Eternal ID of this version: | #1026160/1 |
Text MD5: | be4a1288085b1876c32029c4f8112c2c |
Transpilation MD5: | 0f5dd5a6f1a3d01a66d5aaca88089606 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX module (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-11-27 16:01:54 |
Source code size: | 2860 bytes / 92 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 365 / 1164 |
Referenced in: | [show references] |