mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-10 02:21:16 +00:00
Update
This commit is contained in:
parent
7685a1e98e
commit
25bfd2983e
7 changed files with 35 additions and 33 deletions
|
@ -416,20 +416,6 @@ func (issue *Issue) SummaryCardURL() string {
|
|||
return fmt.Sprintf("%s/summary-card", issue.HTMLURL())
|
||||
}
|
||||
|
||||
func (issue *Issue) SummaryCardSize() (int, int) {
|
||||
return 1200, 600
|
||||
}
|
||||
|
||||
func (issue *Issue) SummaryCardWidth() int {
|
||||
width, _ := issue.SummaryCardSize()
|
||||
return width
|
||||
}
|
||||
|
||||
func (issue *Issue) SummaryCardHeight() int {
|
||||
_, height := issue.SummaryCardSize()
|
||||
return height
|
||||
}
|
||||
|
||||
// Link returns the issue's relative URL.
|
||||
func (issue *Issue) Link() string {
|
||||
var path string
|
||||
|
|
|
@ -1148,6 +1148,7 @@ blame_prior = View blame prior to this change
|
|||
blame.ignore_revs = Ignoring revisions in <a href="%s">.git-blame-ignore-revs</a>. Click <a href="%s">here to bypass</a> and see the normal blame view.
|
||||
blame.ignore_revs.failed = Failed to ignore revisions in <a href="%s">.git-blame-ignore-revs</a>.
|
||||
author_search_tooltip = Shows a maximum of 30 users
|
||||
summary_card_alt = Summary card of repository %s
|
||||
|
||||
tree_path_not_found_commit = Path %[1]s doesn't exist in commit %[2]s
|
||||
tree_path_not_found_branch = Path %[1]s doesn't exist in branch %[2]s
|
||||
|
@ -2740,6 +2741,7 @@ release.asset_name = Asset name
|
|||
release.asset_external_url = External URL
|
||||
release.add_external_asset = Add external asset
|
||||
release.invalid_external_url = Invalid external URL: "%s"
|
||||
release.summary_card_alt = Summary card of an release titled "%s" in repository %s
|
||||
|
||||
branch.name = Branch name
|
||||
branch.already_exists = A branch named "%s" already exists.
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
"code.gitea.io/gitea/services/context"
|
||||
)
|
||||
|
||||
// drawUser draws a user avator in a summary card
|
||||
// drawUser draws a user avatar in a summary card
|
||||
func drawUser(ctx *context.Context, card *card.Card, user *user_model.User) error {
|
||||
if user.UseCustomAvatar {
|
||||
posterAvatarPath := user.CustomAvatarRelativePath()
|
||||
|
@ -50,6 +50,7 @@ func drawUser(ctx *context.Context, card *card.Card, user *user_model.User) erro
|
|||
// drawRepoIcon draws the repo icon in a summary card
|
||||
func drawRepoIcon(ctx *context.Context, card *card.Card, repo *repo_model.Repository) error {
|
||||
repoAvatarPath := repo.CustomAvatarRelativePath()
|
||||
|
||||
if repoAvatarPath != "" {
|
||||
repoAvatarFile, err := storage.RepoAvatars.Open(repoAvatarPath)
|
||||
if err != nil {
|
||||
|
@ -61,21 +62,21 @@ func drawRepoIcon(ctx *context.Context, card *card.Card, repo *repo_model.Reposi
|
|||
}
|
||||
card.DrawImage(repoAvatarImage)
|
||||
return nil
|
||||
} else {
|
||||
// If the repo didn't have an avatar, fallback to the repo owner's avatar for the right-hand-side icon
|
||||
err := repo.LoadOwner(ctx)
|
||||
}
|
||||
|
||||
// If the repo didn't have an avatar, fallback to the repo owner's avatar for the right-hand-side icon
|
||||
err := repo.LoadOwner(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if repo.Owner != nil {
|
||||
err = drawUser(ctx, card, repo.Owner)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if repo.Owner != nil {
|
||||
err = drawUser(ctx, card, repo.Owner)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// hexToColor converts a hex color to a go color
|
||||
|
@ -227,7 +228,7 @@ func drawRepoSummaryCard(ctx *context.Context, repo *repo_model.Repository) (*ca
|
|||
}
|
||||
|
||||
func drawIssueSummaryCard(ctx *context.Context, issue *issue_model.Issue) (*card.Card, error) {
|
||||
width, height := issue.SummaryCardSize()
|
||||
width, height := card.DefaultSize()
|
||||
mainCard, err := card.NewCard(width, height)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -397,7 +398,7 @@ func drawReleaseSummaryCard(ctx *context.Context, release *repo_model.Release) (
|
|||
return mainCard, nil
|
||||
}
|
||||
|
||||
// checkCardCache checks if a card in cahce and serves it
|
||||
// checkCardCache checks if a card in cache and serves it
|
||||
func checkCardCache(ctx *context.Context, cacheKey string) bool {
|
||||
cache := cache.GetCache()
|
||||
pngData, ok := cache.Get(cacheKey).([]byte)
|
||||
|
@ -414,7 +415,7 @@ func checkCardCache(ctx *context.Context, cacheKey string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// serveCard server a Crad to the user adds it to the cache
|
||||
// serveCard server a Card to the user adds it to the cache
|
||||
func serveCard(ctx *context.Context, card *card.Card, cacheKey string) {
|
||||
cache := cache.GetCache()
|
||||
|
||||
|
|
|
@ -2055,6 +2055,8 @@ func ViewIssue(ctx *context.Context) {
|
|||
ctx.Data["RefEndName"] = git.RefName(issue.Ref).ShortName()
|
||||
ctx.Data["NewPinAllowed"] = pinAllowed
|
||||
ctx.Data["PinEnabled"] = setting.Repository.Issue.MaxPinned != 0
|
||||
ctx.Data["OpenGraphImageURL"] = issue.SummaryCardURL()
|
||||
ctx.Data["OpenGraphImageAltText"] = ctx.Tr("repo.issues.summary_card_alt", issue.Title, issue.Repo.FullName())
|
||||
|
||||
prepareHiddenCommentType(ctx)
|
||||
if ctx.Written() {
|
||||
|
|
|
@ -379,6 +379,7 @@ func SingleRelease(ctx *context.Context) {
|
|||
ctx.Data["OpenGraphDescription"] = base.EllipsisString(release.Note, 300)
|
||||
ctx.Data["OpenGraphURL"] = release.HTMLURL()
|
||||
ctx.Data["OpenGraphImageURL"] = release.SummaryCardURL()
|
||||
ctx.Data["OpenGraphImageAltText"] = ctx.Tr("repo.release.summary_card_alt", release.DisplayName(), release.Repo.FullName())
|
||||
|
||||
ctx.HTML(http.StatusOK, tplReleasesList)
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
unit_model "code.gitea.io/gitea/models/unit"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/cache"
|
||||
"code.gitea.io/gitea/modules/card"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/gitrepo"
|
||||
code_indexer "code.gitea.io/gitea/modules/indexer/code"
|
||||
|
@ -632,7 +633,11 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
|
|||
ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx, ctx.Doer.ID, repo.ID)
|
||||
}
|
||||
|
||||
cardWidth, cardHeight := card.DefaultSize()
|
||||
ctx.Data["OpenGraphImageURL"] = repo.SummaryCardURL()
|
||||
ctx.Data["OpenGraphImageWidth"] = cardWidth
|
||||
ctx.Data["OpenGraphImageHeight"] = cardHeight
|
||||
ctx.Data["OpenGraphImageAltText"] = ctx.Tr("repo.summary_card_alt", repo.FullName())
|
||||
|
||||
if repo.IsFork {
|
||||
RetrieveBaseRepo(ctx, repo)
|
||||
|
|
|
@ -10,6 +10,15 @@
|
|||
{{end}}
|
||||
{{if .OpenGraphImageURL}}
|
||||
<meta property="og:image" content="{{.OpenGraphImageURL}}">
|
||||
{{if .OpenGraphImageWidth}}
|
||||
<meta property="og:image:width" content="{{.OpenGraphImageWidth}}">
|
||||
{{end}}
|
||||
{{if .OpenGraphImageHeight}}
|
||||
<meta property="og:image:height" content="{{.OpenGraphImageHeight}}">
|
||||
{{end}}
|
||||
{{if .OpenGraphImageAltText}}
|
||||
<meta property="og:image:alt" content="{{.OpenGraphImageAltText}}">
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if .PageIsUserProfile}}
|
||||
<meta property="og:title" content="{{.ContextUser.DisplayName}}">
|
||||
|
@ -26,10 +35,6 @@
|
|||
{{if .Issue.Content}}
|
||||
<meta property="og:description" content="{{StringUtils.EllipsisString .Issue.Content 300}}">
|
||||
{{end}}
|
||||
<meta property="og:image" content="{{.Issue.SummaryCardURL}}">
|
||||
<meta property="og:image:width" content="{{.Issue.SummaryCardWidth}}">
|
||||
<meta property="og:image:height" content="{{.Issue.SummaryCardHeight}}">
|
||||
<meta property="og:image:alt" content="{{ctx.Locale.Tr "repo.issues.summary_card_alt" .Issue.Title .Repository.FullName}}">
|
||||
{{else if or .PageIsDiff .IsViewFile}}
|
||||
<meta property="og:title" content="{{.Title}}">
|
||||
<meta property="og:url" content="{{AppUrl}}{{.Link}}">
|
||||
|
|
Loading…
Reference in a new issue