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.

authored by oppi.li and committed by Tangled cf269c55 5ef51421

Changed files
+13 -5
appview
state
+13 -5
appview/state/repo.go
··· 319 319 user := s.auth.GetUser(r) 320 320 321 321 var breadcrumbs [][]string 322 - breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/%s/tree/%s", f.OwnerDid(), f.RepoName, ref)}) 322 + breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/tree/%s", f.OwnerSlashRepo(), ref)}) 323 323 if treePath != "" { 324 324 for idx, elem := range strings.Split(treePath, "/") { 325 325 breadcrumbs = append(breadcrumbs, []string{elem, fmt.Sprintf("%s/%s", breadcrumbs[idx][1], elem)}) 326 326 } 327 327 } 328 328 329 - baseTreeLink := path.Join(f.OwnerDid(), f.RepoName, "tree", ref, treePath) 330 - baseBlobLink := path.Join(f.OwnerDid(), f.RepoName, "blob", ref, treePath) 329 + baseTreeLink := path.Join(f.OwnerSlashRepo(), "tree", ref, treePath) 330 + baseBlobLink := path.Join(f.OwnerSlashRepo(), "blob", ref, treePath) 331 331 332 332 s.pages.RepoTree(w, pages.RepoTreeParams{ 333 333 LoggedInUser: user, ··· 454 454 } 455 455 456 456 var breadcrumbs [][]string 457 - breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/%s/tree/%s", f.OwnerDid(), f.RepoName, ref)}) 457 + breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/tree/%s", f.OwnerSlashRepo(), ref)}) 458 458 if filePath != "" { 459 459 for idx, elem := range strings.Split(filePath, "/") { 460 460 breadcrumbs = append(breadcrumbs, []string{elem, fmt.Sprintf("%s/%s", breadcrumbs[idx][1], elem)}) ··· 861 861 } 862 862 863 863 func (f *FullyResolvedRepo) OwnerSlashRepo() string { 864 - p, _ := securejoin.SecureJoin(f.OwnerDid(), f.RepoName) 864 + handle := f.OwnerId.Handle 865 + 866 + var p string 867 + if handle != "" && !handle.IsInvalidHandle() { 868 + p, _ = securejoin.SecureJoin(fmt.Sprintf("@%s", handle), f.RepoName) 869 + } else { 870 + p, _ = securejoin.SecureJoin(f.OwnerDid(), f.RepoName) 871 + } 872 + 865 873 return p 866 874 } 867 875