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
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
run: |

7
dist/web/Dockerfile vendored
View file

@ -73,7 +73,7 @@ cp /imhex/dist/web/source/* /build
ccache -s
EOF
FROM scratch
FROM scratch as raw
COPY --from=build [ \
# ImHex \
"/build/imhex.wasm", \
@ -93,4 +93,7 @@ COPY --from=build [ \
\
# 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) {
const fr = new FileReader();
fr.onload = () => {
let path = "/openedFiles/"+file.name;
if (FS.analyzePath(path).exists) {
FS.unlink(path);
let folder = "/openedFiles/"+Math.random().toString(36).substring(2)+"/";
FS.createPath("/", folder);
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);