From 31c399a8495a37a88d9b60d0438b589f273d8138 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 4 May 2024 19:00:27 +0200 Subject: add --cdn option --- bin/pyggle | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/pyggle b/bin/pyggle index dbccd55..be00b0a 100755 --- a/bin/pyggle +++ b/bin/pyggle @@ -548,6 +548,9 @@ if __name__ == "__main__": action="store_true", help="Store captions as EXIF comments (IN-PLACE EDIT)", ) + parser.add_argument( + "--cdn", metavar="URL", type=str, help="Load JS and CSS from URL/{css,js}" + ) parser.add_argument( "--edit-in-place", action="store_true", @@ -617,11 +620,16 @@ if __name__ == "__main__": base_dir = "/".join(os.path.realpath(sys.argv[0]).split("/")[:-2]) - copy_files(f"{base_dir}/share") + if not args.cdn: + copy_files(f"{base_dir}/share") with open(f"{base_dir}/share/html_start", "r") as f: html_buf = f.read().replace("", args.title) + if args.cdn: + html_buf = html_buf.replace('href=".data/css/"', f'href="{args.cdn}/css/') + html_buf = html_buf.replace('src=".data/js/"', f'sc="{args.cdn}/js/') + if args.html_include: with open(args.html_include, "r") as f: html_buf += f.read() -- cgit v1.2.3