@ -1,10 +1,9 @@
 
		
	
		
			
				import  datetime ,  os ,  re  
		
	
		
			
				from  bottle  import  error ,  route ,  run ,  static_file ,  template  
		
	
		
			
				from  bottle  import  error ,  route ,  run ,  static_file ,  template ,  TEMPLATE_PATH  
		
	
		
			
				
 
		
	
		
			
				loc  =  ' diary/ entries/'  
		
	
		
			
				loc  =  ' '  
		
	
		
			
				
 
		
	
		
			
				def  list_headlines ( articles ) :  
		
	
		
			
				    head  =  count_lines ( loc  +  ' raw/res/head.txt ' ) 
 
		
	
		
			
				    result  =  [ ] 
 
		
	
		
			
				    text  =  [ ] 
 
		
	
		
			
				
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -16,15 +15,19 @@ def list_headlines(articles):
 
		
	
		
			
				
 
		
	
		
			
				        b  =  [ ] 
 
		
	
		
			
				        b . append ( path ) 
 
		
	
		
			
				        b . append ( clean ( text [ head ] . replace ( ' <br> ' , ' ' ) ) ) 
 
		
	
		
			
				        b . append ( clean ( text [ 0 ] . replace ( ' <br> ' , ' ' ) ) ) 
 
		
	
		
			
				        result . append ( b ) 
 
		
	
		
			
				    return  result 
 
		
	
		
			
				
 
		
	
		
			
				def  retrieve_article ( page ) :  
		
	
		
			
				    text  =  [ ] 
 
		
	
		
			
				    with  open ( loc  +  page )  as  f : 
 
		
	
		
			
				            text  =  f . readlines ( ) 
 
		
	
		
			
				    return  text 
 
		
	
		
			
				
 
		
	
		
			
				def  list_snippets ( articles ) :  
		
	
		
			
				    limit  =  4 
 
		
	
		
			
				    total  =  len ( articles ) 
 
		
	
		
			
				    head  =  count_lines ( loc  +  ' raw/res/head.txt ' ) 
 
		
	
		
			
				    tail  =  count_lines ( loc  +  ' raw/res/tail.txt ' ) 
 
		
	
		
			
				    result  =  [ ] 
 
		
	
		
			
				
 
		
	
		
			
				    for  article  in  articles : 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -35,15 +38,15 @@ def list_snippets(articles):
 
		
	
		
			
				        with  open ( loc  +  article )  as  f : 
 
		
	
		
			
				            text  =  f . readlines ( ) 
 
		
	
		
			
				            length  =  len ( text ) 
 
		
	
		
			
				        a . append ( clean ( text [ head ] ) )  # title 
 
		
	
		
			
				        content  =  snip_article ( find_content ( article ,  length , head ,  tail  ),  path ) 
 
		
	
		
			
				        a . append ( clean ( text [ 0 ] ) )  # title 
 
		
	
		
			
				        content  =  snip_article ( find_content ( article ,  length ,  path ) 
 
		
	
		
			
				
 
		
	
		
			
				        if  content . count ( ' <ul> ' )  >  content . count ( ' </ul> ' ) : 
 
		
	
		
			
				            content  + =  ' </ul> ' 
 
		
	
		
			
				        a . append ( content )  # snippet 
 
		
	
		
			
				        a . append ( text [ head  +  1 ] . replace ( ' <br> ' , ' ' ) )  # timestamp 
 
		
	
		
			
				        a . append ( text [ 1 ] . replace ( ' <br> ' , ' ' ) )  # timestamp 
 
		
	
		
			
				        a . append ( ' / '  +  path . replace ( ' .tpl ' , ' ' ) )  # URL 
 
		
	
		
			
				        a . append ( clean ( text [ head ] ) . replace ( '   ' , ' + ' ) )  # social media title 
 
		
	
		
			
				        a . append ( clean ( text [ 0 ] ) . replace ( '   ' , ' + ' ) )  # social media title 
 
		
	
		
			
				        result . append ( a ) 
 
		
	
		
			
				    return  result 
 
		
	
		
			
				
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -53,11 +56,11 @@ def count_lines(fname):
 
		
	
		
			
				            pass 
 
		
	
		
			
				    return  linenum 
 
		
	
		
			
				
 
		
	
		
			
				def  find_content ( article ,  length , head ,  tail  ):  
		
	
		
			
				def  find_content ( article ,  length :  
		
	
		
			
				    content  =  " " 
 
		
	
		
			
				    with  open ( loc  +  article )  as  f : 
 
		
	
		
			
				        for  pos ,  line  in  enumerate ( f ) : 
 
		
	
		
			
				            if  pos  >  head  +  1  and  pos  <  length  -  tail  : 
 
		
	
		
			
				            if  pos  >  1  and  pos  <  length : 
 
		
	
		
			
				                content  + =  line 
 
		
	
		
			
				    return  content 
 
		
	
		
			
				
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -131,11 +134,16 @@ def diary(page):
 
		
	
		
			
				    info  =  { ' css ' :  ' diary ' ,  ' title ' :  ' blessfrey - developer diary ' ,  ' year ' :  datetime . datetime . now ( ) ,  ' snippets ' :  list_snippets ( sort_files ( gather_files ( ) ) ) ,  ' latest ' :  list_headlines ( sort_files ( gather_files ( ) ) [ 0 : 5 ] ) ,  ' total ' :  len ( gather_files ( ) ) ,  ' limit ' :  4 ,  ' cluster ' :  3 ,  ' page ' :  page } 
 
		
	
		
			
				    return  template ( ' diary.tpl ' ,  info ) 
 
		
	
		
			
				
 
		
	
		
			
				@route ( ' diary /entries/<page>' )  
		
	
		
			
				@route ( ' :int >' )  
		
	
		
			
				def  entry ( page ) :  
		
	
		
			
				    """ diary entry """ 
 
		
	
		
			
				    info  =  { ' css ' :  ' diary ' ,  ' title ' :  ' blessfrey - developer diary ' ,  ' year ' :  datetime . datetime . now ( ) ,  ' latest ' :  list_headlines ( sort_files ( gather_files ( ) ) [ 0 : 5 ] ) ,  ' page ' :  page } 
 
		
	
		
			
				    return  template ( ' feature.tpl ' ,  info ) 
 
		
	
		
			
				    info  =  { ' css ' :  ' box ' ,  ' title ' :  ' blessfrey - credits ' ,  ' year ' :  datetime . datetime . now ( ) } 
 
		
	
		
			
				    abs_app_dir_path  =  os . path . dirname ( os . path . realpath ( __file__ ) ) 
 
		
	
		
			
				    abs_views_path  =  os . path . join ( abs_app_dir_path ,  ' views ' ) 
 
		
	
		
			
				    TEMPLATE_PATH . insert ( 0 ,  abs_views_path  ) 
 
		
	
		
			
				    return  template ( os . path . join ( abs_views_path , ' contact.tpl ' ) ,  info ) 
 
		
	
		
			
				#    """diary entry"""  
		
	
		
			
				#    info = {'css': 'diary', 'title': 'blessfrey - developer diary', 'year': datetime.datetime.now(), 'entry': retrieve_article(page), 'latest': list_headlines(sort_files(gather_files())[0:5]), 'page': page}  
		
	
		
			
				#    return template('feature.tpl', info)  
		
	
		
			
				
 
		
	
		
			
				@route ( ' /box ' )  
		
	
		
			
				def  box ( ) :