Skip to content

Commit

Permalink
feat: redirect to another link if file is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
jabuxas committed Oct 17, 2024
1 parent 18bc590 commit 7ed16a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions file_display.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -59,5 +59,5 @@ func getType(file string) string {
if fileType, exists := extensions[extension]; exists {
return fileType
}
return "text"
return "unknown"
}
10 changes: 10 additions & 0 deletions templates/files.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@
border-radius: 10px;
border: 3px solid #2e2e2e;
}

a {
color: #0288d1;
text-decoration: none;
}
</style>
</head>

Expand All @@ -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>
Expand Down

0 comments on commit 7ed16a5

Please sign in to comment.