Unverified Commit 31c399a8 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

add --cdn option

parent a92d89d3
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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])

    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("<!-- $title -->", 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()