utilize titles of .txt files.
This commit is contained in:
parent
ee4c33100a
commit
328f3b2189
2 changed files with 18 additions and 5 deletions
|
|
@ -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>"
|
||||
|
|
|
|||
|
|
@ -161,6 +161,11 @@ a:hover {
|
|||
padding-left: 0;
|
||||
}
|
||||
|
||||
.unfolded .plain .named {
|
||||
display: block;
|
||||
color: rgba(37, 176, 118, 0.25);
|
||||
}
|
||||
|
||||
time {
|
||||
color: rgba(37, 176, 118, .2);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue