Skip to content

Commit

Permalink
add default file handlers to files api
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Jan 14, 2024
1 parent 2f45bdf commit 421f040
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/libfileview.app/fileHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ function openFile (path) {
case 'py':
runPython(path)
break;
default:
openText(path)
break;

}
}
Expand Down
6 changes: 6 additions & 0 deletions src/api/Files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ class FilesAPI {
(await (await fetch(handler)).text()) +
`openFile(${JSON.stringify(path)})`,
); // here, JSON.stringify is used to properly escape the string
} else if (extHandlers["default"]) {
const handler = extHandlers["default"];
eval(
(await (await fetch(handler)).text()) +
`openFile(${JSON.stringify(path)})`,
); // here, JSON.stringify is used to properly escape the string
}
};

Expand Down
5 changes: 5 additions & 0 deletions src/oobe/OobeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ class OobeView {
if (anura.settings.get("use-sw-cache")) await preloadFiles();
console.log("Cached important files");
// Register default filehandlers

anura.files.set(
"/apps/libfileview.app/fileHandler.js",
"default",
);
anura.files.set("/apps/libfileview.app/fileHandler.js", "txt");
anura.files.set("/apps/libfileview.app/fileHandler.js", "mp3");
anura.files.set("/apps/libfileview.app/fileHandler.js", "flac");
Expand Down

0 comments on commit 421f040

Please sign in to comment.