Created
March 21, 2009 20:22
-
-
Save youpy/82968 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* appjet:version 0.1 */ | |
import("lib-text-converter"); | |
import("lib-html-xpath"); | |
import("lib-cache"); | |
function jottit(pageName) { | |
var c = new Cache(); | |
//c.deleteOne(pageName); | |
var data = c.get(pageName); | |
if(typeof data == 'undefined') { | |
var data = new StorableCollection(); | |
try { | |
xget('http://youpy.jottit.com/' + pageName, '//div[@id="content"]//li').div.forEach(function(li) { | |
data.add(new StorableObject({value: li.p})); | |
}); | |
c.set(pageName, data, 60 * 60 * 3); | |
} catch(e) {}; | |
} | |
if(data.size()) { | |
return data.skip(Math.floor(Math.random() * (data.size()))).first().value; | |
} else { | |
return ''; | |
} | |
} | |
function gobi() { | |
return jottit('gobi'); | |
} | |
function prefix() { | |
return jottit('prefix'); | |
} | |
convertText(function(text) { | |
return prefix() + ' ' + text + ' ' + gobi(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment