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
···
<meta property="og:image" content="{{ $imageUrl }}" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="600" />
-
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="{{ unescapeHtml $title }}" />
<meta name="twitter:description" content="{{ $description }}" />
···
<meta property="og:image" content="{{ $imageUrl }}" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="600" />
+
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="{{ unescapeHtml $title }}" />
<meta name="twitter:description" content="{{ $description }}" />
+1 -1
appview/pages/templates/repo/issues/fragments/og.html
···
-
{{ define "issues/fragments/og" }}
{{ $title := printf "%s #%d" .Issue.Title .Issue.IssueId }}
{{ $description := or .Issue.Body .RepoInfo.Description }}
{{ $url := printf "https://tangled.org/%s/issues/%d" .RepoInfo.FullName .Issue.IssueId }}
···
+
{{ define "repo/issues/fragments/og" }}
{{ $title := printf "%s #%d" .Issue.Title .Issue.IssueId }}
{{ $description := or .Issue.Body .RepoInfo.Description }}
{{ $url := printf "https://tangled.org/%s/issues/%d" .RepoInfo.FullName .Issue.IssueId }}
+1 -4
appview/pages/templates/repo/issues/issue.html
···
{{ define "extrameta" }}
-
{{ $title := printf "%s &middot; issue #%d &middot; %s" .Issue.Title .Issue.IssueId .RepoInfo.FullName }}
-
{{ $url := printf "https://tangled.org/%s/issues/%d" .RepoInfo.FullName .Issue.IssueId }}
-
-
{{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }}
{{ end }}
{{ define "repoContentLayout" }}
···
{{ define "extrameta" }}
+
{{ template "repo/issues/fragments/og" (dict "RepoInfo" .RepoInfo "Issue" .Issue) }}
{{ end }}
{{ define "repoContentLayout" }}
+2 -2
appview/pages/templates/repo/pulls/fragments/og.html
···
-
{{ define "pulls/fragments/og" }}
{{ $title := printf "%s #%d" .Pull.Title .Pull.PullId }}
{{ $description := or .Pull.Body .RepoInfo.Description }}
{{ $url := printf "https://tangled.org/%s/pulls/%d" .RepoInfo.FullName .Pull.PullId }}
···
<meta name="twitter:title" content="{{ unescapeHtml $title }}" />
<meta name="twitter:description" content="{{ $description }}" />
<meta name="twitter:image" content="{{ $imageUrl }}" />
-
{{ end }}
···
+
{{ define "repo/pulls/fragments/og" }}
{{ $title := printf "%s #%d" .Pull.Title .Pull.PullId }}
{{ $description := or .Pull.Body .RepoInfo.Description }}
{{ $url := printf "https://tangled.org/%s/pulls/%d" .RepoInfo.FullName .Pull.PullId }}
···
<meta name="twitter:title" content="{{ unescapeHtml $title }}" />
<meta name="twitter:description" content="{{ $description }}" />
<meta name="twitter:image" content="{{ $imageUrl }}" />
+
{{ end }}
+1 -4
appview/pages/templates/repo/pulls/pull.html
···
{{ end }}
{{ define "extrameta" }}
-
{{ $title := printf "%s &middot; pull #%d &middot; %s" .Pull.Title .Pull.PullId .RepoInfo.FullName }}
-
{{ $url := printf "https://tangled.org/%s/pulls/%d" .RepoInfo.FullName .Pull.PullId }}
-
-
{{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }}
{{ end }}
{{ define "repoContentLayout" }}
···
{{ end }}
{{ define "extrameta" }}
+
{{ template "repo/pulls/fragments/og" (dict "RepoInfo" .RepoInfo "Pull" .Pull) }}
{{ end }}
{{ define "repoContentLayout" }}
+4 -16
appview/pulls/opengraph.go
···
}
filesTextWidth := len(filesText) * 20
-
currentX += filesTextWidth + 40
// Draw additions (green +)
greenColor := color.RGBA{34, 139, 34, 255}
-
err = statusStatsArea.DrawSVGIcon("static/icons/plus.svg", currentX, statsY+iconBaselineOffset-iconSize/2+5, iconSize, greenColor)
-
if err != nil {
-
log.Printf("failed to draw plus icon: %v", err)
-
}
-
-
currentX += iconSize + 15
-
additionsText := fmt.Sprintf("%d", diffStats.Insertions)
err = statusStatsArea.DrawTextAt(additionsText, currentX, statsY+iconBaselineOffset, greenColor, textSize, ogcard.Middle, ogcard.Left)
if err != nil {
log.Printf("failed to draw additions text: %v", err)
}
additionsTextWidth := len(additionsText) * 20
-
currentX += additionsTextWidth + 15
// Draw deletions (red -) right next to additions
redColor := color.RGBA{220, 20, 60, 255}
-
err = statusStatsArea.DrawSVGIcon("static/icons/minus.svg", currentX, statsY+iconBaselineOffset-iconSize/2+5, iconSize, redColor)
-
if err != nil {
-
log.Printf("failed to draw minus icon: %v", err)
-
}
-
-
currentX += iconSize + 15
-
deletionsText := fmt.Sprintf("%d", diffStats.Deletions)
err = statusStatsArea.DrawTextAt(deletionsText, currentX, statsY+iconBaselineOffset, redColor, textSize, ogcard.Middle, ogcard.Left)
if err != nil {
log.Printf("failed to draw deletions text: %v", err)
···
}
filesTextWidth := len(filesText) * 20
+
currentX += filesTextWidth
// Draw additions (green +)
greenColor := color.RGBA{34, 139, 34, 255}
+
additionsText := fmt.Sprintf("+%d", diffStats.Insertions)
err = statusStatsArea.DrawTextAt(additionsText, currentX, statsY+iconBaselineOffset, greenColor, textSize, ogcard.Middle, ogcard.Left)
if err != nil {
log.Printf("failed to draw additions text: %v", err)
}
additionsTextWidth := len(additionsText) * 20
+
currentX += additionsTextWidth + 30
// Draw deletions (red -) right next to additions
redColor := color.RGBA{220, 20, 60, 255}
+
deletionsText := fmt.Sprintf("-%d", diffStats.Deletions)
err = statusStatsArea.DrawTextAt(deletionsText, currentX, statsY+iconBaselineOffset, redColor, textSize, ogcard.Middle, ogcard.Left)
if err != nil {
log.Printf("failed to draw deletions text: %v", err)