···270270}
271271272272// documentView is the shared implementation for viewing a document given an ownerDID and rkey.
273273-func (h *Handler) documentView(w http.ResponseWriter, r *http.Request, ownerUserID, ownerDID, rkey string) {
273273+// isOwner should be true when the current user owns the document; it suppresses the ownerDID
274274+// in the template so the edit button links to /docs/{rkey}/edit rather than the collaborator URL.
275275+func (h *Handler) documentView(w http.ResponseWriter, r *http.Request, ownerUserID, ownerDID, rkey string, isOwner bool) {
274276 client, err := h.xrpcClient(ownerUserID)
275277 if err != nil {
276278 http.Error(w, "Could not connect to PDS", 500)
···301303 Rendered template.HTML
302304 OwnerDID string // non-empty when viewing a collaborator's document
303305 }
306306+ // Only set OwnerDID when the viewer is not the owner; the template uses
307307+ // a non-empty OwnerDID to generate the collaborator edit URL.
308308+ templateOwnerDID := ownerDID
309309+ if isOwner {
310310+ templateOwnerDID = ""
311311+ }
304312 h.render(w, "document_view.html", PageData{
305313 Title: doc.Title,
306314 User: user,
307307- Content: DocumentViewData{Doc: doc, Rendered: template.HTML(rendered), OwnerDID: ownerDID},
315315+ Content: DocumentViewData{Doc: doc, Rendered: template.HTML(rendered), OwnerDID: templateOwnerDID},
308316 })
309317}
310318···322330 http.Error(w, "Could not connect to PDS", 500)
323331 return
324332 }
325325-326326- h.documentView(w, r, user.ID, client.DID(), rkey)
333333+ h.documentView(w, r, user.ID, client.DID(), rkey, true)
327334}
328335329336// CollaboratorDocumentView renders a document owned by another user (collaborator access).
···343350 return
344351 }
345352346346- h.documentView(w, r, ownerUser.ID, ownerDID, rkey)
353353+ h.documentView(w, r, ownerUser.ID, ownerDID, rkey, false)
347354}
348355349356// documentEdit is the shared implementation for the edit page.