feat: add uploadedTime to index page

This commit is contained in:
jabuxas 2024-10-16 22:17:17 -03:00
parent 5252854f5d
commit 15c4997511
3 changed files with 8 additions and 1 deletions

View File

@ -35,6 +35,7 @@ var extensions = map[string]string{
func DisplayFile(app *Application, file string, w http.ResponseWriter) {
tmpl := template.Must(template.ParseFiles("templates/files.html"))
fileStat, _ := os.Stat("." + file)
fileContent, _ := os.ReadFile("." + file)
fileInfo := FileInfo{
@ -42,6 +43,9 @@ func DisplayFile(app *Application, file string, w http.ResponseWriter) {
Path: filepath.Join(app.url, file),
Type: getType(file),
Content: string(fileContent),
TimeUploaded: fileStat.ModTime().
UTC().
Format("2006-01-02 15:04:05 UTC"),
}
if err := tmpl.Execute(w, fileInfo); err != nil {

View File

@ -18,6 +18,7 @@ type FileInfo struct {
FormattedSize string
Type string
Content string
TimeUploaded string
}
type TemplateData struct {

View File

@ -17,7 +17,8 @@
height: 100vh;
}
header {
header,
footer {
background-color: #2e2e2e;
text-align: center;
font-size: 1rem;
@ -101,6 +102,7 @@
</video>
{{end}}
</div>
<footer>file uploaded in {{.TimeUploaded}}</footer>
</body>
</html>