Fix rendering bug with folders
alex wennerberg alex@alexwennerberg.com
Wed, 18 Nov 2020 18:47:15 -0800
3 files changed,
8 insertions(+),
6 deletions(-)
M
main.go
→
main.go
@@ -29,6 +29,7 @@ UpdatedTime time.Time
TimeAgo string IsText bool Children []*File + Host string } type User struct {@@ -119,7 +120,7 @@ }
return result, nil } // todo clean up paths -func getFiles(p string) ([]*File, error) { +func getMyFilesRecursive(p string, creator string) ([]*File, error) { result := []*File{} files, err := ioutil.ReadDir(p) if err != nil {@@ -130,13 +131,14 @@ isText := strings.HasPrefix(mime.TypeByExtension(path.Ext(file.Name())), "text")
fullPath := path.Join(p, file.Name()) localPath := getLocalPath(fullPath) f := &File{ - Name: localPath, - // Creator: strings.Split(p, "/")[0], + Name: localPath, + Creator: creator, UpdatedTime: file.ModTime(), IsText: isText, + Host: c.Host, } if file.IsDir() { - f.Children, err = getFiles(path.Join(p, file.Name())) + f.Children, err = getMyFilesRecursive(path.Join(p, file.Name()), creator) } result = append(result, f) }
M
templates/my_site.html
→
templates/my_site.html
@@ -27,7 +27,7 @@ </details>
</td> {{ else }} <td> - <a href="//authUser.domain/{{.Name}}"> + <a href="//{{.Creator}}.{{.Host}}/{{.Name}}"> {{ .Name }}</a> </td> <td>