diff --git a/qt/aqt/mediasrv.py b/qt/aqt/mediasrv.py index 3985313a7..0e9f7b5e8 100644 --- a/qt/aqt/mediasrv.py +++ b/qt/aqt/mediasrv.py @@ -27,7 +27,8 @@ from aqt.utils import aqt_data_folder def _getExportFolder() -> str: - data_folder = aqt_data_folder() + if not (data_folder := os.getenv("ANKI_DATA_FOLDER")): + data_folder = aqt_data_folder() webInSrcFolder = os.path.abspath(os.path.join(data_folder, "web")) if os.path.exists(webInSrcFolder): return webInSrcFolder diff --git a/scripts/ts-run b/scripts/ts-run new file mode 100755 index 000000000..7d93035f6 --- /dev/null +++ b/scripts/ts-run @@ -0,0 +1,10 @@ +#!/bin/bash +# +# Start Anki with the data folder pointed at bazel-bin, +# which is useful when developing TS pages on a Mac. +# +# The pages can be accessed by, eg surfing to +# http://localhost:40000/_anki/pages/deckconfig.html + +ANKI_DATA_FOLDER=$(pwd)/bazel-bin/qt/aqt/data \ + ANKI_API_PORT=40000 ANKIDEV=1 ./run diff --git a/scripts/ts-watch b/scripts/ts-watch new file mode 100755 index 000000000..ba2c73235 --- /dev/null +++ b/scripts/ts-watch @@ -0,0 +1,13 @@ +#!/bin/bash +# +# Monitor the ts folder and rebuild aqt's data each time +# it changes, for testing pages locally. +# +# On a Mac, useful to combine with ts-run. + +# run once at startup +cmd='printf \\033c\\n; bazel build qt:runanki' +sh -c "$cmd" + +# then monitor for changes +fswatch -r -o ts | xargs -n1 -I{} sh -c "$cmd" \ No newline at end of file