def GET(self): if self.restrict_access(): return web.header("Pragma", "no-cache") web.header("Cache-Control", "no-cache") default_last_time = str(time.time()) input = web.input(search="", page=0, last_time=default_last_time) #web.debug('input time ' + input.last_time) if input.last_time == '0.0': # bah... input.last_time = default_last_time last_words = env.get_last_words(since=input.last_time) last_update = 0 if not input.search: input.search = last_words last_update = env.get_last_update() todisplay = 10 posts_count = 0 start_idx = (input.page - 1) * todisplay + 1 end_idx = min(posts_count, input.page * todisplay) if end_idx >= posts_count: start_idx = posts_count - (posts_count % todisplay) + 1 end_idx = posts_count input.page = posts_count / todisplay + 1 #security issue w/ making request for typed words.. words = input.search.split(' ') words.reverse() for w in words: if not w or not dict.is_word(w): continue #trans = '' # translation(w) # unused for now wrdef = wr_definition(w) # check if english word.. # sound is only in english! #jqreq = """$.get('audio?q=' + encodeURIComponent($(this).attr('href')) + '&d=' + new Date().toUTCString());return false;""" #print '<a href="%s" onclick="%s">%s</a>' % (wrdef.sound, jqreq, wrdef.listen) #print "<br /><br />" #print '<iframe src="http://www.wordreference.com/%s/%s" width="320" height="240"></iframe>' % ('enfr', web.urlquote(input.search)) print render.vocab_results(w, wrdef, last_update) return
def GET(self): if self.restrict_access(): return web.header("Pragma", "no-cache") web.header("Cache-Control", "no-cache") """ options = ['window','code','python','hci','context','khai','andrew'] import random random.shuffle(options) """ input = web.input(last_time='0.0') last_words = env.get_last_words(since=input.last_time) last_words = " ".join(filter(dict.is_word, last_words.split(" "))) if debug: web.debug('update last word: ' + last_words) web.debug('given time: ' + input.last_time) if last_words: print last_words #options[0] # '/?search=' + else: print ''