timestamp support
This commit is contained in:
parent
45f37e7279
commit
b08b564f59
6 changed files with 47 additions and 11 deletions
|
|
@ -8,8 +8,10 @@ from PIL import Image
|
||||||
|
|
||||||
from distribusi.page_template import html_footer, html_head
|
from distribusi.page_template import html_footer, html_head
|
||||||
from distribusi.mappings import CODE_TYPES, FILE_TYPES, SUB_TYPES
|
from distribusi.mappings import CODE_TYPES, FILE_TYPES, SUB_TYPES
|
||||||
|
import re
|
||||||
|
|
||||||
MIME_TYPE = magic.Magic(mime=True)
|
MIME_TYPE = magic.Magic(mime=True)
|
||||||
|
PATTERN_TSTR = re.compile(r"(?P<tstring>(?P<year>\d{4})(?P<month>\d{2})(?P<day>\d{2})T(?P<hour>\d{2})(?P<minute>\d{2})(?P<second>\d{2})(?P<timezone>[+|-]\d{4}))_(?P<name>.+)")
|
||||||
|
|
||||||
|
|
||||||
def caption(image):
|
def caption(image):
|
||||||
|
|
@ -111,18 +113,17 @@ def write_index(args,index, html, html_head, html_footer):
|
||||||
def render_dir(args, root):
|
def render_dir(args, root):
|
||||||
html = []
|
html = []
|
||||||
|
|
||||||
for entry in os.listdir(root):
|
for name in os.listdir(root):
|
||||||
|
|
||||||
if args.no_hidden:
|
if args.no_hidden:
|
||||||
if entry.startswith('.'):
|
if name.startswith('.'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
name = entry
|
|
||||||
lv = root.split("/")
|
lv = root.split("/")
|
||||||
relative = lv[len(lv) - 1]
|
relative = lv[len(lv) - 1]
|
||||||
relative_path = "./{}/{}".format(relative, name)
|
relative_path = "./{}/{}".format(relative, name)
|
||||||
|
|
||||||
if os.path.isfile(root + '/' + entry):
|
if os.path.isfile(root + '/' + name):
|
||||||
|
|
||||||
if 'index.html' not in name:
|
if 'index.html' not in name:
|
||||||
full_path = os.path.join(root, name)
|
full_path = os.path.join(root, name)
|
||||||
|
|
@ -174,12 +175,20 @@ def render_dir(args, root):
|
||||||
a = a.replace('{}', relative_path)
|
a = a.replace('{}', relative_path)
|
||||||
html.append(div(args, type_, subtype, a, name))
|
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:
|
if args.menu_with_index:
|
||||||
a = "<a href='{}/index.html'>{}</a>".replace('{}', relative_path)
|
a = "<a href='{}/index.html'>{}</a><time datetime={}>{}</time>".format(relative_path, rename, tstring, tstring)
|
||||||
else:
|
else:
|
||||||
a = "<a href='{}'>{}/</a>".replace('{}', relative_path)
|
a = "<a href='{}'>{}/</a><time datetime={}>{}</time>".format(relative_path, rename, tstring, tstring)
|
||||||
html.append(div(args, 'dir', 'dir', a, 'folder'))
|
html.append(div(args, 'dir', 'dir', a, 'folder'))
|
||||||
# html.insert(0, 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('<a href="../">../</a>')
|
html.append('<a href="../">../</a>')
|
||||||
|
|
||||||
for name in dirs:
|
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:
|
if args.menu_with_index:
|
||||||
a = "<a href='{}/index.html'>{}</a>".replace('{}', name)
|
a = "<div class='title'><a href='{}/index.html'>{}</a><time datetime={}>{}</time></div>".format(name, rename, tstring, tstring)
|
||||||
else:
|
else:
|
||||||
a = "<a href='{}'>{}/</a>".replace('{}', name)
|
a = "<div class='title'><a href='{}'>{}/</a><time datetime={}>{}</time></div>".format(name, rename, tstring, tstring)
|
||||||
if args.unfolding:
|
if args.unfolding:
|
||||||
rd = render_dir(args, "{}/{}".format(root, name))
|
rd = render_dir(args, "{}/{}".format(root, name))
|
||||||
h = '<div id="folder-{}" class="unfolded">\n{}\n{}</div>'.format(name, a, rd)
|
h = '<div id="folder-{}" class="unfolded">\n{}\n{}</div>'.format(name, a, rd)
|
||||||
|
|
|
||||||
1
sample/notes/20210107T184153+0900_start/1.txt
Normal file
1
sample/notes/20210107T184153+0900_start/1.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
안녕, 새로운 시작?
|
||||||
1
sample/notes/20210107T184852+0900_또다른 경우/1.txt
Normal file
1
sample/notes/20210107T184852+0900_또다른 경우/1.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
이번에는 공백문자가 들어있는 경우인데 말야. 잘될까?
|
||||||
3
sample/notes/20210107T184946+0900_한번더/1.txt
Normal file
3
sample/notes/20210107T184946+0900_한번더/1.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
글이 2개가 된것은 좋은데, 그랬더니, sorting이 문제네, 새로운 글이 먼저 나오는게 아무래도 맞겠지? 지금은 오름차순? 이라면, 내림차순으로 바꾸려면 어떻게 하는게 좋으려나.
|
||||||
|
|
||||||
|
그리고, 이걸.. unfolded 폴더의 경우에만 그렇게 할건지. 아니면, 모두다 그렇게 할건지, 그렇게 되면 음. 글 안에서 파일들의 순서를 매기는 것이 좀 애매해지긴 함.
|
||||||
|
|
@ -97,6 +97,11 @@ body>.unfolded {
|
||||||
margin-top: 2em;
|
margin-top: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time {
|
||||||
|
font-size: 0.65em;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
/* theme */
|
/* theme */
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|
@ -127,15 +132,24 @@ a:hover {
|
||||||
color: hotpink;
|
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;
|
font-size: 1.1em;
|
||||||
color: rgba(100, 255, 200, 0.5);
|
color: rgba(100, 255, 200, 0.5);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
border: unset;
|
border: unset;
|
||||||
margin-bottom: 1em;
|
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time {
|
||||||
|
color: rgba(100, 255, 200, .2);
|
||||||
|
}
|
||||||
|
|
||||||
audio::-webkit-media-controls-enclosure {
|
audio::-webkit-media-controls-enclosure {
|
||||||
background-color: rgba(50, 135, 120, 1.0);
|
background-color: rgba(50, 135, 120, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue