cleaning class names for css, fixing video, attribution in template
This commit is contained in:
parent
eba58ebe92
commit
16a0577026
@ -24,16 +24,17 @@ else:
|
|||||||
mime_type = magic.Magic(mime=True)
|
mime_type = magic.Magic(mime=True)
|
||||||
|
|
||||||
file_types = {'image':'<img class="image" src="{}"></img>', 'pdf':'<a href="{}" class="pdf">{}</a>',
|
file_types = {'image':'<img class="image" src="{}"></img>', 'pdf':'<a href="{}" class="pdf">{}</a>',
|
||||||
'text':'<a href="{}" class="text">{}</a>', 'video':'<video class="video" src="{}"></video>', 'audio':'<audio controls class="audio"> <source src="{}"></source></audio>','html':'<a href="{}">{}</a>'}
|
'text':'<a href="{}" class="text">{}</a>', 'video':'<video class="video" controls><source src="{}"></source></video>', 'audio':'<audio controls class="audio"> <source src="{}"></source></audio>','html':'<a href="{}">{}</a>'}
|
||||||
|
|
||||||
def dict_by_value(dictionary, value):
|
def dict_by_value(dictionary, value):
|
||||||
return(list(dictionary.keys())[list(dictionary.values()).index(value)]) # returns the key for the given value
|
return(list(dictionary.keys())[list(dictionary.values()).index(value)]) # returns the key for the given value
|
||||||
def div(mime, tag, *values):
|
def div(mime, tag, *values):
|
||||||
#name, full_path
|
#name, full_path
|
||||||
|
class_name = values[0].split('.')[0].replace(' ', '_')
|
||||||
if 'image' in mime:
|
if 'image' in mime:
|
||||||
html ='<div class="{}">'.format(values[0])+tag+'</br><span class="filename">{}</span></div>'.format(values[0])
|
html ='<div class="{}">'.format(class_name)+tag+'</br><span class="filename">{}</span></div>'.format(values[0])
|
||||||
else:
|
else:
|
||||||
html = '<div class="{}">'.format(values[0])+tag+'</div>'.format(values[0])
|
html = '<div class="{}">'.format(class_name)+tag+'</div>'.format(values[0])
|
||||||
return html
|
return html
|
||||||
|
|
||||||
for root, dirs, files in os.walk(directory):
|
for root, dirs, files in os.walk(directory):
|
||||||
@ -48,6 +49,9 @@ for root, dirs, files in os.walk(directory):
|
|||||||
mime = mime_type.from_file(full_path)
|
mime = mime_type.from_file(full_path)
|
||||||
mime, format = mime.split('/') #example: text plain
|
mime, format = mime.split('/') #example: text plain
|
||||||
|
|
||||||
|
if args.verbose:
|
||||||
|
print(mime, format)
|
||||||
|
|
||||||
if mime in file_types:
|
if mime in file_types:
|
||||||
if name.endswith('.html'):
|
if name.endswith('.html'):
|
||||||
a = open(full_path).read()
|
a = open(full_path).read()
|
||||||
@ -60,7 +64,7 @@ for root, dirs, files in os.walk(directory):
|
|||||||
if mime not in file_types and format not in file_types: #to catch exceptions we haven't defined in file_types before
|
if mime not in file_types and format not in file_types: #to catch exceptions we haven't defined in file_types before
|
||||||
a = "<a href='{}'>{}</a>"
|
a = "<a href='{}'>{}</a>"
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
print ('Unrecognized mime-type: \n', mime,format, name)
|
print ('mime-type not in list, adding as href: \n', mime,format, name)
|
||||||
|
|
||||||
a = a.replace('{}',name)
|
a = a.replace('{}',name)
|
||||||
html.append(div(mime,a,name))
|
html.append(div(mime,a,name))
|
||||||
|
@ -4,10 +4,12 @@ html_head = """
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
<!-- Generated with distribusi http://git.homebrewserver.club/distribusi/log.html -->
|
||||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||||
<style>
|
<style>
|
||||||
.image{max-width: 100%;}
|
.image{max-width: 100%;}
|
||||||
div{width: 640px;float:left;}
|
div{width: 640px;float:left;}
|
||||||
|
video {width:640px;}
|
||||||
.dir::before{content:"📁";font-size:18px;}
|
.dir::before{content:"📁";font-size:18px;}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
Loading…
Reference in New Issue
Block a user