forked from tangled.org/core
this repo has no description

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
···
user := s.auth.GetUser(r)
var breadcrumbs [][]string
-
breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/%s/tree/%s", f.OwnerDid(), f.RepoName, ref)})
+
breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/tree/%s", f.OwnerSlashRepo(), ref)})
if treePath != "" {
for idx, elem := range strings.Split(treePath, "/") {
breadcrumbs = append(breadcrumbs, []string{elem, fmt.Sprintf("%s/%s", breadcrumbs[idx][1], elem)})
}
}
-
baseTreeLink := path.Join(f.OwnerDid(), f.RepoName, "tree", ref, treePath)
-
baseBlobLink := path.Join(f.OwnerDid(), f.RepoName, "blob", ref, treePath)
+
baseTreeLink := path.Join(f.OwnerSlashRepo(), "tree", ref, treePath)
+
baseBlobLink := path.Join(f.OwnerSlashRepo(), "blob", ref, treePath)
s.pages.RepoTree(w, pages.RepoTreeParams{
LoggedInUser: user,
···
}
var breadcrumbs [][]string
-
breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/%s/tree/%s", f.OwnerDid(), f.RepoName, ref)})
+
breadcrumbs = append(breadcrumbs, []string{f.RepoName, fmt.Sprintf("/%s/tree/%s", f.OwnerSlashRepo(), ref)})
if filePath != "" {
for idx, elem := range strings.Split(filePath, "/") {
breadcrumbs = append(breadcrumbs, []string{elem, fmt.Sprintf("%s/%s", breadcrumbs[idx][1], elem)})
···
}
func (f *FullyResolvedRepo) OwnerSlashRepo() string {
-
p, _ := securejoin.SecureJoin(f.OwnerDid(), f.RepoName)
+
handle := f.OwnerId.Handle
+
+
var p string
+
if handle != "" && !handle.IsInvalidHandle() {
+
p, _ = securejoin.SecureJoin(fmt.Sprintf("@%s", handle), f.RepoName)
+
} else {
+
p, _ = securejoin.SecureJoin(f.OwnerDid(), f.RepoName)
+
}
+
return p
}