mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-22 17:19:39 +02:00
feat: improve support for binary & audio files
This commit is contained in:
@@ -6,8 +6,10 @@
|
|||||||
<div class="h-100 overflow-auto" ng-if="type == 'pdf'">
|
<div class="h-100 overflow-auto" ng-if="type == 'pdf'">
|
||||||
<pdfviewer class="h-100 overflow-auto" src="{{url}}" id="viewer"></pdfviewer>
|
<pdfviewer class="h-100 overflow-auto" src="{{url}}" id="viewer"></pdfviewer>
|
||||||
</div>
|
</div>
|
||||||
|
<div ng-if="type == 'audio'"><audio controls="controls"><source src="{{url}}" /></audio></div>
|
||||||
<div ng-if="type == 'IPython'"><notebook file="url"></notebook></div>
|
<div ng-if="type == 'IPython'"><notebook file="url"></notebook></div>
|
||||||
<div ng-if="type == 'error'" class="file-error container d-flex h-100"><h1 class="display-1 m-auto" translate="ERRORS.{{content}}">Error</h1></div></div>
|
<div ng-if="type == 'error'" class="file-error container d-flex h-100"><h1 class="display-1 m-auto" translate="ERRORS.{{content}}">Error</h1></div></div>
|
||||||
<div ng-if="type == 'loading' && !error" class="file-error container d-flex h-100"><h1 class="display-1 m-auto">Loading...</h1></div></div>
|
<div ng-if="type == 'loading' && !error" class="file-error container d-flex h-100"><h1 class="display-1 m-auto">Loading...</h1></div></div>
|
||||||
<div ng-if="type == 'empty'" class="file-error container d-flex h-100"><h1 class="display-1 m-auto">Empty repository!</h1></div>
|
<div ng-if="type == 'empty'" class="file-error container d-flex h-100"><h1 class="display-1 m-auto">Empty repository!</h1></div>
|
||||||
<div ng-if="content == null && type != 'empty'" class="file-error container d-flex h-100"><h1 class="display-1 m-auto">Empty file!</h1></div>
|
<div ng-if="content == null && type != 'empty'" class="file-error container d-flex h-100"><h1 class="display-1 m-auto">Empty file!</h1></div>
|
||||||
|
<div ng-if="type == 'binary'" class="file-error container d-flex h-100"><h1 class="display-1 m-auto">Unsupported binary file. You can download the file: <a target="_blank" ng-href="{{url}}&download=true">here</a>.</h1></div>
|
||||||
+22
-5
@@ -1511,16 +1511,24 @@ angular
|
|||||||
"heif",
|
"heif",
|
||||||
"heic",
|
"heic",
|
||||||
];
|
];
|
||||||
|
const audioFiles = ["wav", "mp3", "ogg", "wma", "flac", "aac", "m4a"];
|
||||||
const mediaFiles = [
|
const mediaFiles = [
|
||||||
"wav",
|
|
||||||
"mp3",
|
|
||||||
"ogg",
|
|
||||||
"mp4",
|
"mp4",
|
||||||
"avi",
|
"avi",
|
||||||
"webm",
|
"webm",
|
||||||
"mov",
|
"mov",
|
||||||
"mpg",
|
"mpg",
|
||||||
"wma",
|
"mpeg",
|
||||||
|
"mkv",
|
||||||
|
"flv",
|
||||||
|
"wmv",
|
||||||
|
"3gp",
|
||||||
|
"3g2",
|
||||||
|
"m4v",
|
||||||
|
"f4v",
|
||||||
|
"f4p",
|
||||||
|
"f4a",
|
||||||
|
"f4b",
|
||||||
];
|
];
|
||||||
|
|
||||||
$scope.$on("$routeUpdate", function (event, current) {
|
$scope.$on("$routeUpdate", function (event, current) {
|
||||||
@@ -1647,6 +1655,9 @@ angular
|
|||||||
if (mediaFiles.indexOf(extension) > -1) {
|
if (mediaFiles.indexOf(extension) > -1) {
|
||||||
return "media";
|
return "media";
|
||||||
}
|
}
|
||||||
|
if (audioFiles.indexOf(extension) > -1) {
|
||||||
|
return "audio";
|
||||||
|
}
|
||||||
return "code";
|
return "code";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1693,6 +1704,13 @@ angular
|
|||||||
$scope.content = $sce.trustAsHtml(orgHTMLDocument.toString());
|
$scope.content = $sce.trustAsHtml(orgHTMLDocument.toString());
|
||||||
$scope.type = "html";
|
$scope.type = "html";
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
$scope.type == "code" &&
|
||||||
|
res.headers("content-type") == "application/octet-stream"
|
||||||
|
) {
|
||||||
|
$scope.type = "binary";
|
||||||
|
$scope.content = "binary";
|
||||||
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
Prism.highlightAll();
|
Prism.highlightAll();
|
||||||
}, 50);
|
}, 50);
|
||||||
@@ -1844,7 +1862,6 @@ angular
|
|||||||
$scope.type = "empty";
|
$scope.type = "empty";
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$scope.$apply(() => {
|
$scope.$apply(() => {
|
||||||
selectFile();
|
selectFile();
|
||||||
updateContent();
|
updateContent();
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -41,6 +41,8 @@ router.post("/", async (req: express.Request, res: express.Response) => {
|
|||||||
anonymizer.once("transform", (data) => {
|
anonymizer.once("transform", (data) => {
|
||||||
if (!mime && data.isText) {
|
if (!mime && data.isText) {
|
||||||
res.contentType("text/plain");
|
res.contentType("text/plain");
|
||||||
|
} else if (!mime && !data.isText) {
|
||||||
|
res.contentType("application/octet-stream");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
function handleStreamError(error: Error) {
|
function handleStreamError(error: Error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user