1
0
mirror of synced 2025-01-31 20:05:22 +01:00

feat: Allow users to open multiple files with the same name in the web version + make web Dockerfile able to run web server by itself (#1518)

This commit is contained in:
iTrooz 2024-01-26 19:52:05 +01:00 committed by GitHub
parent a4d6932ed8
commit b7349e42c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 8 deletions

View File

@ -39,7 +39,7 @@ jobs:
- name: 🛠️ Build using docker - name: 🛠️ Build using docker
run: | run: |
docker buildx build . -f dist/web/Dockerfile --progress=plain --build-arg 'JOBS=4' --output out docker buildx build . -f dist/web/Dockerfile --progress=plain --build-arg 'JOBS=4' --output out --target raw
- name: 🔨 Fix permissions - name: 🔨 Fix permissions
run: | run: |

5
dist/web/Dockerfile vendored
View File

@ -73,7 +73,7 @@ cp /imhex/dist/web/source/* /build
ccache -s ccache -s
EOF EOF
FROM scratch FROM scratch as raw
COPY --from=build [ \ COPY --from=build [ \
# ImHex \ # ImHex \
"/build/imhex.wasm", \ "/build/imhex.wasm", \
@ -94,3 +94,6 @@ COPY --from=build [ \
# Destination \ # Destination \
"./" \ "./" \
] ]
FROM nginx
COPY --from=raw . /usr/share/nginx/html

10
dist/web/compose.yml vendored Normal file
View File

@ -0,0 +1,10 @@
# docker compose -f dist/web/compose.yml --build up
version: '3'
services:
imhex_web:
image: imhex_web:latest
build:
context: ../../ # ImHex folder
dockerfile: ./dist/web/Dockerfile
ports:
- 8080:80

View File

@ -153,12 +153,14 @@ namespace hex::fs {
for (let file of selector.files) { for (let file of selector.files) {
const fr = new FileReader(); const fr = new FileReader();
fr.onload = () => { fr.onload = () => {
let path = "/openedFiles/"+file.name; let folder = "/openedFiles/"+Math.random().toString(36).substring(2)+"/";
if (FS.analyzePath(path).exists) { FS.createPath("/", folder);
FS.unlink(path); if (FS.analyzePath(folder+file.name).exists) {
console.log(`Error: ${folder+file.name} already exist`);
} else {
FS.createDataFile(folder, file.name, fr.result, true, true);
Module._fileBrowserCallback(stringToNewUTF8(folder+file.name));
} }
FS.createDataFile("/openedFiles/", file.name, fr.result, true, true);
Module._fileBrowserCallback(stringToNewUTF8(path));
}; };
fr.readAsBinaryString(file); fr.readAsBinaryString(file);