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

100
LINES

< > BotCompany Repo | #1032188 // gaz.ai [LIVE]

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

Uses 1951K of libraries. Click here for Pure Java version (8888L/68K).

!7

mainPackage gazelle
mainClassName main

module GazAI > GazelleBEA {
  transient long filesObjectID = 270;
  
  /*O html4(Req req) {
    ret hfullcenter(centerGazelleLogo());
  }*/
  
  @Override O serveHomePage_base() {
    new HTMLFramer1 framer;
    framer.title = "Gaz.AI";
    framer.renderTitle = () -> "";
    framer.addInHead(hsansserif());
    framer.add(hfullcenter(
      centerGazelleLogo()
      + p(ahref(baseLink + "/login", "Internal"))
      ));
    ret framer!;
  }
  
  @Override Cl<Class> cruddableClasses(DynGazelleRocks.Req req) {
    ret addAllAndReturnCollection(super.cruddableClasses(req), Settings);
  }

  S authFormMoreContent() {
    printStackTrace();
    ret super.authFormMoreContent();
  }
  
  void init :: after {
    runRefChecker = false;
    botName = heading = adminName = "Gaz.AI";
    showCRUDToEveryone = false;
    showCRUDToNonMasterUsers = true; // TODO: make sure no classes "leak"
    showInputAndPatternNavItems = false;
    set authedDialogIDForEveryCookie;
  }
  
  L<Class> publicCRUDs() {
    ret ll(UploadedImage.class, UploadedSound.class);
  }
  
  // put the public CRUDs here but make sure to filter them in
  // the next method!
  @Override L<Class> crudClasses(DynGazelleRocks.Req req) {
    if (!masterAuthed(req))
      ret publicCRUDs();
    else
      ret super.crudClasses(req);
  }
  
  @Override MapSO filtersForClass(Class c, DynGazelleRocks.Req req) {
    if (!masterAuthed(req) && contains(publicCRUDs(), c))
      ret litmap(user := user(req));
    ret super.filtersForClass(c, req);
  }
  
  O serve404Page() {
    if (startsWith(currentReq().uri, "/crud/"))
      ret hredirect(baseLink + "/login");
    else
      ret subBot_serve404("Resource not found, please try the " + ahref("/", "home page"));
  }
  
  @Override O serveDefaultPage(DynGazelleRocks.Req req) {
    if (ewicOneOf(req.uri(), ".css", ".js"))
      ret serve404Page();
      
    if (eqicOneOf(req.uri(), "/gazelle.jar", "/webhook"))
      ret eleu_callModuleHTMLMethod("gazAiHomePage", req);
      //ret subBot_serveRedirect("https://ultrafast.gaz.ai" + req.uri());
      
    S uri = replacePrefix("/kb/", "/", req.uri());
    ret hrefresh(addParamsToURL("https://gazelle.rocks/kb" + uri, req.params());
  }
  
  @Override O serveOtherPage2(Req req) {
    new Matches m;
    S uri = req.uri();

    if (startsWith(uri, "/files/", m)) {
      req.subURI = m.rest();
      ret beaCall(filesObjectID, "html", req);
    }
    ret super.serveOtherPage2(req);
  }
  
  void makeNavItems_base(DynGazelleRocks.Req req, HTMLFramer1 framer) {
    super.makeNavItems_base(req, framer);
    
    if (isMasterAuthed(req))
      framer.addNavItem(ahref("https://vnc.gaz.ai", "VNC"));
  }
}

!include early #1031418 // Gazelle BEA

Author comment

Began life as a copy of #1031945

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032188
Snippet name: gaz.ai [LIVE]
Eternal ID of this version: #1032188/45
Text MD5: 407fcdf158f7e61a1e58d5ada913ae07
Transpilation MD5: 2f647e3b79f7ae3bbc3dc8a69c14edec
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-02-19 00:52:52
Source code size: 2860 bytes / 100 lines
Pitched / IR pitched: No / No
Views / Downloads: 463 / 172370
Version history: 44 change(s)
Referenced in: [show references]