From b08b564f598c3d5d5a30eeb03ba5dffc0eb6021e Mon Sep 17 00:00:00 2001 From: Dooho Yi Date: Fri, 8 Jan 2021 01:52:04 +0900 Subject: [PATCH] timestamp support --- distribusi/distribusi.py | 35 ++++++++++++++----- sample/{01.txt => 1.txt} | 0 sample/notes/20210107T184153+0900_start/1.txt | 1 + .../1.txt | 1 + .../20210107T184946+0900_한번더/1.txt | 3 ++ styles/aurora.css | 18 ++++++++-- 6 files changed, 47 insertions(+), 11 deletions(-) rename sample/{01.txt => 1.txt} (100%) create mode 100644 sample/notes/20210107T184153+0900_start/1.txt create mode 100644 sample/notes/20210107T184852+0900_또다른 경우/1.txt create mode 100644 sample/notes/20210107T184946+0900_한번더/1.txt diff --git a/distribusi/distribusi.py b/distribusi/distribusi.py index 1d25693..148c75a 100644 --- a/distribusi/distribusi.py +++ b/distribusi/distribusi.py @@ -8,8 +8,10 @@ from PIL import Image from distribusi.page_template import html_footer, html_head from distribusi.mappings import CODE_TYPES, FILE_TYPES, SUB_TYPES +import re MIME_TYPE = magic.Magic(mime=True) +PATTERN_TSTR = re.compile(r"(?P(?P\d{4})(?P\d{2})(?P\d{2})T(?P\d{2})(?P\d{2})(?P\d{2})(?P[+|-]\d{4}))_(?P.+)") def caption(image): @@ -111,18 +113,17 @@ def write_index(args,index, html, html_head, html_footer): def render_dir(args, root): html = [] - for entry in os.listdir(root): + for name in os.listdir(root): if args.no_hidden: - if entry.startswith('.'): + if name.startswith('.'): continue - name = entry lv = root.split("/") relative = lv[len(lv) - 1] relative_path = "./{}/{}".format(relative, name) - if os.path.isfile(root + '/' + entry): + if os.path.isfile(root + '/' + name): if 'index.html' not in name: full_path = os.path.join(root, name) @@ -174,12 +175,20 @@ def render_dir(args, root): a = a.replace('{}', relative_path) html.append(div(args, type_, subtype, a, name)) - if os.path.isdir(root + '/' + entry): + if os.path.isdir(root + '/' + name): + + #check - time string + m = PATTERN_TSTR.search(name) + tstring = "" + rename = name + if m: + tstring = m.group('tstring') + rename = m.group('name') if args.menu_with_index: - a = "{}".replace('{}', relative_path) + a = "{}".format(relative_path, rename, tstring, tstring) else: - a = "{}/".replace('{}', relative_path) + a = "{}/".format(relative_path, rename, tstring, tstring) html.append(div(args, 'dir', 'dir', a, 'folder')) # html.insert(0, div(args, 'dir', 'dir', a, 'folder')) @@ -271,10 +280,18 @@ def distribusify(args, directory): # noqa html.append('../') for name in dirs: + #check - time string + m = PATTERN_TSTR.search(name) + tstring = "" + rename = name + if m: + tstring = m.group('tstring') + rename = m.group('name') + if args.menu_with_index: - a = "{}".replace('{}', name) + a = "
{}
".format(name, rename, tstring, tstring) else: - a = "{}/".replace('{}', name) + a = "
{}/
".format(name, rename, tstring, tstring) if args.unfolding: rd = render_dir(args, "{}/{}".format(root, name)) h = '
\n{}\n{}
'.format(name, a, rd) diff --git a/sample/01.txt b/sample/1.txt similarity index 100% rename from sample/01.txt rename to sample/1.txt diff --git a/sample/notes/20210107T184153+0900_start/1.txt b/sample/notes/20210107T184153+0900_start/1.txt new file mode 100644 index 0000000..a6ca65b --- /dev/null +++ b/sample/notes/20210107T184153+0900_start/1.txt @@ -0,0 +1 @@ +안녕, 새로운 시작? diff --git a/sample/notes/20210107T184852+0900_또다른 경우/1.txt b/sample/notes/20210107T184852+0900_또다른 경우/1.txt new file mode 100644 index 0000000..c8fdfd1 --- /dev/null +++ b/sample/notes/20210107T184852+0900_또다른 경우/1.txt @@ -0,0 +1 @@ +이번에는 공백문자가 들어있는 경우인데 말야. 잘될까? diff --git a/sample/notes/20210107T184946+0900_한번더/1.txt b/sample/notes/20210107T184946+0900_한번더/1.txt new file mode 100644 index 0000000..ede0ecb --- /dev/null +++ b/sample/notes/20210107T184946+0900_한번더/1.txt @@ -0,0 +1,3 @@ +글이 2개가 된것은 좋은데, 그랬더니, sorting이 문제네, 새로운 글이 먼저 나오는게 아무래도 맞겠지? 지금은 오름차순? 이라면, 내림차순으로 바꾸려면 어떻게 하는게 좋으려나. + +그리고, 이걸.. unfolded 폴더의 경우에만 그렇게 할건지. 아니면, 모두다 그렇게 할건지, 그렇게 되면 음. 글 안에서 파일들의 순서를 매기는 것이 좀 애매해지긴 함. diff --git a/styles/aurora.css b/styles/aurora.css index 0d7f8a1..c451eef 100644 --- a/styles/aurora.css +++ b/styles/aurora.css @@ -97,6 +97,11 @@ body>.unfolded { margin-top: 2em; } +time { + font-size: 0.65em; + text-align: right; +} + /* theme */ body { @@ -127,15 +132,24 @@ a:hover { color: hotpink; } -.unfolded>a:nth-child(1) { +.unfolded>.title { + width: 100%; + display: flex; + justify-content: space-between; +} + +.unfolded>.title>a:nth-child(1) { font-size: 1.1em; color: rgba(100, 255, 200, 0.5); font-weight: 700; border: unset; - margin-bottom: 1em; padding-left: 0; } +time { + color: rgba(100, 255, 200, .2); +} + audio::-webkit-media-controls-enclosure { background-color: rgba(50, 135, 120, 1.0); }