@ -14,7 +14,7 @@ def folders (_path,_config):
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    """ 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    _content  =  os . listdir ( _path )         
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    return  [ _name  for  _name  in  _content  if  os . path . isdir ( os . sep . join ( [ _path , _name ] ) )  if  not  _name . startswith ( ' _ ' ) ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					def  content ( _folder , _config  ): 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					def  content ( _folder , _config ,keep = [ ]  ): 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    """ 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    : content  of  the  folder 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    """ 
 
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -29,13 +29,13 @@ def content(_folder,_config):
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        _menuItems  =  list_files ( _folder , _config )  #os.listdir(_folder) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        # return [{'text':_name.split('.')[0].replace('_', ' ').replace('-',' ').strip(),'uri': os.sep.join([_folder,_name])} for _name in os.listdir(_folder) if not _name.startswith('_') and os.path.isfile( os.sep.join([_folder,_name]))] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        return  [ { ' text ' : _name . split ( ' . ' ) [ 0 ] . replace ( ' _ ' ,  '   ' ) . replace ( ' - ' , '   ' ) . strip ( ) , ' uri ' :  os . sep . join ( [ _path , _name ] ) }  for  _name  in  os . listdir ( _folder )  if  not  _name [ 0 ]  in  [ ' . ' , ' _ ' ]  and  os . path . isfile (  os . sep . join ( [ _folder , _name ] ) ) ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        return  [ { ' text ' : _name . split ( ' . ' ) [ 0 ] . replace ( ' _ ' ,  '   ' ) . replace ( ' - ' , '   ' ) . strip ( ) , ' uri ' :  os . sep . join ( [ _path , _name ] ) }  for  _name  in  os . listdir ( _folder )  if  not  _name [ 0 ]  in  [ ' . ' , ' _ ' ]  and  os . path . isfile (  os . sep . join ( [ _folder , _name ] ) )  and  _name . split ( ' . ' ) [ - 1 ]  in  [ ' html ' , ' md ' ]  ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    else : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        return  [ ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					def  list_files ( _folder , _config  ): 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					def  list_files ( _folder , _config , keep = [ ]  ): 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    return  [ name  for  name  in  os . listdir ( _folder )  if  name [ 0 ]  not  in  [ ' . ' , ' _ ' ] ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					def  build  ( _config  ):  #(_path,_content): 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					def  build  ( _config , keep = [ ]  ):  #(_path,_content): 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    """ 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    building  the  menu  for  the  site  given  the  content  is  on  disk 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    : path   path  of  the  files  on  disk 
 
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -48,6 +48,7 @@ def build (_config): #(_path,_content):
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    # print (_path) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    _items  =  folders ( _path , _config ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    _subItems  =  [  content  ( os . sep . join ( [ _path , _name ] ) , _config ) for  _name  in  _items   ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    _r  =  { } 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    for  _name  in  _items  : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        _index  =  _items . index ( _name ) 
 
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				 
				
					@ -85,7 +86,6 @@ def read (**_args):
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    _uri  =  request . args [ ' uri ' ]     # if 'location' in _layout : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    #     _uri = os.sep.join([_layout['location'],_uri]) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    _uri  =  _realpath ( _uri ,  _args [ ' config ' ] ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    if  os . path . exists ( _uri ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        f  =  open ( _uri , mode = ' rb ' ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        _stream  =  f . read ( ) 
 
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -103,12 +103,15 @@ def exists(**_args):
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					def  html ( _uri , _config )  : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    # _html = (open(uri)).read()    
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    _path  =  _realpath ( _uri , _config )  
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    _context  =  _config [ ' system ' ] [ ' context ' ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    _html  =  (  open ( _path ) ) . read ( ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    _layout  =  _config [ ' layout ' ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    if  ' location '  in  _layout  : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if  not  _config  : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            _api  =  os . sep . join ( [ ' api/disk/read?uri= ' , _layout [ ' root ' ] ] ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        else : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            _api  =  os . sep . join ( [ f ' { _context } /api/disk/read?uri= ' , _layout [ ' root ' ] ] ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        _html  =  _html . replace ( _layout [ ' root ' ] , _api ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    _html  =  markdown ( _html )  if  _uri [ - 2 : ]  in  [ ' md ' , ' MD ' , ' Md ' , ' mD ' ]  else  _html 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    return  _html 
 
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				 
				
					@ -118,15 +121,23 @@ def plugins (**_args):
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    : path    path  of  the  files 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    : name    name  of  the  module 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    """ 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    _context  =  _args [ ' context ' ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    if  ' path '  not  in  _args  : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        return  { ' api/disk/read ' : read } 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        key  =  ' api/disk/read ' 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if  _context  : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            key  =  f ' { _context } / { key } ' 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        return  { key : read } 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    _path  =  _args [ ' path ' ]  #os.sep.join([_args['root'],'plugin'])         
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					    if  os . path . isdir ( _path ) : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        files  =  os . listdir ( _path ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        if  files  : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            files  =  [ name  for  name  in  files  if  name . endswith ( ' .py ' ) ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            if  files : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                _path  =  os . sep . join ( [ _path , files [ 0 ] ] ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                _uri  =  [ _path , files [ 0 ] ] 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                if  _context  : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                    _uri  =  [ _context ]  +  _uri 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                _path  =  os . sep . join ( _uri ) 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					            else : 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					                return  None 
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				 
				
					        else :