mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-10 23:52:16 +01:00
Update
This commit is contained in:
parent
aa64f6515c
commit
4568ebc913
4 changed files with 51 additions and 25 deletions
|
@ -191,7 +191,7 @@ func (r *Release) Link() string {
|
||||||
|
|
||||||
// SummaryCardURL returns the absolute URL to an image providing a summary of the release
|
// SummaryCardURL returns the absolute URL to an image providing a summary of the release
|
||||||
func (r *Release) SummaryCardURL() string {
|
func (r *Release) SummaryCardURL() string {
|
||||||
return fmt.Sprintf("%s/releases/summary-card/%d", r.Repo.HTMLURL(), r.ID)
|
return fmt.Sprintf("%s/releases/summary-card/%s", r.Repo.HTMLURL(), util.PathEscapeSegments(r.TagName))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisplayName retruns the name of the release
|
// DisplayName retruns the name of the release
|
||||||
|
|
|
@ -494,7 +494,7 @@ func DrawIssueSummaryCard(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DrawReleaseSummaryCard(ctx *context.Context) {
|
func DrawReleaseSummaryCard(ctx *context.Context) {
|
||||||
release, err := repo_model.GetReleaseForRepoByID(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":releaseID"))
|
release, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, ctx.Params("*"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if repo_model.IsErrReleaseNotExist(err) {
|
if repo_model.IsErrReleaseNotExist(err) {
|
||||||
ctx.NotFound("", nil)
|
ctx.NotFound("", nil)
|
||||||
|
|
|
@ -1299,7 +1299,7 @@ func registerRoutes(m *web.Route) {
|
||||||
m.Get("/latest", repo.LatestRelease)
|
m.Get("/latest", repo.LatestRelease)
|
||||||
m.Get(".rss", feedEnabled, repo.ReleasesFeedRSS)
|
m.Get(".rss", feedEnabled, repo.ReleasesFeedRSS)
|
||||||
m.Get(".atom", feedEnabled, repo.ReleasesFeedAtom)
|
m.Get(".atom", feedEnabled, repo.ReleasesFeedAtom)
|
||||||
m.Get("/summary-card/{releaseID}", repo.DrawReleaseSummaryCard)
|
m.Get("/summary-card/*", repo.DrawReleaseSummaryCard)
|
||||||
}, ctxDataSet("EnableFeed", setting.Other.EnableFeed),
|
}, ctxDataSet("EnableFeed", setting.Other.EnableFeed),
|
||||||
repo.MustBeNotEmpty, context.RepoRefByType(context.RepoRefTag, true))
|
repo.MustBeNotEmpty, context.RepoRefByType(context.RepoRefTag, true))
|
||||||
m.Get("/releases/attachments/{uuid}", repo.MustBeNotEmpty, repo.GetAttachment)
|
m.Get("/releases/attachments/{uuid}", repo.MustBeNotEmpty, repo.GetAttachment)
|
||||||
|
|
|
@ -98,6 +98,9 @@ func TestOpenGraphProperties(t *testing.T) {
|
||||||
"og:url": setting.AppURL + "/user27/repo49/src/branch/master/test/test.txt",
|
"og:url": setting.AppURL + "/user27/repo49/src/branch/master/test/test.txt",
|
||||||
"og:type": "object",
|
"og:type": "object",
|
||||||
"og:image": setting.AppURL + "user27/repo49/-/summary-card",
|
"og:image": setting.AppURL + "user27/repo49/-/summary-card",
|
||||||
|
"og:image:alt": "Summary card of repository user27/repo49",
|
||||||
|
"og:image:width": "1200",
|
||||||
|
"og:image:height": "600",
|
||||||
"og:site_name": siteName,
|
"og:site_name": siteName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -109,6 +112,9 @@ func TestOpenGraphProperties(t *testing.T) {
|
||||||
"og:url": setting.AppURL + "/user2/repo1/wiki/Page-With-Spaced-Name",
|
"og:url": setting.AppURL + "/user2/repo1/wiki/Page-With-Spaced-Name",
|
||||||
"og:type": "object",
|
"og:type": "object",
|
||||||
"og:image": setting.AppURL + "user2/repo1/-/summary-card",
|
"og:image": setting.AppURL + "user2/repo1/-/summary-card",
|
||||||
|
"og:image:alt": "Summary card of repository user2/repo1",
|
||||||
|
"og:image:width": "1200",
|
||||||
|
"og:image:height": "600",
|
||||||
"og:site_name": siteName,
|
"og:site_name": siteName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -120,6 +126,9 @@ func TestOpenGraphProperties(t *testing.T) {
|
||||||
"og:url": setting.AppURL + "user2/repo1",
|
"og:url": setting.AppURL + "user2/repo1",
|
||||||
"og:type": "object",
|
"og:type": "object",
|
||||||
"og:image": setting.AppURL + "user2/repo1/-/summary-card",
|
"og:image": setting.AppURL + "user2/repo1/-/summary-card",
|
||||||
|
"og:image:alt": "Summary card of repository user2/repo1",
|
||||||
|
"og:image:width": "1200",
|
||||||
|
"og:image:height": "600",
|
||||||
"og:site_name": siteName,
|
"og:site_name": siteName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -132,6 +141,23 @@ func TestOpenGraphProperties(t *testing.T) {
|
||||||
"og:description": "A wonderful repository with more than just a README.md",
|
"og:description": "A wonderful repository with more than just a README.md",
|
||||||
"og:type": "object",
|
"og:type": "object",
|
||||||
"og:image": setting.AppURL + "user27/repo49/-/summary-card",
|
"og:image": setting.AppURL + "user27/repo49/-/summary-card",
|
||||||
|
"og:image:alt": "Summary card of repository user27/repo49",
|
||||||
|
"og:image:width": "1200",
|
||||||
|
"og:image:height": "600",
|
||||||
|
"og:site_name": siteName,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "release",
|
||||||
|
url: "/user2/repo1/releases/tag/v1.1",
|
||||||
|
expected: map[string]string{
|
||||||
|
"og:title": "testing-release - user2/repo1",
|
||||||
|
"og:url": setting.AppURL + "user2/repo1/releases/tag/v1.1",
|
||||||
|
"og:type": "object",
|
||||||
|
"og:image": setting.AppURL + "user2/repo1/releases/summary-card/v1.1",
|
||||||
|
"og:image:alt": "Summary card of an release titled \"testing-release\" in repository user2/repo1",
|
||||||
|
"og:image:width": "1200",
|
||||||
|
"og:image:height": "600",
|
||||||
"og:site_name": siteName,
|
"og:site_name": siteName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -180,7 +206,7 @@ func TestOpenGraphSummaryCard(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "release",
|
name: "release",
|
||||||
url: "/user2/repo1/releases/summary-card/1",
|
url: "/user2/repo1/releases/summary-card/v1.1",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue