From 13202cc6b1b31dbf16a657f847df240cb35fa157 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Fri, 2 Jul 2021 15:28:27 -0400 Subject: [PATCH 1/3] Ensure existence of static build dir --- .gitignore | 2 +- app/__init__.py | 7 ++++++- app/static/build/.gitignore | 2 ++ run | 2 -- 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 app/static/build/.gitignore diff --git a/.gitignore b/.gitignore index caa4595..32c54ce 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,6 @@ app/static/custom_config app/static/bangs # pip stuff -build/ +/build/ dist/ *.egg-info/ diff --git a/app/__init__.py b/app/__init__.py index f77b281..294053c 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -101,7 +101,12 @@ for cb_dir in cache_busting_dirs: full_cb_path = os.path.join(full_cb_dir, cb_file) cb_file_link = gen_file_hash(full_cb_dir, cb_file) build_path = os.path.join(app.config['BUILD_FOLDER'], cb_file_link) - os.symlink(full_cb_path, build_path) + + try: + os.symlink(full_cb_path, build_path) + except FileExistsError: + # Symlink hasn't changed, ignore + pass # Create mapping for relative path urls map_path = build_path.replace(app.config['APP_ROOT'], '') diff --git a/app/static/build/.gitignore b/app/static/build/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/app/static/build/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/run b/run index 25fdf15..4ace594 100755 --- a/run +++ b/run @@ -12,8 +12,6 @@ SUBDIR="${1:-app}" export APP_ROOT="$SCRIPT_DIR/$SUBDIR" export STATIC_FOLDER="$APP_ROOT/static" -rm -rf $STATIC_FOLDER/build - # Check for regular vs test run if [[ "$SUBDIR" == "test" ]]; then # Set up static files for testing From 958faed1b6c6d683c337ccb112eef46c1d41f178 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Fri, 2 Jul 2021 16:13:42 -0400 Subject: [PATCH 2/3] Set user ownership of static build dir --- Dockerfile | 3 +++ docker-compose.yml | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e584383..65ba191 100644 --- a/Dockerfile +++ b/Dockerfile @@ -67,6 +67,9 @@ COPY app/ app/ COPY run . COPY whoogle.env . +# Allow writing symlinks to build dir +RUN chown 102:102 app/static/build + EXPOSE $EXPOSE_PORT HEALTHCHECK --interval=30s --timeout=5s \ diff --git a/docker-compose.yml b/docker-compose.yml index 3fba776..dbb741b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,6 @@ services: - no-new-privileges cap_drop: - ALL - read_only: true tmpfs: - /config/:size=10M,uid=102,gid=102,mode=1700 - /var/lib/tor/:size=10M,uid=102,gid=102,mode=1700 From 38c38a772fa6154169e3e5b34c89e2b6fd2ef6bd Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Sun, 4 Jul 2021 15:20:19 -0400 Subject: [PATCH 3/3] Find valid parent element when collapsing result content Previously if a result element marked for collapsing didn't have a valid "parent" element, the collapsing was skipped altogether. This loops through child elements until a valid parent is found (or if one isn't found, the element will not be collapsed). --- app/filter.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/filter.py b/app/filter.py index 215bfe7..87d00a2 100644 --- a/app/filter.py +++ b/app/filter.py @@ -173,8 +173,12 @@ class Filter: break # Create the new details element to wrap around the result's - # immediate parent - parent = result_children[0].parent + # first parent + parent = None + idx = 0 + while not parent and idx < len(result_children): + parent = result_children[idx].parent + idx += 1 details = BeautifulSoup(features='html.parser').new_tag('details') summary = BeautifulSoup(features='html.parser').new_tag('summary') summary.string = label