From c68a4af4b111d2b570fe6507cf6234058fdb0c2a Mon Sep 17 00:00:00 2001 From: rmgr Date: Thu, 17 Feb 2022 12:05:33 +1030 Subject: [PATCH] Add support for sharing .stls --- nb_wiki.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/nb_wiki.py b/nb_wiki.py index 32a09cb..e5d4e43 100644 --- a/nb_wiki.py +++ b/nb_wiki.py @@ -4,7 +4,7 @@ import http.server import socketserver import shutil list_of_tags = {} -copy_extensions = [".gif",".jpg",".png", ".html"] +copy_extensions = [".gif",".jpg",".png", ".html", ".stl"] output_dir = "" base_url = "" @@ -211,12 +211,18 @@ def process_tag(output, page_title, parent_link, base_dir , tag_text): def process_link(output, link_text): link_text = link_text.replace(":","/") + link_path = os.path.join(base_url, link_text) if not "|" in link_text: - output.write('' + link_text + '') + if os.path.splitext(link_text) in copy_extensions: + output.write('' + link_text + '') + else: + output.write('' + link_text + '') else: split_link = link_text.split("|") - output.write('' + split_link[1] + '') - + if os.path.splitext(split_link[0].rstrip())[1] in copy_extensions: + output.write('' + split_link[1] + '') + else: + output.write('' + split_link[1] + '') def process_external_link(output, link_text): output.write('' + link_text + '')