feat: redirect to another link if file is not supported
This commit is contained in:
parent
18bc590525
commit
7ed16a5397
@ -29,7 +29,7 @@ var extensions = map[string]string{
|
||||
".log": "text", ".txt": "text", ".csv": "text",
|
||||
".json": "text", ".env": "text", ".sum": "text",
|
||||
".gitignore": "text", ".dockerfile": "text", ".Makefile": "text",
|
||||
".rst": "text",
|
||||
".rst": "text", ".el": "text",
|
||||
}
|
||||
|
||||
func DisplayFile(app *Application, file string, w http.ResponseWriter) {
|
||||
@ -59,5 +59,5 @@ func getType(file string) string {
|
||||
if fileType, exists := extensions[extension]; exists {
|
||||
return fileType
|
||||
}
|
||||
return "text"
|
||||
return "unknown"
|
||||
}
|
||||
|
@ -187,6 +187,11 @@
|
||||
border-radius: 10px;
|
||||
border: 3px solid #2e2e2e;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #0288d1;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@ -204,6 +209,11 @@
|
||||
<source src="{{.Name}}" type="video/mp4" />
|
||||
Your browser does not support the video tag.
|
||||
</video>
|
||||
{{else}}
|
||||
<p>
|
||||
Couldn't detect file from extension, visit
|
||||
<a href="http://{{.Path}}">this link</a> to see/download your file.
|
||||
</p>
|
||||
{{end}}
|
||||
</div>
|
||||
<footer>file uploaded in {{.TimeUploaded}}</footer>
|
||||
|
Loading…
Reference in New Issue
Block a user