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

43
LINES

< > BotCompany Repo | #1002007 // Blog Headlines Bot

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

Libraryless. Click here for Pure Java version (1596L/11K/34K).

!752

!include #1000850 // TableFinder

static S html(S subUri) {
  L<S> tok = javaTok(subUri);
  int i = matchMeta(tok, "/", "<number>");
  
  // single post
  
  if (i == 1) {
    S postID = "#" + tok.get(3);
    S title = getSnippetTitle(postID);
    ret fromLines(litlist(
      "<h3>" + title + "</h3>",
      "",
      loadSnippet(postID)));
  }
  
  // headlines
  
  L<S> headlines;
  headlines = litlist("Line A", "Headline B", "Headline C");
  pcall { headlines = getLatestHeadlines(); }
  ret join("<br>", headlines);
}

 static L<S> getLatestHeadlines() {
    S html = loadPage("http://tinybrain.de:8080/tb/snippets.php?type=49");
    new TableFinder finder;
    finder.go(html);
    
    new L<S> l;
    for (int i = 1; i < finder.data.size(); i++) {
      L<S> row = finder.getRow(i);
      S title = dropAllTags(row.get(0));
      S id = dropAllTags(row.get(1));
      //S link = "http://tinybrain.de/" + parseSnippetID(id);
      S link = "/" + parseSnippetID(getProgramID()) + "/raw/" + parseSnippetID(id);
      l.add("<a href=" + htmlQuote(link) + ">" + htmlencode(title) + "</a>");
    }
    return l;
  }

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002007
Snippet name: Blog Headlines Bot
Eternal ID of this version: #1002007/1
Text MD5: efb98d999b3f2c91666fd43e855d17a0
Transpilation MD5: d9a8b41c2a422ecde6aaea1baef54350
Author: stefan
Category: javax html
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-13 17:40:51
Source code size: 1167 bytes / 43 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 573 / 1627
Referenced in: [show references]