Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions golink.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,10 +664,10 @@ func acceptHTML(r *http.Request) bool {
// detailData is the data used by the detailTmpl template.
type detailData struct {
// Editable indicates whether the current user can edit the link.
Editable bool
Link *Link
XSRF string
Message string
Editable bool
Link *Link
XSRF string
AlreadyExists bool
}

func serveDetail(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -714,7 +714,7 @@ func serveDetail(w http.ResponseWriter, r *http.Request) {
XSRF: xsrftoken.Generate(xsrfKey, cu.login, link.Short),
}
if r.URL.Query().Get("exists") == "1" {
data.Message = "A link with this short name already exists. You can edit it below."
data.AlreadyExists = true
}
if canEdit && !ownerExists {
data.Link.Owner = cu.login
Expand Down
6 changes: 4 additions & 2 deletions tmpl/detail.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{{ define "main" }}
{{ if .Message }}
<div class="py-2 px-4 mb-6 rounded-md border text-sm border-orange-50 bg-orange-0 text-gray-700">{{ .Message }}</div>
{{ if .AlreadyExists }}
<div class="py-2 px-4 mb-6 rounded-md border text-sm border-orange-50 bg-orange-0 text-gray-700">
{{ if .Editable }}A link with this short name already exists. You can edit it below.{{ else }}A link with this short name already exists.{{ end }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or A link with this short name already exists.{{ if .Editable }} You can edit it below.{{ end }}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in #227

</div>
{{ end }}
<h2 class="text-xl font-bold pb-2">Link Details</h2>

Expand Down
Loading