diff --git a/distribusi/distribusi/distribusi.py b/distribusi/distribusi/distribusi.py index d3dab72..2247205 100644 --- a/distribusi/distribusi/distribusi.py +++ b/distribusi/distribusi/distribusi.py @@ -11,8 +11,7 @@ from PIL import Image, ExifTags import markdown from distribusi.page_template import html_footer, html_head -from distribusi.page_template_event import html_footer_evnet, html_head_event -from distribusi.page_template_events import html_footer_events, html_head_event +from distribusi.page_template_event import html_footer_event, html_head_event from distribusi.mappings import CODE_TYPES, FILE_TYPES, SUB_TYPES from distribusi import fragments import uuid @@ -132,13 +131,14 @@ def check_distribusi_index(args, index): elif args.force: return True -def write_index(args,index, html, html_head, html_footer): + +def write_index(args, index, html, html_head, html_footer): with open(index, 'w') as f: if not args.no_template: if args.style: fs = open(args.style, "r") style = fs.read() - styled_html_head = html_head# % style + styled_html_head = html_head # % style else: styled_html_head = html_head % '' print("---") @@ -162,7 +162,7 @@ def render_dir(args, directory): relative_path = "./{}/{}".format(relative, name) if ignore.test(name): - pass + continue elif 'index.html' not in name: full_path = os.path.join(root, name) mime = MIME_TYPE.from_file(full_path) @@ -239,6 +239,8 @@ def render_dir(args, directory): def distribusify(args, directory, freg): # noqa for root, dirs, files in os.walk(directory): ignore.add(root) + if ignore.testRoot(root): + continue if args.exclude_directory: if args.verbose: @@ -256,10 +258,14 @@ def distribusify(args, directory, freg): # noqa # fragments index # 작가 폴더 내인 경우 아티스트명 저장 # + artist = None path = root.split('/') - if len(path) == 3: + if len(path) > 2: artist = path[2].strip() + print(path) + print(artist) + if not args.remove_index: html = [] @@ -268,7 +274,7 @@ def distribusify(args, directory, freg): # noqa for name in sorted(files): if ignore.test(name): - pass + continue elif 'index.html' not in name: full_path = os.path.join(root, name) mime = MIME_TYPE.from_file(full_path) @@ -322,8 +328,6 @@ def distribusify(args, directory, freg): # noqa a = FILE_TYPES[type_].format(name, alt, c) - - if subtype in SUB_TYPES: a = SUB_TYPES[subtype] @@ -340,7 +344,6 @@ def distribusify(args, directory, freg): # noqa fid = freg.get_index(artist, name) html.append(div(args, type_, subtype, a, name, fid)) - if root != directory: if args.menu_with_index: html.append('../') @@ -349,9 +352,8 @@ def distribusify(args, directory, freg): # noqa for name in dirs: if ignore.test(name): - pass - elif len(path) == 3 and artist: - print(artist) + continue + elif (len(path) == 3 and artist) or (len(path) == 4 and artist == "events"): # dirs 내부의 콘텐츠를 렌더링해 가져와야 함 fid = freg.get_index(artist, name) rd = render_dir(args, "{}/{}".format(root, name)) @@ -363,9 +365,15 @@ def distribusify(args, directory, freg): # noqa index = os.path.join(root, 'index.html') if os.path.exists(index): if check_distribusi_index(args, index): - write_index(args,index,html, html_head, html_footer) + if artist == "events": + write_index(args, index, html, html_head_event, html_footer_event) + else: + write_index(args, index, html, html_head, html_footer) elif not os.path.exists(index): - write_index(args,index,html, html_head, html_footer) + if artist == "events": + write_index(args, index, html, html_head_event, html_footer_event) + else: + write_index(args, index, html, html_head, html_footer) if args.remove_index: index = os.path.join(root, 'index.html') diff --git a/distribusi/distribusi/ignore.py b/distribusi/distribusi/ignore.py index 65c7e1f..7b53969 100644 --- a/distribusi/distribusi/ignore.py +++ b/distribusi/distribusi/ignore.py @@ -26,3 +26,16 @@ class Ignore: return True return False + + def testRoot(self, target): + path = target.split('/') + + if path[len(path)-1] in self.ignore or path[len(path)-1] == "": + return True + + for ig in self.ignore: + reg = re.compile(ig) + if bool(re.match(reg, target)): + return True + + return False \ No newline at end of file diff --git a/distribusi/distribusi/page_template_event.py b/distribusi/distribusi/page_template_event.py index 40706e4..1f2d057 100644 --- a/distribusi/distribusi/page_template_event.py +++ b/distribusi/distribusi/page_template_event.py @@ -12,7 +12,7 @@ html_head_event = """ - + %s diff --git a/test_data/.ignore b/test_data/.ignore index 215a393..97a206e 100644 --- a/test_data/.ignore +++ b/test_data/.ignore @@ -6,8 +6,10 @@ index.html index.json Readme.md src +.+/src+. participants.html style.css 404.html main.js -.+.alt \ No newline at end of file +.+.alt +events \ No newline at end of file diff --git a/test_data/event_lecture/event_0000.meta b/test_data/event_lecture/event_0000.meta deleted file mode 100644 index 0dee57f..0000000 --- a/test_data/event_lecture/event_0000.meta +++ /dev/null @@ -1,3 +0,0 @@ -{ - "occupation": 0 -} \ No newline at end of file diff --git a/test_data/event_lecture/event_0000/124157237_121248643124584_872058020963845448_n.jpg b/test_data/event_lecture/event_0000/124157237_121248643124584_872058020963845448_n.jpg deleted file mode 100644 index 821875d..0000000 Binary files a/test_data/event_lecture/event_0000/124157237_121248643124584_872058020963845448_n.jpg and /dev/null differ diff --git a/test_data/event_lecture/event_0000/124469821_121248626457919_479957910997498417_n.jpg b/test_data/event_lecture/event_0000/124469821_121248626457919_479957910997498417_n.jpg deleted file mode 100644 index 2918c3e..0000000 Binary files a/test_data/event_lecture/event_0000/124469821_121248626457919_479957910997498417_n.jpg and /dev/null differ diff --git a/test_data/event_lecture/event_0000/124476076_121248659791249_2342598949363915450_n.jpg b/test_data/event_lecture/event_0000/124476076_121248659791249_2342598949363915450_n.jpg deleted file mode 100644 index 2666baa..0000000 Binary files a/test_data/event_lecture/event_0000/124476076_121248659791249_2342598949363915450_n.jpg and /dev/null differ diff --git a/test_data/event_lecture/event_0000/index.html b/test_data/event_lecture/event_0000/index.html deleted file mode 100644 index 6159ad8..0000000 --- a/test_data/event_lecture/event_0000/index.html +++ /dev/null @@ -1,74 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - diff --git a/test_data/event_lecture/event_0001.meta b/test_data/event_lecture/event_0001.meta deleted file mode 100644 index 8e490f6..0000000 --- a/test_data/event_lecture/event_0001.meta +++ /dev/null @@ -1,3 +0,0 @@ -{ - "occupation": 1 -} \ No newline at end of file diff --git a/test_data/event_lecture/event_0001/event_0001.txt b/test_data/event_lecture/event_0001/event_0001.txt deleted file mode 100644 index eef1ee9..0000000 --- a/test_data/event_lecture/event_0001/event_0001.txt +++ /dev/null @@ -1,26 +0,0 @@ -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 -이벤트 0001 에 대한 설명문 - - diff --git a/test_data/event_lecture/event_0001/index.html b/test_data/event_lecture/event_0001/index.html deleted file mode 100644 index 6159ad8..0000000 --- a/test_data/event_lecture/event_0001/index.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test_data/event_lecture/index.html b/test_data/event_lecture/index.html deleted file mode 100644 index f706377..0000000 --- a/test_data/event_lecture/index.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - -

