/* appjet:version 0.1 */ var txt,url,res,twits,data={}; txt = request.params.q || 'Home'; url = 'http://search.twitter.com/search.json?lang=en&q='+txt; res = wget(url); twits = eval('twits='+res); data={ query:txt, title:txt||'Home', twits:twits.results } Date.prototype.format=function(){ var a,y,m,d,h,i,s; a='am' y=this.getFullYear() m=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][this.getMonth()] d=this.getDate() h=this.getHours(); if(h>12){h-=12; a='pm';} i=this.getMinutes(); if(i<10) i="0"+i; s=this.getSeconds(); if(s<10) s="0"+s; return d+' '+m+' '+y+' - '+h+':'+i+':'+s+a; } function get_main() { page.setMode('plain') page.setTitle('Twitter Search') print(html(""" <html> <head> <title>Twitter Search</title> <style> body{font:normal 0.9em helvetica,arial,sans-serif; background:url(http://s.twimg.com/a/1273536095/images/themes/theme1/bg.png) center top no-repeat #C0DEED;} h1{width:560px; margin:0px auto;} h3,p{margin:0; padding:0;} p b{background:#FFA;} a{text-decoration:none; color:#44F;} a:hover{text-decoration:underline; color:#00F;} li{list-style-type:none; border-top:1px solid #DDD; padding:6px 0; min-height:60px;} li:hover{background:rgba(240,240,240,0.4);} li img{width:48px; height:48px; float:left; margin:6px 12px 12px 0;} small{color:#AAA; font-size:0.7em;} #hose{width:560px; margin:32px auto; padding:12px; background:white;} #hose{border-radius:8px; -webkit-border-radius:8px; -moz-border-radius:8px;} #hose{box-shadow:1px 1px 5px #333; -webkit-box-shadow:1px 1px 5px #333; -moz-box-shadow:1px 1px 5px #333;} #search{float:right;} #q{width:200px; height:32px; font-size:1.6em; color:#CCC; border:1px solid #CCC;} #q{border-radius:4px; -webkit-border-radius:4px; -moz-border-radius:4px;} #q:focus{color:#000; content:'';} </style> </head> <body> <h1><img src="http://a0.twimg.com/a/1274130900/images/twitter_logo_header.png" /></h1> <div id="hose"> <form id="search" method="get"> <input type="textbox" id="q" name="q" value="search" placeholder="search" onfocus="this.value=''"/> </form>""")) print(H2(data.title)) for(i in data.twits){ print( LI( IMG({src:data.twits[i].profile_image_url}), H3(link("http://twitter.com/"+data.twits[i].from_user,data.twits[i].from_user)), html("<p>"+data.twits[i].text.replace(new RegExp(data.query,'gi'),'<b>'+data.query+'</b>')+"</p>"), SMALL(new Date(data.twits[i].created_at).format()) ) ) } print(html(""" </div> </body> </html> """)) } dispatch()
Go Back to this app | Get plain source