Monorepo for Tangled tangled.org

appview: state/repo: do not switch to dids in links

fixes a a few links in blob and tree views that caused the link to
switch from handle to did.

Changed files
+13 -5
appview
state
+13 -5
appview/state/repo.go
··· 312 312 user := s.auth.GetUser(r) 313 313 314 314 var breadcrumbs [][]string 315 - breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/%s/tree/%s", f.OwnerDid(), f.RepoName, ref)}) 315 + breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/tree/%s", f.OwnerSlashRepo(), ref)}) 316 316 if treePath != "" { 317 317 for idx, elem := range strings.Split(treePath, "/") { 318 318 breadcrumbs = append(breadcrumbs, []string{elem, fmt.Sprintf("%s/%s", breadcrumbs[idx][1], elem)}) 319 319 } 320 320 } 321 321 322 - baseTreeLink := path.Join(f.OwnerDid(), f.RepoName, "tree", ref, treePath) 323 - baseBlobLink := path.Join(f.OwnerDid(), f.RepoName, "blob", ref, treePath) 322 + baseTreeLink := path.Join(f.OwnerSlashRepo(), "tree", ref, treePath) 323 + baseBlobLink := path.Join(f.OwnerSlashRepo(), "blob", ref, treePath) 324 324 325 325 s.pages.RepoTree(w, pages.RepoTreeParams{ 326 326 LoggedInUser: user, ··· 447 447 } 448 448 449 449 var breadcrumbs [][]string 450 - breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/%s/tree/%s", f.OwnerDid(), f.RepoName, ref)}) 450 + breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/tree/%s", f.OwnerSlashRepo(), ref)}) 451 451 if filePath != "" { 452 452 for idx, elem := range strings.Split(filePath, "/") { 453 453 breadcrumbs = append(breadcrumbs, []string{elem, fmt.Sprintf("%s/%s", breadcrumbs[idx][1], elem)}) ··· 854 854 } 855 855 856 856 func (f *FullyResolvedRepo) OwnerSlashRepo() string { 857 - p, _ := securejoin.SecureJoin(f.OwnerDid(), f.RepoName) 857 + handle := f.OwnerId.Handle 858 + 859 + var p string 860 + if handle != "" && !handle.IsInvalidHandle() { 861 + p, _ = securejoin.SecureJoin(fmt.Sprintf("@%s", handle), f.RepoName) 862 + } else { 863 + p, _ = securejoin.SecureJoin(f.OwnerDid(), f.RepoName) 864 + } 865 + 858 866 return p 859 867 } 860 868