diff --git a/scripts/generate.py b/scripts/generate.py index 2013e4c..fa7a12f 100644 --- a/scripts/generate.py +++ b/scripts/generate.py @@ -24,6 +24,10 @@ EXTENSIONS = [ ".org.txt", ] +WATCH = True +if os.getenv('WATCH_AND_REBUILD', '1') == '0': + WATCH = False + MIN_HIDDEN_HEADLINE_LEVEL = 2 INDEX_ID = "ea48ec1d-f9d4-4fb7-b39a-faa7b6e2ba95" SITE_NAME = "Código para llevar" @@ -237,8 +241,12 @@ def main(src_top, dest_top): db = create_db(os.path.join(dest_top, 'db.sqlite3')) docs = regen_all(src_top, dest_top, db=db) - logging.info("Initial load completed in {:.2f}s".format(time.time() - t0)) + if not WATCH: + logging.info("Build completed in {:.2f}s".format(time.time() - t0)) + return 0 + + logging.info("Initial load completed in {:.2f}s".format(time.time() - t0)) ## Updating for event in notifier.event_gen(yield_nones=False): (ev, types, directory, file) = event @@ -506,4 +514,4 @@ if __name__ == "__main__": exit(0) logging.basicConfig(level=logging.INFO, format="%(levelname)-8s %(message)s") - main(sys.argv[1], sys.argv[2]) + exit(main(sys.argv[1], sys.argv[2])) diff --git a/scripts/upload-homepage.sh b/scripts/upload-homepage.sh deleted file mode 100644 index 8d475ef..0000000 --- a/scripts/upload-homepage.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -eu - -cd "$(dirname "$0")/.." - -cd static -scp homepage.html root@codigoparallevar.com:/mnt/vols/misc/codigoparallevar/index.html diff --git a/scripts/upload.sh b/scripts/upload.sh new file mode 100644 index 0000000..ca0a213 --- /dev/null +++ b/scripts/upload.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -eu + +cd "$(dirname "$0")/.." + +# Upload homepage +cd static +scp homepage.html root@codigoparallevar.com:/mnt/vols/misc/codigoparallevar/index.html + +# Build notes +cd ../scripts +WATCH_AND_REBUILD=0 python3 generate.py ~/.logs/brain ../_gen/notes + +# Upload notes +cd ../_gen +rsync -HPaz static/ --delete-after --exclude='*.html' root@codigoparallevar.com:/mnt/vols/misc/codigoparallevar/static/ +rsync -HPaz notes/ --delete-after --exclude='xapian' --exclude='*.sqlite3' root@codigoparallevar.com:/mnt/vols/misc/codigoparallevar/notes/ +rsync -HPaz notes/db.sqlite3 root@codigoparallevar.com:/mnt/vols/misc/codigoparallevar-api/ + +# Restart API server +ssh root@codigoparallevar.com docker restart notes-api-server diff --git a/static/search-box.js b/static/search-box.js index e2ebd80..54e518f 100644 --- a/static/search-box.js +++ b/static/search-box.js @@ -47,7 +47,7 @@ function _codigoparallevar_enable_search_box(selector, options) { const DEBOUNCE_TIME = 500; // Milliseconds const MIN_LENGTH = 3; - const SEARCH_ENDPOINT = 'http://localhost:3001/api/search'; + const SEARCH_ENDPOINT = 'https://api.codigoparallevar.com/api/search'; let debounceWaiter = null; let currentQuery = null;