utilize titles of .txt files.

This commit is contained in:
Dooho Yi 2021-01-31 20:29:52 +09:00
parent ee4c33100a
commit f5e76c78cb
2 changed files with 21 additions and 5 deletions

View file

@ -12,6 +12,7 @@ import re
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>.+)")
PATTERN_TSTR_TXT = 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>.*)\.txt")
def caption(image):
@ -156,13 +157,17 @@ def render_dir(args, root):
#elif subtype in CODE_TYPES or name.endswith('.txt'):
elif name.endswith('.txt'):
#check - time string
m = PATTERN_TSTR.search(name)
m = PATTERN_TSTR_TXT.search(name)
tstring = ""
rename = name
if m:
tstring = m.group('tstring')
rename = m.group('name')
a = "<div>" + open(full_path).read() + "</div><time datetime={}>{}</time>"
if rename == "":
a = "<div>"
else:
a = "<div><div class='named'>{}</div>".replace('{}', rename)
a = a + open(full_path).read() + "</div><time datetime={}>{}</time>"
a = a.replace('{}', tstring)
else:
subtype = subtype + ' unkown-file'
@ -271,15 +276,18 @@ def distribusify(args, directory): # noqa
#elif subtype in CODE_TYPES or name.endswith('.txt'):
elif name.endswith('.txt'):
#check - time string
m = PATTERN_TSTR.search(name)
m = PATTERN_TSTR_TXT.search(name)
tstring = ""
rename = name
if m:
tstring = m.group('tstring')
rename = m.group('name')
a = "<div>" + open(full_path).read() + "</div><time datetime={}>{}</time>"
if rename == "":
a = "<div>"
else:
a = "<div><div class='named'>{}</div>".replace('{}', rename)
a = a + open(full_path).read() + "</div><time datetime={}>{}</time>"
a = a.replace('{}', tstring)
#a = "<div>" + open(full_path).read() + "</div>"
else:
subtype = subtype+' unkown-file'
a = "<a href='{}'>{}</a>"

View file

@ -161,6 +161,14 @@ a:hover {
padding-left: 0;
}
.unfolded .plain .named {
display: block;
font-weight: 700;
border: unset;
/* color: rgba(180, 64, 134, 0.5); */
color: rgba(37, 176, 118, 0.25);
}
time {
color: rgba(37, 176, 118, .2);
}