Compare commits
10 commits
410efea672
...
ec20adba40
| Author | SHA1 | Date | |
|---|---|---|---|
| ec20adba40 | |||
| 6091e5a988 | |||
| 77018d75e6 | |||
| 1b3d5bb88b | |||
| 90a4f2fbb8 | |||
| 86de0ac6b1 | |||
| f5e76c78cb | |||
| d5de3bd80a | |||
| 328f3b2189 | |||
| ee4c33100a |
7 changed files with 67 additions and 17 deletions
|
|
@ -94,6 +94,12 @@ def build_argparser():
|
|||
help="Enable unfolding detecting .unfolding",
|
||||
action="store_true")
|
||||
|
||||
parser.add_argument(
|
||||
'--latest-first',
|
||||
help="sort file/folders to be latest object comes earlier",
|
||||
action="store_true",
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
@ -111,10 +112,13 @@ def write_index(args,index, html, html_head, html_footer):
|
|||
|
||||
|
||||
def render_dir(args, root):
|
||||
reverse = False
|
||||
if args.latest_first:
|
||||
reverse = True
|
||||
|
||||
html = []
|
||||
|
||||
#for name in sorted(os.listdir(root)):
|
||||
for name in sorted(os.listdir(root),reverse=True):
|
||||
for name in sorted(os.listdir(root),reverse=reverse):
|
||||
|
||||
if args.no_hidden:
|
||||
if name.startswith('.'):
|
||||
|
|
@ -153,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'
|
||||
|
|
@ -213,6 +221,11 @@ def render_dir(args, root):
|
|||
|
||||
|
||||
def distribusify(args, directory): # noqa
|
||||
|
||||
reverse = False
|
||||
if args.latest_first:
|
||||
reverse = True
|
||||
|
||||
for root, dirs, files in os.walk(directory):
|
||||
|
||||
if args.exclude_directory:
|
||||
|
|
@ -237,8 +250,7 @@ def distribusify(args, directory): # noqa
|
|||
if args.verbose:
|
||||
print('Generating directory listing for', root)
|
||||
|
||||
#for name in sorted(files):
|
||||
for name in sorted(files,reverse=True):
|
||||
for name in sorted(files,reverse=reverse):
|
||||
|
||||
if 'index.html' not in name:
|
||||
full_path = os.path.join(root, name)
|
||||
|
|
@ -264,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>"
|
||||
|
|
@ -308,8 +323,7 @@ def distribusify(args, directory): # noqa
|
|||
else:
|
||||
html.append('<a href="../">../</a>')
|
||||
|
||||
#for name in dirs:
|
||||
for name in sorted(dirs,reverse=True):
|
||||
for name in sorted(dirs,reverse=reverse):
|
||||
|
||||
#check - time string
|
||||
m = PATTERN_TSTR.search(name)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
html_head = """
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html>
|
||||
<head>
|
||||
<!-- Generated with distribusi https://git.vvvvvvaria.org/varia/distribusi -->
|
||||
<meta name="generator" content="distribusi" />
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@ video {
|
|||
|
||||
/* layout */
|
||||
|
||||
html {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
div {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
|
@ -58,7 +62,7 @@ div {
|
|||
}
|
||||
|
||||
.plain div {
|
||||
white-space: pre-line;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@ video {
|
|||
|
||||
/* layout */
|
||||
|
||||
html {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
div {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
|
@ -58,14 +62,14 @@ div {
|
|||
}
|
||||
|
||||
.plain div {
|
||||
white-space: pre-line;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
/* .x-c div,
|
||||
.x-shellscript div,
|
||||
.x-python div {
|
||||
white-space: pre-line;
|
||||
white-space: pre-wrap;
|
||||
} */
|
||||
|
||||
figure {
|
||||
|
|
@ -169,6 +173,13 @@ a:hover {
|
|||
padding-left: 0;
|
||||
}
|
||||
|
||||
.plain .named {
|
||||
display: block;
|
||||
font-weight: 700;
|
||||
border: unset;
|
||||
color: rgba(127, 127, 127, 0.5);
|
||||
}
|
||||
|
||||
time {
|
||||
color: rgba(127, 127, 127, 0.2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@
|
|||
max-width: 100%%;
|
||||
} */
|
||||
|
||||
html {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.pdf object {
|
||||
width: 640px;
|
||||
height: 640px;
|
||||
|
|
@ -58,7 +62,7 @@ div {
|
|||
}
|
||||
|
||||
.plain div {
|
||||
white-space: pre-line;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@ video {
|
|||
|
||||
/* layout */
|
||||
|
||||
html {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
div {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
|
@ -58,7 +62,7 @@ div {
|
|||
}
|
||||
|
||||
.plain div {
|
||||
white-space: pre-line;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
|
|
@ -161,6 +165,13 @@ a:hover {
|
|||
padding-left: 0;
|
||||
}
|
||||
|
||||
.plain .named {
|
||||
display: block;
|
||||
font-weight: 700;
|
||||
border: unset;
|
||||
color: rgba(37, 176, 118, 0.25);
|
||||
}
|
||||
|
||||
time {
|
||||
color: rgba(37, 176, 118, .2);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue