feat: add uploadedTime to index page
This commit is contained in:
parent
5252854f5d
commit
15c4997511
@ -35,6 +35,7 @@ var extensions = map[string]string{
|
|||||||
func DisplayFile(app *Application, file string, w http.ResponseWriter) {
|
func DisplayFile(app *Application, file string, w http.ResponseWriter) {
|
||||||
tmpl := template.Must(template.ParseFiles("templates/files.html"))
|
tmpl := template.Must(template.ParseFiles("templates/files.html"))
|
||||||
|
|
||||||
|
fileStat, _ := os.Stat("." + file)
|
||||||
fileContent, _ := os.ReadFile("." + file)
|
fileContent, _ := os.ReadFile("." + file)
|
||||||
|
|
||||||
fileInfo := FileInfo{
|
fileInfo := FileInfo{
|
||||||
@ -42,6 +43,9 @@ func DisplayFile(app *Application, file string, w http.ResponseWriter) {
|
|||||||
Path: filepath.Join(app.url, file),
|
Path: filepath.Join(app.url, file),
|
||||||
Type: getType(file),
|
Type: getType(file),
|
||||||
Content: string(fileContent),
|
Content: string(fileContent),
|
||||||
|
TimeUploaded: fileStat.ModTime().
|
||||||
|
UTC().
|
||||||
|
Format("2006-01-02 15:04:05 UTC"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := tmpl.Execute(w, fileInfo); err != nil {
|
if err := tmpl.Execute(w, fileInfo); err != nil {
|
||||||
|
@ -18,6 +18,7 @@ type FileInfo struct {
|
|||||||
FormattedSize string
|
FormattedSize string
|
||||||
Type string
|
Type string
|
||||||
Content string
|
Content string
|
||||||
|
TimeUploaded string
|
||||||
}
|
}
|
||||||
|
|
||||||
type TemplateData struct {
|
type TemplateData struct {
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
height: 100vh;
|
height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
header {
|
header,
|
||||||
|
footer {
|
||||||
background-color: #2e2e2e;
|
background-color: #2e2e2e;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
@ -101,6 +102,7 @@
|
|||||||
</video>
|
</video>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
<footer>file uploaded in {{.TimeUploaded}}</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user