forked from tangled.org/core
Monorepo for Tangled — https://tangled.org

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