feat: add uploadedTime to index page
This commit is contained in:
parent
4384cfaa35
commit
8ec85fdc1b
@ -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 {
|
||||
|
@ -18,6 +18,7 @@ type FileInfo struct {
|
||||
FormattedSize string
|
||||
Type string
|
||||
Content string
|
||||
TimeUploaded string
|
||||
}
|
||||
|
||||
type TemplateData struct {
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user