Test iframe resize by children

This commit is contained in:
Sewon Ahn 2020-10-28 17:38:25 +09:00
parent cffa246415
commit 23a0fb433a
2 changed files with 28 additions and 1 deletions

View file

@ -54,6 +54,9 @@ def thumbnail(image, name, args):
print('Thumbnailer:', e) print('Thumbnailer:', e)
return "<figure><a href='{}'><img src='{}'></a><figcaption>{}</figcaption></figure>".format(name, name, name) return "<figure><a href='{}'><img src='{}'></a><figcaption>{}</figcaption></figure>".format(name, name, name)
def folder(name, id):
html = '<div>'+name+'</div><iframe src="{}/index.html" id="'+id+'" onLoad="autoResize(\''+id+'\')";></iframe>'
return html.format(name)
def div(args, type_, subtype, tag, name): def div(args, type_, subtype, tag, name):
id_name = name.split('.')[0].replace(' ', '_') id_name = name.split('.')[0].replace(' ', '_')
@ -191,13 +194,15 @@ def distribusify(args, directory): # noqa
else: else:
html.append('<a href="../">../</a>') html.append('<a href="../">../</a>')
i = 0;
for name in dirs: for name in dirs:
if args.menu_with_index: if args.menu_with_index:
a = "<a href='{}/index.html'>{}</a>".replace('{}', name) a = "<a href='{}/index.html'>{}</a>".replace('{}', name)
else: else:
a = "<a href='{}'>{}/</a>".replace('{}', name) a = "<a href='{}'>{}/</a>".replace('{}', name)
html.insert(0, div(args, 'dir', 'dir', a, 'folder')) html.insert(0, folder(name, 'folder-{}'.format(i)))
i = i + 1
index = os.path.join(root, 'index.html') index = os.path.join(root, 'index.html')
if os.path.exists(index): if os.path.exists(index):

View file

@ -15,6 +15,28 @@ html_head = """
video {width:640px;max-height:640px;} video {width:640px;max-height:640px;}
%s %s
</style> </style>
<script language="JavaScript">
<!--
function autoResize(id){
var newheight;
var newwidth;
if(document.getElementById){
newheight=document.getElementById(id).contentWindow.document.body.scrollHeight;
newwidth=document.getElementById(id).contentWindow.document.body.scrollWidth;
}
document.getElementById(id).height= (newheight) + "px";
document.getElementById(id).width= (newwidth) + "px";
console.log("Call autoResize for "+id+" w: " + newwidth + ", h: " + newheight);
}
//-->
</script>
</head> </head>
<body> <body>
""" """