@@ -85,11 +85,12 @@ def genIndex(path,dirs,files,htmlTemp = HTML):
85
85
#<hr>\n<span style="color:orange;text-align:center;">Read Me</span>\n<hr>\n
86
86
md = '\n <h1 style="color:red;text-align:center;">Read Me</h1>\n ' + f .read ()
87
87
cur = getPath (path )
88
- dirLst = genDirectoryList (path ,dirs )
89
- fileLst = genFileList (path ,files )
90
- cont = htmlTemp .format (DOWNLOAD = DOWNLOAD + path ,cur = cur ,dirLst = dirLst ,fileLst = fileLst ,readme = md2html (md ))
91
88
tar = os .path .join (TARDIR ,path )
92
89
if not os .path .exists (tar ):os .mkdir (tar )
90
+
91
+ dirLst = genDirectoryList (path ,dirs )
92
+ fileLst = genFileList (path ,files ,tar )
93
+ cont = htmlTemp .format (DOWNLOAD = DOWNLOAD + path ,cur = cur ,dirLst = dirLst ,fileLst = fileLst ,readme = md2html (md ))
93
94
filename = os .path .join (tar , NAME )
94
95
with open (filename ,'w' ) as f :
95
96
f .write (cont )
@@ -106,10 +107,16 @@ def getPath(path):
106
107
return '/' .join (res [::- 1 ])
107
108
108
109
LIITEM = '<li><a href="{path}"><i class="fa fa-{icon}"></i> {name}</a></li>'
109
- def genFileList (path ,files ):
110
- keys = [i for i in files if i [0 ]!= '.' ]
111
- link = {i :os .path .join (path ,i ) for i in keys }
112
- lst = [LIITEM .format (icon = getIcon (key ),name = key + '---({})' .format (getSize (link [key ])),path = os .path .join (PATH ,link [key ])) for key in keys ]
110
+ def genFileList (path ,files ,tar = TARDIR ):
111
+ files = [i for i in files if not i .startswith ('.' )]
112
+ link = {}
113
+ for k in files :
114
+ if k .endswith ('.md' ):
115
+ shutil .copy (os .path .join (path ,k ),tar )
116
+ link [k ] = k [:- 3 ] + '.html'
117
+ else :
118
+ link [k ] = os .path .join (PATH ,path ,k )
119
+ lst = [LIITEM .format (icon = getIcon (key ),name = key + '---({})' .format (getSize (os .path .join (path ,key ))),path = link [key ]) for key in files ]
113
120
if lst == []: lst .append ('<li><i class="fa fa-meh-o"></i> None</li>' )
114
121
return '\n ' .join (lst )
115
122
0 commit comments