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

35
LINES

< > BotCompany Repo | #1003007 - Home Pages Bot

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1738L/11K/38K).

!759

static PersistentMap<S, S> urlToText;

p {
  urlToText = new PersistentMap("urlToText");
}

static synchronized S html(S uri) {
  uri = dropPrefix("/", uri);
  
  if (empty(uri) || eq(uri, "list")) {
    new L<S> list;
    for (S url : keys(urlToText)) {
      list.add(a("/" + url, "href", pageLink(url)));
    }
    ret h3("Pages") + ul(list);
  }
    
  S html = urlToText.get(tlc(uri));
  ret or2(html, "?");
}

static sync boolean hasURL(S bla) {
  ret urlToText.containsKey(tlc(bla));
}

static sync S getTextForURL(S bla) {
  ret urlToText.get(tlc(bla));
}

// returns previous text if any
static sync S setURL(S bla, S text) {
  ret urlToText.put(tlc(bla), text);
}

download  show line numbers  debug dex   

Travelled to 9 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1003007
Snippet name: Home Pages Bot
Eternal ID of this version: #1003007/1
Text MD5: a27bdd444fafe4b3e3f27a2eab66431b
Transpilation MD5: 0fa5e71478d3d7e30a31720f299db9f2
Author: stefan
Category: eleu / internet
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-04-18 17:26:37
Source code size: 713 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 433 / 729
Referenced in: [show references]

Formerly at http://tinybrain.de/1003007 & http://1003007.tinybrain.de