1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
/* 
 * Locale stuff. 
 * <locale-token project="roxen_config"> _ </locale-token> 
 */ 
#include <roxen.h> 
#define _(X,Y)      _DEF_LOCALE("roxen_config",X,Y) 
 
constant box      = "large"; 
constant box_initial = 0; 
 
String box_name = _(398,"Todays MegaTokyo comic"); 
String box_doc  = _(399,"Todays comic from MegaTokyo"); 
 
 
/* And here we go. :-) */ 
 
string parse( RequestID id ) 
{ 
  string data; 
  string contents = ""; 
 
  if( !(data = .Box.get_http_data("www.megatokyo.com",80,"GET / HTTP/1.0" ) )) 
    contents = "Fetching data from megatokyo..."; 
  else 
  { 
    string img; 
    string rant, status; 
 
    sscanf( data, "%*s\"strips/%s.gif\"", img ); 
    sscanf( data, "%*s<!--%*sstuff you%*s - start -->%s<!--", status ); 
 
    sscanf( data, 
            "%*s<!-- n e w s r a n t    c o m e n t -->" 
            "%s" 
            "<!-- comments area ends here for PIRO-->", 
            rant ); 
 
    array st = status/"<br>"; 
    string tmp; 
    status = "<font size=-1>"; 
    if( sizeof( st ) > 4 ) 
    { 
      sscanf( st[0], "%*s>\n%s", tmp ); 
      status += tmp +"<br />due "+ st[1]+ " ("; 
      sscanf( st[2], "%*s%[0-9]%% done", tmp ); 
      status += tmp+"% done)<br />\n"; 
      status += "<i>"+st[3]+"</i><br />"; 
      for( int i = 4; i<sizeof(st); i++ ) 
        status += (st[i]/"</font")[0]+"<br />"; 
 
      status = "<cimg format=png src='/internal-roxen-pixel-orange' " 
        "     scale='"+(int)(2.8*(int)tmp)+",12'/>" 
        "<cimg format=png src='/internal-roxen-pixel-black' " 
        "     scale='"+(int)(280-(2.5*(int)tmp))+",12' />" 
        "<br />"+status; 
    } 
    status += "</font>"; 
 
    contents  = 
      "<a href='http://www.megatokyo.com/'>" 
      "<center><cimg format=png border=0 max-width=390 " 
      "src='http://www.megatokyo.com/strips/"+img+".gif' /></center>" 
      "</a><br /><b>Next strip:</b>"+status; 
//     werror( data ); 
  } 
 
  return ("<box type='"+box+"' title='"+box_name+"'>"+contents+"</box>"); 
}