Uses 911K of libraries. Click here for Pure Java version (5122L/30K).
1 | !7 |
2 | |
3 | cmodule OntologyWebServer > DynPrintLog { |
4 | transient O serveFunction; |
5 | |
6 | start-thread { |
7 | dm_serveHttpFromFunction(8089, serveFunction = func(S uri, SS params) enter { |
8 | uri = dropLeadingOrTrailingSlash(uri); |
9 | if (nempty(uri)) |
10 | ret serveEntity(urldecode(uri), params); |
11 | L l = cast dm_call(dm_ontologyBot(), 'concepts); |
12 | ret h1_title("Ontologyyyy (" + nEntries(l) + ")") |
13 | + renderEntries(l); |
14 | }); |
15 | dm_registerAs('ontologyWebServer); |
16 | } |
17 | |
18 | S renderEntries(L<virtual Entry> entries) { |
19 | ret nlToBr(lines(map(entries, entry -> |
20 | linkEntity(getString a(entry)) + " " + |
21 | spanTitle("Entry ID: " + getString globalID(entry), htmlEncode2((S) call(entry, 'linkPhrase))) + " " + |
22 | linkEntity(getString b(entry))))); |
23 | } |
24 | |
25 | S serveEntity(S entity, SS params) { |
26 | L l = cast dm_call(dm_ontologyBot(), 'searchForAny, entity); |
27 | ret h1_title(ahref("/", "Ontology") + " | Entity: " + htmlEncode2(entity)) |
28 | + (empty(l) ? "Nothing known about " + b(htmlEncode2(entity)) |
29 | : renderEntries(l)); |
30 | } |
31 | |
32 | S linkEntity(S name) { |
33 | ret ahref("/" + urlencode(name), htmlEncode2(name)); |
34 | } |
35 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1023466 |
Snippet name: | Ontology Web Server |
Eternal ID of this version: | #1023466/17 |
Text MD5: | 99803f68ccdb37daddd8846eb043b2e1 |
Transpilation MD5: | 47ba8bfb932999b9f35c9e909c65cbba |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-06-23 19:50:25 |
Source code size: | 1186 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 375 / 932 |
Version history: | 16 change(s) |
Referenced in: | [show references] |