web/hgbook/comments/views.py~
changeset 1 672eaaab9204
parent 0 8083d21c0020
equal deleted inserted replaced
0:8083d21c0020 1:672eaaab9204
     8 from django.template.loader import get_template
     8 from django.template.loader import get_template
     9 from django.utils.simplejson import dumps 
     9 from django.utils.simplejson import dumps 
    10 from p_list import *
    10 from p_list import *
    11 from BeautifulSoup import BeautifulSoup
    11 from BeautifulSoup import BeautifulSoup
    12 import glob
    12 import glob
    13 html_folder='/home/amit/hgbook-alqua/web/html/'
    13 html_folder='/home/amit/SEES-hacks/web/html'
    14 
    14 
    15 def sort_dict(dict):
    15 def sort_dict(dict):
    16 	new_dict = {}
    16 	new_dict = {}
    17 	sorted_keys = dict.keys()
    17 	sorted_keys = dict.keys()
    18 	sorted_keys.sort()
    18 	sorted_keys.sort()
    47 	print request
    47 	print request
    48 
    48 
    49 
    49 
    50 def index(request):
    50 def index(request):
    51 	html_files = glob.glob(html_folder+'ch*.html')
    51 	html_files = glob.glob(html_folder+'ch*.html')
    52 #	print >> sys.stderr , html_files	
    52 	print >> sys.stderr ,html_files	
       
    53 	print >> sys.stderr ,"just checking whether i got here"	
       
    54 	print >> sys.stderr , html_files	
    53 	html_files.sort()
    55 	html_files.sort()
    54 	link_list=['/review/html/'+a.split('/')[-1] for a in html_file]
    56 	link_list=['/review/html/'+a.split('/')[-1] for a in html_files]
    55 #	print >> sys.stderr , html_files        
    57 #	print >> sys.stderr , html_files        
    56 	title_list=[]
    58 	title_list=[]
    57 	for html_file in html_files:
    59 	for html_file in html_files:
    58 		file_str=open(html_file,'r').read()			
    60 		file_str=open(html_file,'r').read()			
    59 		soup_obj=BeautifulSoup(''.join(file_str))
    61 		soup_obj=BeautifulSoup(''.join(file_str))
    61 		title_str=unicode(title_str)		
    63 		title_str=unicode(title_str)		
    62 		title_str.encode('ascii','ignore')              
    64 		title_str.encode('ascii','ignore')              
    63 		title_list.append(title_str)
    65 		title_list.append(title_str)
    64 	
    66 	
    65 	resp_dict=zip(link_list,title_list)
    67 	resp_dict=zip(link_list,title_list)
    66 	
    68 	print >>sys.stderr ,resp_dict
    67 	return render_to_response('index.html', {'resp_dict': resp_dict })
    69 	return render_to_response('index.html', {'resp_dict': resp_dict })
    68 
    70 
    69 
    71 
    70 
    72 
    71 
    73