Commit c7bcf747 authored by marius david's avatar marius david
Browse files

Directly embed some dependancies into the git repo

parent e07748b9
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -16,7 +16,8 @@ combined.js

# Build files
node_modules/
dist*/
/dist*/
/result

# Cache folders
*.pyc

tools/ci/cdn_to_local.py

deleted100644 → 0
+0 −49
Original line number Diff line number Diff line
import glob
import string
import re
import hashlib
import os
import urllib.request

cdns = []

def join_rel_path(path1, path2):
    path = os.path.join(path1, path2)
    path = re.sub(r"\/[^\/]+?\/\.", "", path)
    return path

for name in glob.glob("web/**.html"):
    with open(name, 'r', encoding='utf-8') as file:
        file_string = file.read()
    urls = re.findall('"(https:\/\/cdn.jsdelivr.net\/(.+?))"', file_string)
    for url_groups in urls:
        url: string = url_groups[0]
        os.makedirs("dist-temp/cdn/" + hashlib.md5(url.encode()).hexdigest(), exist_ok=True)
        new_url = "cdn/" + hashlib.md5(url.encode()).hexdigest() + "/" + os.path.basename(url)
        print(url)
        urllib.request.urlretrieve(url, "dist-temp/" + new_url)
        file_string = file_string.replace(url, new_url)
        cdns.append((url, new_url, hashlib.md5(url.encode()).hexdigest()))
    file_string = file_string.replace("crossorigin=\"anonymous\"", "")
    # print(file_string).replace("\?.+$", "")
    name = name.replace('web/', 'dist-temp/')
    with open(name, 'w', encoding='utf-8') as file:
        file.write(file_string)

for cdn in cdns:
    parent_url, parent_new_url, hash = cdn
    name = "dist-temp/" + parent_new_url
    with open(name, 'r', encoding='utf-8') as file:
        file_string = file.read()
    urls = re.findall('\("(.\/(.+?))"\)', file_string)
    for url_groups in urls:
        url_orig = url_groups[0]
        url: string = join_rel_path(parent_url, url_groups[0])
        url = re.sub("\?.+$", "", url)
        os.makedirs("dist-temp/cdn/" + hashlib.md5(url.encode()).hexdigest(), exist_ok=True)
        new_url = "cdn/" + hashlib.md5(url.encode()).hexdigest() + "/" + os.path.basename(url)
        print(url)
        urllib.request.urlretrieve(url, "dist-temp/" + new_url)
        file_string = file_string.replace(url_orig, new_url.replace("cdn/", "../"))
    with open(name, 'w', encoding='utf-8') as file:
        file.write(file_string)
 No newline at end of file

tools/fetch_dist.bash

0 → 100644
+25 −0
Original line number Diff line number Diff line
# should be run in the root of the repository
# The files present in the dist folder should correspond to those obtained by this script (as a way to source those blobs)

set -e

DIST_DIR=$(pwd)/web/_js/dist


BOOTSTRAP_TEMP=$(mktemp -d)
echo fetching bootstrap with temp dir $BOOTSTRAP_TEMP
cd $BOOTSTRAP_TEMP
wget https://github.com/twbs/bootstrap/releases/download/v5.3.3/bootstrap-5.3.3-dist.zip -O dist.zip
unzip dist.zip
cp bootstrap-*-dist/js/bootstrap.bundle.min.* $DIST_DIR
rm -r $BOOTSTRAP_TEMP

BOOTSTRAP_ICONS_TEMP=$(mktemp -d)
echo fetching bootstrap-icons with temp dir $BOOTSTRAP_ICONS_TEMP
cd $BOOTSTRAP_ICONS_TEMP
wget https://github.com/twbs/icons/releases/download/v1.11.3/bootstrap-icons-1.11.3.zip -O dist.zip
unzip dist.zip
mkdir -p $DIST_DIR/bootstrap-icons-font/fonts
cp -r bootstrap-icons-*/font/fonts/* $DIST_DIR/bootstrap-icons-font/fonts
cp -r bootstrap-icons-*/font/bootstrap-icons.min.css $DIST_DIR/bootstrap-icons-font/bootstrap-icons.min.css
rm -r $BOOTSTRAP_ICONS_TEMP
 No newline at end of file
+5 −0

File added.

Preview size limit exceeded, changes collapsed.

+172 KiB

File added.

Preview suppressed by a .gitattributes entry or the file's encoding is unsupported.

Loading