Skip to content

Instantly share code, notes, and snippets.

@youpy
Created March 21, 2009 20:22
Show Gist options
  • Save youpy/82968 to your computer and use it in GitHub Desktop.
Save youpy/82968 to your computer and use it in GitHub Desktop.
/* 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