1
1
mirror of https://github.com/go-gitea/gitea synced 2025-10-31 19:38:23 +00:00

Move HasWiki to repository service package (#33912)

Move HasWiki out of the models package to avoid referencing the absolute
wiki path directly.
This commit is contained in:
Lunny Xiao
2025-09-01 11:12:58 -07:00
committed by GitHub
parent ea96ff6b0c
commit 4e1b8db1fc
17 changed files with 76 additions and 54 deletions

View File

@@ -33,6 +33,7 @@ import (
"code.gitea.io/gitea/services/forms"
git_service "code.gitea.io/gitea/services/git"
notify_service "code.gitea.io/gitea/services/notify"
repo_service "code.gitea.io/gitea/services/repository"
wiki_service "code.gitea.io/gitea/services/wiki"
)
@@ -474,7 +475,7 @@ func Wiki(ctx *context.Context) {
return
}
if !ctx.Repo.Repository.HasWiki() {
if !repo_service.HasWiki(ctx, ctx.Repo.Repository) {
ctx.Data["Title"] = ctx.Tr("repo.wiki")
ctx.HTML(http.StatusOK, tplWikiStart)
return
@@ -510,7 +511,7 @@ func Wiki(ctx *context.Context) {
func WikiRevision(ctx *context.Context) {
ctx.Data["CanWriteWiki"] = ctx.Repo.CanWrite(unit.TypeWiki) && !ctx.Repo.Repository.IsArchived
if !ctx.Repo.Repository.HasWiki() {
if !repo_service.HasWiki(ctx, ctx.Repo.Repository) {
ctx.Data["Title"] = ctx.Tr("repo.wiki")
ctx.HTML(http.StatusOK, tplWikiStart)
return
@@ -540,7 +541,7 @@ func WikiRevision(ctx *context.Context) {
// WikiPages render wiki pages list page
func WikiPages(ctx *context.Context) {
if !ctx.Repo.Repository.HasWiki() {
if !repo_service.HasWiki(ctx, ctx.Repo.Repository) {
ctx.Redirect(ctx.Repo.RepoLink + "/wiki")
return
}
@@ -648,7 +649,7 @@ func WikiRaw(ctx *context.Context) {
func NewWiki(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
if !ctx.Repo.Repository.HasWiki() {
if !repo_service.HasWiki(ctx, ctx.Repo.Repository) {
ctx.Data["title"] = "Home"
}
if ctx.FormString("title") != "" {
@@ -701,7 +702,7 @@ func NewWikiPost(ctx *context.Context) {
func EditWiki(ctx *context.Context) {
ctx.Data["PageIsWikiEdit"] = true
if !ctx.Repo.Repository.HasWiki() {
if !repo_service.HasWiki(ctx, ctx.Repo.Repository) {
ctx.Redirect(ctx.Repo.RepoLink + "/wiki")
return
}