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).

1  
!752
2  
3  
!include #1000850 // TableFinder
4  
5  
static S html(S subUri) {
6  
  L<S> tok = javaTok(subUri);
7  
  int i = matchMeta(tok, "/", "<number>");
8  
  
9  
  // single post
10  
  
11  
  if (i == 1) {
12  
    S postID = "#" + tok.get(3);
13  
    S title = getSnippetTitle(postID);
14  
    ret fromLines(litlist(
15  
      "<h3>" + title + "</h3>",
16  
      "",
17  
      loadSnippet(postID)));
18  
  }
19  
  
20  
  // headlines
21  
  
22  
  L<S> headlines;
23  
  headlines = litlist("Line A", "Headline B", "Headline C");
24  
  pcall { headlines = getLatestHeadlines(); }
25  
  ret join("<br>", headlines);
26  
}
27  
28  
 static L<S> getLatestHeadlines() {
29  
    S html = loadPage("http://tinybrain.de:8080/tb/snippets.php?type=49");
30  
    new TableFinder finder;
31  
    finder.go(html);
32  
    
33  
    new L<S> l;
34  
    for (int i = 1; i < finder.data.size(); i++) {
35  
      L<S> row = finder.getRow(i);
36  
      S title = dropAllTags(row.get(0));
37  
      S id = dropAllTags(row.get(1));
38  
      //S link = "http://tinybrain.de/" + parseSnippetID(id);
39  
      S link = "/" + parseSnippetID(getProgramID()) + "/raw/" + parseSnippetID(id);
40  
      l.add("<a href=" + htmlQuote(link) + ">" + htmlencode(title) + "</a>");
41  
    }
42  
    return l;
43  
  }

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: 512 / 1537
Referenced in: [show references]