diff --git a/file_display.go b/file_display.go index 7cb9a0a..612abb1 100644 --- a/file_display.go +++ b/file_display.go @@ -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 { diff --git a/helpers.go b/helpers.go index 6b60152..18168fa 100644 --- a/helpers.go +++ b/helpers.go @@ -18,6 +18,7 @@ type FileInfo struct { FormattedSize string Type string Content string + TimeUploaded string } type TemplateData struct { diff --git a/templates/files.html b/templates/files.html index 7d1f5ef..24cccb2 100644 --- a/templates/files.html +++ b/templates/files.html @@ -17,7 +17,8 @@ height: 100vh; } - header { + header, + footer { background-color: #2e2e2e; text-align: center; font-size: 1rem; @@ -101,6 +102,7 @@ {{end}} +