def listLastHour(request): tw_timeline=GetTimeline() t=get_template('IndexListLast.html') latest_news_list=wikilib.fnLatestnews() send_list=[] send_list=mc.get('HOURKEY') c=Context({'latest_hits_list':send_list,'latest_news_list':latest_news_list,'MONTHNAME':MONTHNAME,'y':YEAR,'m':MONTH,'d':DAY,'tw_timeline':tw_timeline,'latest_news_list':latest_news_list}) rendered=t.render(c) return HttpResponse(rendered)
def indexLang(request,LANG='en'): DAY, MONTH, YEAR, HOUR,expiretime,MONTHNAME = fnReturnTimes() try: #keep if function called programmatically request.encoding='iso-8859-1' except: pass MONTHNAME=fnCaseMonthName(MONTH) LATEST_NEWS_LIST=wikilib.fnLatestnews() tw_timeline=GetTimeline() archive_list=[] PLACE=1 REDIS_ID_KEY=str(LANG)+'_'+str(PLACE)+'_'+'ID' rc=redis.Redis('localhost') send_list=[] try: aTITLE=str(rc.get(REDIS_ID_KEY)) artID=aTITLE except: aTITLE='None' if aTITLE=='None' or aTITLE=='': COLLNAME=str(LANG)+"_threehour" THREEHOUR_LIST_QUERY=db[COLLNAME].find().sort('place',1) LANGSUB=LANG[0:2] if str(LANG)=='commons.m': LANGSUB='commons' for p in THREEHOUR_LIST_QUERY: tstr=str(p['title']) rec={'title':p['title'],'place':p['place'],'Avg':p['rollavg'],'linktitle':urllib.quote(p['title']),'id':p['id'],'LANG':LANG,'LANGSUB':LANGSUB} send_list.append(rec) PLACE+=1 else: rc.set(REDIS_ID_KEY,str(aTITLE)) send_list=[] PLACE=1 while artID!="None" and artID!='' and PLACE<100: REDIS_TITLE_KEY=str(LANG)+'_'+str(artID)+'_'+'TITLE' REDIS_AVG_KEY=str(LANG)+'_'+str(artID)+'_'+'AVG' REDIS_LINKTITLE_KEY=str(LANG)+'_'+str(artID)+'_'+'LINKTITLE' aaTITLE=rc.get(REDIS_TITLE_KEY) aAVG=rc.get(REDIS_AVG_KEY) aLINKTITLE=rc.get(REDIS_LINKTITLE_KEY) aID=rc.get(REDIS_ID_KEY) tstr=str(aaTITLE) rec={'title':urllib2.unquote(tstr),'place':PLACE,'Avg':aAVG,'linktitle':aLINKTITLE,'id':aID,'LANG':str(LANG)} send_list.append(rec) rc.set(REDIS_TITLE_KEY,aaTITLE) rc.set(REDIS_AVG_KEY,aAVG) rc.set(REDIS_LINKTITLE_KEY,aLINKTITLE) rc.set(REDIS_ID_KEY,aID) PLACE+=1 REDIS_ID_KEY=str(LANG)+'_'+str(PLACE)+'_ID' artID=rc.get(REDIS_ID_KEY) PAGETITLE="Top "+str(wikilib.fnReturnLanguageName(LANG))+" pages for "+str(MONTHNAME)+" "+str(DAY)+", "+str(YEAR) DATADICTIONARY = {'latest_hits_list':send_list,'latest_news_list':LATEST_NEWS_LIST,'PageTitle':PAGETITLE,'PageDesc':'By three hour rolling average, find the most trending articles at this hour, compared to yesterday. Updated hourly around 20 past!','expiretime':expiretime,'tw_timeline':tw_timeline,'archive_list':archive_list,'LANGUAGE':LANG} return render_to_response('RedTieIndexI18.html',DATADICTIONARY,context_instance=RequestContext(request))