mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-26 15:19:47 +01: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())
|
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.
|
// Link returns the issue's relative URL.
|
||||||
func (issue *Issue) Link() string {
|
func (issue *Issue) Link() string {
|
||||||
var path 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 = 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>.
|
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
|
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_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
|
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.asset_external_url = External URL
|
||||||
release.add_external_asset = Add external asset
|
release.add_external_asset = Add external asset
|
||||||
release.invalid_external_url = Invalid external URL: "%s"
|
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.name = Branch name
|
||||||
branch.already_exists = A branch named "%s" already exists.
|
branch.already_exists = A branch named "%s" already exists.
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
"code.gitea.io/gitea/services/context"
|
"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 {
|
func drawUser(ctx *context.Context, card *card.Card, user *user_model.User) error {
|
||||||
if user.UseCustomAvatar {
|
if user.UseCustomAvatar {
|
||||||
posterAvatarPath := user.CustomAvatarRelativePath()
|
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
|
// drawRepoIcon draws the repo icon in a summary card
|
||||||
func drawRepoIcon(ctx *context.Context, card *card.Card, repo *repo_model.Repository) error {
|
func drawRepoIcon(ctx *context.Context, card *card.Card, repo *repo_model.Repository) error {
|
||||||
repoAvatarPath := repo.CustomAvatarRelativePath()
|
repoAvatarPath := repo.CustomAvatarRelativePath()
|
||||||
|
|
||||||
if repoAvatarPath != "" {
|
if repoAvatarPath != "" {
|
||||||
repoAvatarFile, err := storage.RepoAvatars.Open(repoAvatarPath)
|
repoAvatarFile, err := storage.RepoAvatars.Open(repoAvatarPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -61,21 +62,21 @@ func drawRepoIcon(ctx *context.Context, card *card.Card, repo *repo_model.Reposi
|
||||||
}
|
}
|
||||||
card.DrawImage(repoAvatarImage)
|
card.DrawImage(repoAvatarImage)
|
||||||
return nil
|
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 {
|
if err != nil {
|
||||||
return err
|
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
|
// 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) {
|
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)
|
mainCard, err := card.NewCard(width, height)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -397,7 +398,7 @@ func drawReleaseSummaryCard(ctx *context.Context, release *repo_model.Release) (
|
||||||
return mainCard, nil
|
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 {
|
func checkCardCache(ctx *context.Context, cacheKey string) bool {
|
||||||
cache := cache.GetCache()
|
cache := cache.GetCache()
|
||||||
pngData, ok := cache.Get(cacheKey).([]byte)
|
pngData, ok := cache.Get(cacheKey).([]byte)
|
||||||
|
@ -414,7 +415,7 @@ func checkCardCache(ctx *context.Context, cacheKey string) bool {
|
||||||
return false
|
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) {
|
func serveCard(ctx *context.Context, card *card.Card, cacheKey string) {
|
||||||
cache := cache.GetCache()
|
cache := cache.GetCache()
|
||||||
|
|
||||||
|
|
|
@ -2055,6 +2055,8 @@ func ViewIssue(ctx *context.Context) {
|
||||||
ctx.Data["RefEndName"] = git.RefName(issue.Ref).ShortName()
|
ctx.Data["RefEndName"] = git.RefName(issue.Ref).ShortName()
|
||||||
ctx.Data["NewPinAllowed"] = pinAllowed
|
ctx.Data["NewPinAllowed"] = pinAllowed
|
||||||
ctx.Data["PinEnabled"] = setting.Repository.Issue.MaxPinned != 0
|
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)
|
prepareHiddenCommentType(ctx)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
|
|
|
@ -379,6 +379,7 @@ func SingleRelease(ctx *context.Context) {
|
||||||
ctx.Data["OpenGraphDescription"] = base.EllipsisString(release.Note, 300)
|
ctx.Data["OpenGraphDescription"] = base.EllipsisString(release.Note, 300)
|
||||||
ctx.Data["OpenGraphURL"] = release.HTMLURL()
|
ctx.Data["OpenGraphURL"] = release.HTMLURL()
|
||||||
ctx.Data["OpenGraphImageURL"] = release.SummaryCardURL()
|
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)
|
ctx.HTML(http.StatusOK, tplReleasesList)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import (
|
||||||
unit_model "code.gitea.io/gitea/models/unit"
|
unit_model "code.gitea.io/gitea/models/unit"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
"code.gitea.io/gitea/modules/cache"
|
"code.gitea.io/gitea/modules/cache"
|
||||||
|
"code.gitea.io/gitea/modules/card"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/gitrepo"
|
"code.gitea.io/gitea/modules/gitrepo"
|
||||||
code_indexer "code.gitea.io/gitea/modules/indexer/code"
|
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)
|
ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx, ctx.Doer.ID, repo.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cardWidth, cardHeight := card.DefaultSize()
|
||||||
ctx.Data["OpenGraphImageURL"] = repo.SummaryCardURL()
|
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 {
|
if repo.IsFork {
|
||||||
RetrieveBaseRepo(ctx, repo)
|
RetrieveBaseRepo(ctx, repo)
|
||||||
|
|
|
@ -10,6 +10,15 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .OpenGraphImageURL}}
|
{{if .OpenGraphImageURL}}
|
||||||
<meta property="og:image" content="{{.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}}
|
{{end}}
|
||||||
{{if .PageIsUserProfile}}
|
{{if .PageIsUserProfile}}
|
||||||
<meta property="og:title" content="{{.ContextUser.DisplayName}}">
|
<meta property="og:title" content="{{.ContextUser.DisplayName}}">
|
||||||
|
@ -26,10 +35,6 @@
|
||||||
{{if .Issue.Content}}
|
{{if .Issue.Content}}
|
||||||
<meta property="og:description" content="{{StringUtils.EllipsisString .Issue.Content 300}}">
|
<meta property="og:description" content="{{StringUtils.EllipsisString .Issue.Content 300}}">
|
||||||
{{end}}
|
{{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}}
|
{{else if or .PageIsDiff .IsViewFile}}
|
||||||
<meta property="og:title" content="{{.Title}}">
|
<meta property="og:title" content="{{.Title}}">
|
||||||
<meta property="og:url" content="{{AppUrl}}{{.Link}}">
|
<meta property="og:url" content="{{AppUrl}}{{.Link}}">
|
||||||
|
|
Loading…
Reference in a new issue