mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-09-19 08:44:14 +00:00
fix word wrapping
This commit is contained in:
@@ -70,16 +70,25 @@ func (h *RepoOGHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
card.DrawAvatarOrPlaceholder(avatarURL, layout.IconX, layout.IconY, ogcard.AvatarSize,
|
||||
strings.ToUpper(string(repository[0])))
|
||||
|
||||
// Draw owner handle and repo name on same line: @owner / repo
|
||||
// Draw owner handle and repo name - wrap to new line if too long
|
||||
ownerText := "@" + user.Handle + " / "
|
||||
card.DrawText(ownerText, layout.TextX, layout.TextY, ogcard.FontTitle, ogcard.ColorMuted, ogcard.AlignLeft, false)
|
||||
|
||||
// Measure owner text width to position repo name
|
||||
ownerWidth := card.MeasureText(ownerText, ogcard.FontTitle, false)
|
||||
card.DrawText(repository, layout.TextX+float64(ownerWidth), layout.TextY, ogcard.FontTitle, ogcard.ColorText, ogcard.AlignLeft, true)
|
||||
repoWidth := card.MeasureText(repository, ogcard.FontTitle, true)
|
||||
combinedWidth := ownerWidth + repoWidth
|
||||
|
||||
// Draw description (if present, with wrapping)
|
||||
textY := layout.TextY
|
||||
if combinedWidth > layout.MaxWidth {
|
||||
// Too long - put repo name on new line
|
||||
card.DrawText("@"+user.Handle+" /", layout.TextX, textY, ogcard.FontTitle, ogcard.ColorMuted, ogcard.AlignLeft, false)
|
||||
textY += ogcard.LineSpacingLarge
|
||||
card.DrawText(repository, layout.TextX, textY, ogcard.FontTitle, ogcard.ColorText, ogcard.AlignLeft, true)
|
||||
} else {
|
||||
// Fits on one line
|
||||
card.DrawText(ownerText, layout.TextX, textY, ogcard.FontTitle, ogcard.ColorMuted, ogcard.AlignLeft, false)
|
||||
card.DrawText(repository, layout.TextX+float64(ownerWidth), textY, ogcard.FontTitle, ogcard.ColorText, ogcard.AlignLeft, true)
|
||||
}
|
||||
|
||||
// Track current Y position for description
|
||||
if description != "" {
|
||||
textY += ogcard.LineSpacingSmall
|
||||
card.DrawTextWrapped(description, layout.TextX, textY, ogcard.FontDescription, ogcard.ColorMuted, layout.MaxWidth, false)
|
||||
|
||||
Reference in New Issue
Block a user