Uses 911K of libraries. Click here for Pure Java version (15652L/83K).
1 | !7 |
2 | |
3 | concept User { |
4 | GlobalID eleuUserGlobalID; |
5 | S googleEmail; |
6 | |
7 | Superposition defaultSuperposition; |
8 | |
9 | Superposition defaultSuperposition() { |
10 | ret withDBLock(this, () -> { |
11 | if (defaultSuperposition == null) |
12 | cset(this, defaultSuperposition := cnew Superposition(user := User.this, name := shortUserName() + "1")); |
13 | ret defaultSuperposition; |
14 | }); |
15 | } |
16 | |
17 | S shortUserName() { |
18 | ret or2(takeCharsWhile isLetter(googleEmail), "unknown"); |
19 | } |
20 | } |
21 | |
22 | concept Superposition > ConceptWithGlobalID { |
23 | User user; |
24 | S name; |
25 | } |
26 | |
27 | concept Rewrite > ConceptWithGlobalID { |
28 | Superposition sp; |
29 | S in, out, purpose, conditions; |
30 | } |
31 | |
32 | concept Statement > ConceptWithGlobalID { |
33 | Superposition sp; |
34 | S text, meta; |
35 | bool enabled; |
36 | } |
37 | |
38 | cmodule RewriteDBWebBot > DynPrintLogAndEnabled { |
39 | set flag NoNanoHTTPD. |
40 | |
41 | S myLink() { ret "/db/"; } |
42 | |
43 | start { |
44 | dbIndexing(User, 'eleuUserGlobalID); |
45 | } |
46 | |
47 | O html(virtual Request req) { |
48 | try { |
49 | SS params = cast rget params(req); |
50 | virtual User eleuUser = rcall loggedInUser(req); |
51 | if (eleuUser == null) ret "Need cookie"; |
52 | GlobalID userID = cast quickImport(rcall globalID(eleuUser)); |
53 | User user = uniq User(eleuUserGlobalID := assertNotNull(userID)); |
54 | cset(user, googleEmail := getString googleEmail(eleuUser)); |
55 | |
56 | HCRUD_Concepts<Superposition> data = new <>(Superposition.class).addFilter(+user); |
57 | HCRUD crud = new(myLink(), data); |
58 | crud.uneditableFields = litset("globalID", "user"); |
59 | ret "Hello " + eleuUser |
60 | + ", " + user.eleuUserGlobalID + ", " + user.googleEmail |
61 | + h3("Your superpositions") |
62 | + crud.renderPage(params); |
63 | } on fail e { printStackTrace(e); } |
64 | } |
65 | |
66 | // API for Eleu |
67 | |
68 | void setEleu(O eleu) { mainBot = eleu; } |
69 | } |
Began life as a copy of #1028961
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028965 |
Snippet name: | Rewrite DB Web Bot [dev.] |
Eternal ID of this version: | #1028965/24 |
Text MD5: | d6ba93d7ad924d9412c37b14f157644e |
Transpilation MD5: | 325f3d54e496c57c8a5fc2f28e432d4f |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-14 21:51:40 |
Source code size: | 1836 bytes / 69 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 282 / 30417 |
Version history: | 23 change(s) |
Referenced in: | [show references] |