refurbished css for webpage generator
This commit is contained in:
@@ -12,7 +12,7 @@ def get_options():
|
||||
action = "store_false",
|
||||
dest = "move",
|
||||
default = True,
|
||||
help = "Copy file instead of copying",
|
||||
help = "Copy file instead of moving",
|
||||
)
|
||||
parser.add_argument(
|
||||
'-d',
|
||||
@@ -112,10 +112,7 @@ if __name__ == "__main__":
|
||||
else:
|
||||
new_name = get_version_name(opts.file)
|
||||
if not opts.quiet:
|
||||
print("%s -> %s"%(
|
||||
opts.file,
|
||||
new_name
|
||||
))
|
||||
print(new_name)
|
||||
test_existing(new_name, opts.force)
|
||||
if opts.move:
|
||||
os.rename(opts.file, new_name)
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
import os,sys,time
|
||||
import urllib
|
||||
VERSION="20160116"
|
||||
|
||||
VERSION = "20181206"
|
||||
IMAGE_EXTENSIONS = ['png', 'gif', 'jpg', 'jpeg', 'tif', 'tiff']
|
||||
|
||||
def setup():
|
||||
@@ -27,6 +28,7 @@ def setup():
|
||||
parser.add_argument("--version",action='version', version=VERSION)
|
||||
parser.add_argument("path",type=str,action="store",default=os.path.abspath('.'),nargs='?',
|
||||
help="Root path of the index")
|
||||
|
||||
options = parser.parse_args()
|
||||
options.path = os.path.abspath(options.path)
|
||||
if options.title == None:
|
||||
@@ -97,15 +99,28 @@ def get_filelink(path,fname,images=False):
|
||||
fname_str = get_imagestr(fname)
|
||||
else:
|
||||
fname_str = fname
|
||||
return '<tr><td><a href="'+urllib.quote(fname)+'">'+fname_str+'</a><td class="right">'+fsstr+'</td><td class="right bytes">'+fsstrb+'</td><td class="right">'+fdstr+'</td></tr>\n'
|
||||
return '<tr><td><a class="link_file" href="%s">%s</a><td class="right">%s</td><td class="right bytes">%s</td><td class="right">%s</td></tr>\n'%(
|
||||
urllib.quote(fname),
|
||||
fname_str,
|
||||
fsstr,
|
||||
fsstrb,
|
||||
fdstr
|
||||
)
|
||||
|
||||
def get_imagestr(fname):
|
||||
return '<img src="'+urllib.quote(fname)+'" title="'+fname+'"/>'
|
||||
return '<img src="%s" title="%s"/>'%(
|
||||
urllib.quote(fname),
|
||||
fname
|
||||
)
|
||||
|
||||
def get_pathlink(path,dname):
|
||||
fdate = time.localtime(os.path.getmtime(os.path.join(path, dname)))
|
||||
fdstr = time.strftime("%Y/%m/%d %H:%M:%S", fdate)
|
||||
return '<tr><td><a href="'+urllib.quote(dname)+'">'+dname+'</a><td class="right">[DIR]</td><td class="right bytes">0</td><td class="right">'+fdstr+'</td></tr>\n'
|
||||
return '<tr><td><a class="link_dir" href="%s">↳ %s/</a><td class="right">[DIR]</td><td class="right bytes">0</td><td class="right">%s</td></tr>\n'%(
|
||||
urllib.quote(dname),
|
||||
dname,
|
||||
fdstr
|
||||
)
|
||||
|
||||
def get_header(opts):
|
||||
header='''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
@@ -114,21 +129,71 @@ def get_header(opts):
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="generator" content="SimpleWebPage ''' + VERSION + '''" />
|
||||
''' + setup2HTML(opts) + '''
|
||||
<title>Index of '''+opts.title+'''</title>
|
||||
<title>''' + opts.title + '''</title>
|
||||
<style>
|
||||
* {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
body {
|
||||
font-family: monospace;
|
||||
color: #222;
|
||||
font: 14px monospace;
|
||||
padding: 20px;
|
||||
background: #CCC;
|
||||
}
|
||||
h1 {
|
||||
text-align: center;
|
||||
padding: 20px 0 12px 0;
|
||||
margin: 0;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
.container {
|
||||
box-shadow: 0 5px 10px -5px rgba(0,0,0,0.5);
|
||||
position: relative;
|
||||
background: #eee;
|
||||
}
|
||||
table {
|
||||
background-color: gray;
|
||||
background-color: #F3F3F3;
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
margin: 15px 0;
|
||||
}
|
||||
td, th {
|
||||
text-align: left;
|
||||
background-color: lightgray;
|
||||
padding: 0.5ex;
|
||||
th {
|
||||
background-color: #EB6000;
|
||||
color: #FFF;
|
||||
cursor: pointer;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
td {
|
||||
padding-right: 5px;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
td a {
|
||||
color: #EB6000;
|
||||
display: block;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
th a {
|
||||
padding-left: 0
|
||||
}
|
||||
td:first-of-type a {
|
||||
padding-left: 5px;
|
||||
}
|
||||
th:first-of-type {
|
||||
padding-left: 5px;
|
||||
}
|
||||
tr:nth-of-type(odd) {
|
||||
background-color: #DDD;
|
||||
}
|
||||
tr:hover td {
|
||||
background-color:#BBB;
|
||||
}
|
||||
tr:hover td a {
|
||||
color: #222;
|
||||
}
|
||||
th { cursor: hand; }
|
||||
th:a { text-decoration: none; }
|
||||
.right {
|
||||
text-align: right;
|
||||
}
|
||||
@@ -461,15 +526,15 @@ function alternate(table) {
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Index of '''+opts.title+'''</h1>
|
||||
<div class="container">
|
||||
<h1>''' + opts.title + '''</h1>
|
||||
<table class="sortable" id="fileList"><thead><tr><th>Name</th><th class="right">Size</th><th class="right">Size B</th><th class="right">Modified</th></tr></thead><tbody>
|
||||
'''
|
||||
return header
|
||||
|
||||
def get_footer():
|
||||
footer='''</tbody></table>
|
||||
return '''</tbody></table></div>
|
||||
</body></html>'''
|
||||
return footer
|
||||
|
||||
def is_imagefile(fname):
|
||||
for ext in IMAGE_EXTENSIONS:
|
||||
@@ -485,5 +550,6 @@ def sizeof(num):
|
||||
return "%3.1f %s" % (num, x)
|
||||
num /= 1024.0
|
||||
|
||||
if __name__ == "__main__":
|
||||
opts = setup()
|
||||
generate_index(opts)
|
||||
|
||||
Reference in New Issue
Block a user