Parse CSV files into HTML tables

This commit is contained in:
Thomas Miceli
2023-03-19 03:18:56 +01:00
parent 11b3eed250
commit 858ee3e70a
5 changed files with 108 additions and 13 deletions

View File

@ -11,6 +11,7 @@ import (
"io"
"net/http"
"opengist/internal/config"
"opengist/internal/git"
"opengist/internal/models"
"path/filepath"
"regexp"
@ -77,6 +78,21 @@ func Start() {
"isMarkdown": func(i string) bool {
return ".md" == strings.ToLower(filepath.Ext(i))
},
"isCsv": func(i string) bool {
return ".csv" == strings.ToLower(filepath.Ext(i))
},
"csvFile": func(file *git.File) *git.CsvFile {
if ".csv" != strings.ToLower(filepath.Ext(file.Filename)) {
return nil
}
csvFile, err := git.ParseCsv(file)
if err != nil {
return nil
}
return csvFile
},
"httpStatusText": http.StatusText,
"loadedTime": func(startTime time.Time) string {
return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms"