all repos — flounder @ b74ecaec8871cf7641c243b21a2f006f3c0d1968

A small site builder for the Gemini protocol

Fix rendering bug  with folders
alex wennerberg alex@alexwennerberg.com
Wed, 18 Nov 2020 18:47:15 -0800
commit

b74ecaec8871cf7641c243b21a2f006f3c0d1968

parent

30103dd54397d530516bf19dc2d6ae1278fe42c8

3 files changed, 8 insertions(+), 6 deletions(-)

jump to
M http.gohttp.go

@@ -207,7 +207,7 @@ return

} // check auth userFolder := path.Join(c.FilesDirectory, authUser) - files, _ := getFiles(userFolder) + files, _ := getMyFilesRecursive(userFolder, authUser) data := struct { Host string PageTitle string
M main.gomain.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.htmltemplates/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>