From d09101ff48b879119416e9728a8b096570f509d5 Mon Sep 17 00:00:00 2001 From: Hyunchul Kim Date: Wed, 2 Dec 2020 07:26:30 +0900 Subject: [PATCH] Add fragmentId(`fid`) --- distribusi/distribusi/distribusi.py | 42 ++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/distribusi/distribusi/distribusi.py b/distribusi/distribusi/distribusi.py index c5e26c5..1906c2e 100644 --- a/distribusi/distribusi/distribusi.py +++ b/distribusi/distribusi/distribusi.py @@ -62,21 +62,36 @@ def thumbnail(image, name, args): return "
{}
".format(name, name, name) -def div(args, type_, subtype, tag, name, id): +def div(args, type_, subtype, tag, name, fid): + ''' + fid: fragment_id + ''' if args.no_filenames: filename = '' else: filename = '{}'.format(name) - if 'image' in type_: - html = '
{}#{}
' - elif 'pdf' in subtype: - html = '
{}' + filename + '#{}
' - elif 'dir' in type_ or 'html' in subtype or 'unkown-file' in subtype: - html = '
{}{}
' + if len(str(fid)) >= 36: # detect if fid is uuid + if 'image' in type_: + html = '
{}
' + elif 'pdf' in subtype: + html = '
{}' + filename + '
' + elif 'dir' in type_ or 'html' in subtype or 'unkown-file' in subtype: + html = '
{}
' + else: + html = '
{}' + filename + '
' + html = html.format(subtype, tag) else: - html = '
{}' + filename + '#{}
' - return html.format(subtype, id, tag, id) + if 'image' in type_: + html = '
{}#{}
' + elif 'pdf' in subtype: + html = '
{}' + filename + '#{}
' + elif 'dir' in type_ or 'html' in subtype or 'unkown-file' in subtype: + html = '
{}{}
' + else: + html = '
{}' + filename + '#{}
' + html = html.format(subtype, fid, tag, fid) + return html def check_distribusi_index(args, index): @@ -274,8 +289,8 @@ def distribusify(args, directory, freg): # noqa a = a.replace('{}', name) if len(path) == 3 and artist: - id = freg.get_index(artist, name) - html.append(div(args, type_, subtype, a, name, id)) + fid = freg.get_index(artist, name) + html.append(div(args, type_, subtype, a, name, fid)) if root != directory: @@ -289,9 +304,10 @@ def distribusify(args, directory, freg): # noqa if len(path) == 3 and artist: print(artist) # dirs 내부의 콘텐츠를 렌더링해 가져와야 함 - id = freg.get_index(artist, name) + fid = freg.get_index(artist, name) rd = render_dir(args, "{}/{}".format(root, name)) - h = '
\n{}
'.format(id, rd) + # h = '
\n{}
' + h = '
\n{}{}
'.format(fid, rd, fid) html.append(h) if not directory == root: