From 71c8d18cd9005a2915a07ffc2af48827b39e4d05 Mon Sep 17 00:00:00 2001 From: Simon Roberts Date: Fri, 5 Jul 2024 18:36:17 +1000 Subject: [PATCH 1/4] Add adhoc tool for generating a local site --- code/adhoc_tools.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/code/adhoc_tools.py b/code/adhoc_tools.py index 505e827410..11a039c2a2 100755 --- a/code/adhoc_tools.py +++ b/code/adhoc_tools.py @@ -399,6 +399,38 @@ def dump_status_tech_upgrade(): pprint.pprint(tallies) +def generate_local_website(): + """Generate a version of the website with all data local.""" + # copy index.html -> index-local.html + with open("./site/index.html") as f: + index_html = f.read().replace('main.js', 'main-local.js') + with open("./site/index-local.html", "w") as f: + f.write(index_html) + + # copy main.js -> main-local.js + with open("./site/main.js") as f: + gh_prefix = 'https://raw.githubusercontent.com/LukePrior/nbn-upgrade-map' + main_js = (f.read() + # use local results files + .replace(gh_prefix + '/main/results', '../results') + .replace(gh_prefix + '/" + commit + "/results', '../results') + # disable serviceworkerr + .replace('navigator.serviceWorker.', '// ') + # disable date selector + .replace("addControlWithHTML('date-selector'", '// ') + .replace('fetch(commits_url)', 'new Promise( () => {} )') + # disable gtagr + .replace('gtag(', '// gtag(') + ) + + with open("./site/main-local.js", "w") as f: + f.write(main_js) + + # to view this locally, start a simple web-server with the following command (from the top level directory): + # python -m http.server 8000 + # and open http://localhost:8000/index-local.html + + if __name__ == "__main__": LOGLEVEL = os.environ.get("LOGLEVEL", "INFO").upper() logging.basicConfig(level=LOGLEVEL, format="%(asctime)s %(levelname)s %(threadName)s %(message)s") From 9c2d373a389175ae0e30de70092db5eb76722333 Mon Sep 17 00:00:00 2001 From: lyricnz Date: Fri, 5 Jul 2024 08:37:28 +0000 Subject: [PATCH 2/4] [MegaLinter] Apply linters fixes --- code/adhoc_tools.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/code/adhoc_tools.py b/code/adhoc_tools.py index 11a039c2a2..8f22f5266f 100755 --- a/code/adhoc_tools.py +++ b/code/adhoc_tools.py @@ -403,25 +403,26 @@ def generate_local_website(): """Generate a version of the website with all data local.""" # copy index.html -> index-local.html with open("./site/index.html") as f: - index_html = f.read().replace('main.js', 'main-local.js') + index_html = f.read().replace("main.js", "main-local.js") with open("./site/index-local.html", "w") as f: f.write(index_html) # copy main.js -> main-local.js with open("./site/main.js") as f: - gh_prefix = 'https://raw.githubusercontent.com/LukePrior/nbn-upgrade-map' - main_js = (f.read() - # use local results files - .replace(gh_prefix + '/main/results', '../results') - .replace(gh_prefix + '/" + commit + "/results', '../results') - # disable serviceworkerr - .replace('navigator.serviceWorker.', '// ') - # disable date selector - .replace("addControlWithHTML('date-selector'", '// ') - .replace('fetch(commits_url)', 'new Promise( () => {} )') - # disable gtagr - .replace('gtag(', '// gtag(') - ) + gh_prefix = "https://raw.githubusercontent.com/LukePrior/nbn-upgrade-map" + main_js = ( + f.read() + # use local results files + .replace(gh_prefix + "/main/results", "../results") + .replace(gh_prefix + '/" + commit + "/results', "../results") + # disable serviceworkerr + .replace("navigator.serviceWorker.", "// ") + # disable date selector + .replace("addControlWithHTML('date-selector'", "// ") + .replace("fetch(commits_url)", "new Promise( () => {} )") + # disable gtagr + .replace("gtag(", "// gtag(") + ) with open("./site/main-local.js", "w") as f: f.write(main_js) From a6631542345a8223bfcbdbcb5d5a6c5f7d9aa20c Mon Sep 17 00:00:00 2001 From: Simon Roberts Date: Fri, 5 Jul 2024 18:41:14 +1000 Subject: [PATCH 3/4] Fix local URL --- code/adhoc_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/adhoc_tools.py b/code/adhoc_tools.py index 8f22f5266f..6fd36ce62f 100755 --- a/code/adhoc_tools.py +++ b/code/adhoc_tools.py @@ -429,7 +429,7 @@ def generate_local_website(): # to view this locally, start a simple web-server with the following command (from the top level directory): # python -m http.server 8000 - # and open http://localhost:8000/index-local.html + # and open http://localhost:8000/site/index-local.html if __name__ == "__main__": From e2def4537e2afe3212d8123c5948f301b5859ba5 Mon Sep 17 00:00:00 2001 From: Simon Roberts Date: Fri, 5 Jul 2024 18:44:51 +1000 Subject: [PATCH 4/4] fix comment --- code/adhoc_tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/adhoc_tools.py b/code/adhoc_tools.py index 6fd36ce62f..864621d3aa 100755 --- a/code/adhoc_tools.py +++ b/code/adhoc_tools.py @@ -420,7 +420,7 @@ def generate_local_website(): # disable date selector .replace("addControlWithHTML('date-selector'", "// ") .replace("fetch(commits_url)", "new Promise( () => {} )") - # disable gtagr + # disable gtags .replace("gtag(", "// gtag(") )