Skip to content

Commit 372ef3f

Browse files
committed
feat: toggle prefetching for files and folders
1 parent 521434f commit 372ef3f

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM php:8.4-fpm-alpine AS base
22

3-
ENV DIRBROWSER_VERSION=3.11.2
3+
ENV DIRBROWSER_VERSION=3.12.0
44

55
RUN apk update && apk upgrade
66

@@ -121,6 +121,10 @@ ENV WORKER_FORCE_RESCAN=
121121

122122
ENV PAGINATION_PER_PAGE=100
123123

124+
ENV PREFETCH_FOLDERS=true
125+
126+
ENV PREFETCH_FILES=false
127+
124128
EXPOSE 8080
125129

126130
CMD ["/init.sh"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Prefetching on Hover
2+
3+
By default, hovering over a folder link in the filetree will prefetch the contents of the folder. This can be disabled by setting the `PREFETCH_FOLDERS` environment variable to `false`.
4+
Prefetching of files is disabled by default because it downloads the file in the background and may increase the counter inadvertently. This can be enabled again by setting the `PREFETCH_FILES` environment variable to `true`.
5+
6+
import EnvConfig from '@site/src/components/EnvConfig';
7+
8+
<EnvConfig name="PREFETCH_FOLDERS|PREFETCH_FILES" init="true|false" values="true,false|true,false" versions="3.12|3.12"/>

src/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ function toggletheme() {
805805
$fileDate = new DateTime($file->modified_date);
806806
$diff = $now->diff($fileDate)->days;
807807
?>
808-
<a data-turbo-action="advance" data-file-selected="0" data-file-isdir="<?= $file->is_dir ? "1" : "0" ?>" data-file-name="<?= $file->name ?>" data-file-dl="$[if `process.env.DOWNLOAD_COUNTER === "true"`]$<?= $file->dl_count ?>$[end]$" data-file-size="<?= $file->size ?>" data-file-mod="<?= $file->modified_date ?>" href="${{`process.env.BASE_PATH ?? ''`}}$<?= $file->url ?><?= /* extra slash for dirs */ $file->is_dir ? "/" : "" ?>" class="row db-row py-2 db-file">
808+
<a data-turbo-prefetch="<?= $file->is_dir ? "${{env:PREFETCH_FOLDERS}}$" : "${{env:PREFETCH_FILES}}$" ?>" data-turbo-action="advance" data-file-selected="0" data-file-isdir="<?= $file->is_dir ? "1" : "0" ?>" data-file-name="<?= $file->name ?>" data-file-dl="$[if `process.env.DOWNLOAD_COUNTER === "true"`]$<?= $file->dl_count ?>$[end]$" data-file-size="<?= $file->size ?>" data-file-mod="<?= $file->modified_date ?>" href="${{`process.env.BASE_PATH ?? ''`}}$<?= $file->url ?><?= /* extra slash for dirs */ $file->is_dir ? "/" : "" ?>" class="row db-row py-2 db-file">
809809
<div class="col col-auto multiselect" style="display:none">
810810
<input class="form-check-input" style="padding:5px;pointer-events:none" type="checkbox" aria-label="..." />
811811
</div>

0 commit comments

Comments
 (0)