forked from tangled.org/core
Monorepo for Tangled

appview/pages: fix OG links for issues and pulls

Signed-off-by: oppiliappan <me@oppi.li>

oppi.li 71d46921 55b06460

verified
Changed files
+10 -28
appview
pages
templates
repo
fragments
issues
fragments
pulls
fragments
pulls
+1 -1
appview/pages/templates/repo/fragments/og.html
··· 11 11 <meta property="og:image" content="{{ $imageUrl }}" /> 12 12 <meta property="og:image:width" content="1200" /> 13 13 <meta property="og:image:height" content="600" /> 14 - 14 + 15 15 <meta name="twitter:card" content="summary_large_image" /> 16 16 <meta name="twitter:title" content="{{ unescapeHtml $title }}" /> 17 17 <meta name="twitter:description" content="{{ $description }}" />
+1 -1
appview/pages/templates/repo/issues/fragments/og.html
··· 1 - {{ define "issues/fragments/og" }} 1 + {{ define "repo/issues/fragments/og" }} 2 2 {{ $title := printf "%s #%d" .Issue.Title .Issue.IssueId }} 3 3 {{ $description := or .Issue.Body .RepoInfo.Description }} 4 4 {{ $url := printf "https://tangled.org/%s/issues/%d" .RepoInfo.FullName .Issue.IssueId }}
+1 -4
appview/pages/templates/repo/issues/issue.html
··· 2 2 3 3 4 4 {{ define "extrameta" }} 5 - {{ $title := printf "%s &middot; issue #%d &middot; %s" .Issue.Title .Issue.IssueId .RepoInfo.FullName }} 6 - {{ $url := printf "https://tangled.org/%s/issues/%d" .RepoInfo.FullName .Issue.IssueId }} 7 - 8 - {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }} 5 + {{ template "repo/issues/fragments/og" (dict "RepoInfo" .RepoInfo "Issue" .Issue) }} 9 6 {{ end }} 10 7 11 8 {{ define "repoContentLayout" }}
+2 -2
appview/pages/templates/repo/pulls/fragments/og.html
··· 1 - {{ define "pulls/fragments/og" }} 1 + {{ define "repo/pulls/fragments/og" }} 2 2 {{ $title := printf "%s #%d" .Pull.Title .Pull.PullId }} 3 3 {{ $description := or .Pull.Body .RepoInfo.Description }} 4 4 {{ $url := printf "https://tangled.org/%s/pulls/%d" .RepoInfo.FullName .Pull.PullId }} ··· 16 16 <meta name="twitter:title" content="{{ unescapeHtml $title }}" /> 17 17 <meta name="twitter:description" content="{{ $description }}" /> 18 18 <meta name="twitter:image" content="{{ $imageUrl }}" /> 19 - {{ end }} 19 + {{ end }}
+1 -4
appview/pages/templates/repo/pulls/pull.html
··· 3 3 {{ end }} 4 4 5 5 {{ define "extrameta" }} 6 - {{ $title := printf "%s &middot; pull #%d &middot; %s" .Pull.Title .Pull.PullId .RepoInfo.FullName }} 7 - {{ $url := printf "https://tangled.org/%s/pulls/%d" .RepoInfo.FullName .Pull.PullId }} 8 - 9 - {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }} 6 + {{ template "repo/pulls/fragments/og" (dict "RepoInfo" .RepoInfo "Pull" .Pull) }} 10 7 {{ end }} 11 8 12 9 {{ define "repoContentLayout" }}
+4 -16
appview/pulls/opengraph.go
··· 214 214 } 215 215 216 216 filesTextWidth := len(filesText) * 20 217 - currentX += filesTextWidth + 40 217 + currentX += filesTextWidth 218 218 219 219 // Draw additions (green +) 220 220 greenColor := color.RGBA{34, 139, 34, 255} 221 - err = statusStatsArea.DrawSVGIcon("static/icons/plus.svg", currentX, statsY+iconBaselineOffset-iconSize/2+5, iconSize, greenColor) 222 - if err != nil { 223 - log.Printf("failed to draw plus icon: %v", err) 224 - } 225 - 226 - currentX += iconSize + 15 227 - additionsText := fmt.Sprintf("%d", diffStats.Insertions) 221 + additionsText := fmt.Sprintf("+%d", diffStats.Insertions) 228 222 err = statusStatsArea.DrawTextAt(additionsText, currentX, statsY+iconBaselineOffset, greenColor, textSize, ogcard.Middle, ogcard.Left) 229 223 if err != nil { 230 224 log.Printf("failed to draw additions text: %v", err) 231 225 } 232 226 233 227 additionsTextWidth := len(additionsText) * 20 234 - currentX += additionsTextWidth + 15 228 + currentX += additionsTextWidth + 30 235 229 236 230 // Draw deletions (red -) right next to additions 237 231 redColor := color.RGBA{220, 20, 60, 255} 238 - err = statusStatsArea.DrawSVGIcon("static/icons/minus.svg", currentX, statsY+iconBaselineOffset-iconSize/2+5, iconSize, redColor) 239 - if err != nil { 240 - log.Printf("failed to draw minus icon: %v", err) 241 - } 242 - 243 - currentX += iconSize + 15 244 - deletionsText := fmt.Sprintf("%d", diffStats.Deletions) 232 + deletionsText := fmt.Sprintf("-%d", diffStats.Deletions) 245 233 err = statusStatsArea.DrawTextAt(deletionsText, currentX, statsY+iconBaselineOffset, redColor, textSize, ogcard.Middle, ogcard.Left) 246 234 if err != nil { 247 235 log.Printf("failed to draw deletions text: %v", err)