From 2ca1f9f4ec000b9b1f9b883b730bb1386f9c4651 Mon Sep 17 00:00:00 2001 From: manetta Date: Tue, 11 Jun 2019 22:15:18 +0200 Subject: [PATCH] tweaking distribusi a bit further, added a mobile stylesheet, foldername as h1 title, listing folders at the top --- distribusi/distribusi.py | 12 ++++++++---- distribusi/page_template.py | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/distribusi/distribusi.py b/distribusi/distribusi.py index 4c7b6a9..d7d1d2b 100644 --- a/distribusi/distribusi.py +++ b/distribusi/distribusi.py @@ -51,9 +51,9 @@ def div(mime, tag, *values): id_name = values[0].split('.')[0].replace(' ', '_') if 'image' in mime: - html = '
{}
{}
' + html = '
{}{}
' elif 'pdf' in mime: - html = '
{}
{}
' + html = '
{}{}
' else: html = '
{}
' @@ -114,17 +114,21 @@ def distribusify(args, directory): # noqa position = '../' * root.count('/') stylesheet = ''.format(position) else: - stylesheet = ''.format(directory) + stylesheet = '' for name in dirs: a = "{}/".replace('{}', name) - html.append(div('dir', a, 'folder')) + html.insert(0, div('dir', a, 'folder')) with open(os.path.join(root, 'index.html'), 'w') as f: if not args.no_template: header = html_head(stylesheet) f.write(header) + h1 = '

{}

'.format(''.join(root)) + print('path:', h1) + html.insert(0, h1) + for line in html: f.write(line+'\n') diff --git a/distribusi/page_template.py b/distribusi/page_template.py index c9f2312..075731a 100644 --- a/distribusi/page_template.py +++ b/distribusi/page_template.py @@ -19,13 +19,22 @@ html_footer = """ styles = """ body{ position: absolute; - top:20px; + top:0; + left:0; + margin:3.5em 1em 1em 1em; } - .stylesheet{ display: none; } +h1.foldername{ + margin: 0 0 1em 1.5em; +} + +a{ + text-decoration:none; +} + div{ width: 640px; float:left; @@ -50,14 +59,16 @@ a.text::before{ a.back::before{ content:"ток"; font-size:18px; - padding-right: 1em; + padding-right: 1.25em; text-decoration:none; } a.back{ position: fixed; + width:100%; + background-color:white; top:0; left:0; - padding:0.5em; + padding:1em 1.5em; } .image{ @@ -69,4 +80,21 @@ a.back{ video { width:640px; } +.filename{ + display:block; + font-size:small; + margin-top:0.5em; +} + +@media only screen and (max-width: 600px) { + body{ + width:calc(100% - 2em); + } + div { + width:calc(100% - 2em); + } + div a img{ + width:100%; + } +} """ \ No newline at end of file