def mobileIndexLang(request,LANG='en'): RangeList=wikilib.fnRangeCount(5) DAY, MONTH, YEAR, HOUR,expiretime,MONTHNAME = fnReturnTimes() request.encoding='iso-8859-1' MONTHNAME=fnCaseMonthName(MONTH) t=get_template('MobileIndexI18.html') title='' archive_list=[] PLACE=1 REDIS_ID_KEY=str(LANG)+'_'+str(PLACE)+'_'+'ID' rc=redis.Redis('localhost') mcVAR=str(LANG)+"_THREEHOUR" SITENAME=getSiteName(LANG) LANGSUB=LANG[0:2] 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) if str(LANG)=='commons.m': LANGSUB='commons' for p in THREEHOUR_LIST_QUERY: tstr=str(p['title']) rec={'title':urllib2.unquote(tstr),'place':p['place'],'Avg':p['rollavg'],'linktitle':p['title'],'id':p['id'],'LANG':LANG,'LANGSUB':LANGSUB,'SITENAME':SITENAME} 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) SITENAME=getSitename(LANG) LANGSUB=LANG[0:2] if 'commons' in LANG: LANGSUB='commons' rec={'LANGSUB':LANGSUB,'SITENAME':SITENAME,'title':urllib2.unquote(tstr),'place':PLACE,'Avg':aAVG,'linktitle':aLINKTITLE,'id':aID,'LANG':str(LANG)} send_list.append(rec) PLACE+=1 REDIS_ID_KEY=str(LANG)+'_'+str(PLACE)+'_ID' artID=rc.get(REDIS_ID_KEY) PAGETITLE=str(wikilib.fnReturnLanguageName(LANG)) PAGEDATE=str(MONTHNAME)+" "+str(DAY)+" "+str(YEAR) c=Context({'PageDate':PAGEDATE,'RangeList':RangeList,'latest_hits_list':send_list,'PageTitle':PAGETITLE,'expiretime':expiretime,'archive_list':archive_list,'LANGUAGE':LANG}) 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))
def MobileLanguageList(request,LANG='en'): t=get_template('MobileLangList.html') LANGLIST=wikilib.getLanguageList() DAY, MONTH, YEAR, HOUR,expiretime,MONTHNAME = fnReturnTimes() PAGEDATE=str(MONTHNAME)+" "+str(DAY)+" "+str(YEAR) send_list=[] for lang in LANGLIST: PAGETITLE=str(wikilib.fnReturnLanguageName(lang)) record={'LANG':str(lang),'title':PAGETITLE} send_list.append(record) PAGETITLE="Languages" c=Context({'PageDate':PAGEDATE,'PageTitle':PAGETITLE,'expiretime':expiretime,'language_list':send_list}) rendered=t.render(c) return HttpResponse(rendered)