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

35
LINES

< > BotCompany Repo | #1023466 // Ontology Web Server

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (5122L/30K).

!7

cmodule OntologyWebServer > DynPrintLog {
  transient O serveFunction;
  
  start-thread {
    dm_serveHttpFromFunction(8089, serveFunction = func(S uri, SS params) enter {
      uri = dropLeadingOrTrailingSlash(uri);
      if (nempty(uri))
        ret serveEntity(urldecode(uri), params);
      L l = cast dm_call(dm_ontologyBot(), 'concepts);
      ret h1_title("Ontologyyyy (" + nEntries(l) + ")")
        + renderEntries(l);
    });
    dm_registerAs('ontologyWebServer);
  }
  
  S renderEntries(L<virtual Entry> entries) {
    ret nlToBr(lines(map(entries, entry ->
      linkEntity(getString a(entry)) + " " +
      spanTitle("Entry ID: " + getString globalID(entry), htmlEncode2((S) call(entry, 'linkPhrase))) + " " +
      linkEntity(getString b(entry)))));
  }
  
  S serveEntity(S entity, SS params) {
    L l = cast dm_call(dm_ontologyBot(), 'searchForAny, entity);
    ret h1_title(ahref("/", "Ontology") + " | Entity: " + htmlEncode2(entity))
      + (empty(l) ? "Nothing known about " + b(htmlEncode2(entity))
        : renderEntries(l));
  }
  
  S linkEntity(S name) {
    ret ahref("/" + urlencode(name), htmlEncode2(name));
  }
}

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: 371 / 926
Version history: 16 change(s)
Referenced in: [show references]