Phase 3: Organization Public Profile Page - Pinned repositories with groups - Public members display with roles - API endpoints for pinned repos and groups Phase 4: Gitea Pages Foundation - Landing page templates (simple, docs, product, portfolio) - Custom domain support with verification - YAML configuration parser (.gitea/landing.yaml) - Repository settings UI for pages Phase 5: Enhanced Wiki System with V2 API - Full CRUD operations via v2 API - Full-text search with WikiIndex table - Link graph visualization - Wiki health metrics (orphaned, dead links, outdated) - Designed for external AI plugin integration - Developer guide for .NET integration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
135 lines
3.7 KiB
Go
135 lines
3.7 KiB
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
|
"code.gitea.io/gitea/modules/templates"
|
|
"code.gitea.io/gitea/services/context"
|
|
pages_service "code.gitea.io/gitea/services/pages"
|
|
)
|
|
|
|
const tplRepoSettingsPages templates.TplName = "repo/settings/pages"
|
|
|
|
// Pages shows the repository pages settings
|
|
func Pages(ctx *context.Context) {
|
|
ctx.Data["Title"] = ctx.Tr("repo.settings.pages")
|
|
ctx.Data["PageIsSettingsPages"] = true
|
|
|
|
// Get pages config
|
|
config, err := repo_model.GetPagesConfig(ctx, ctx.Repo.Repository.ID)
|
|
if err != nil && !repo_model.IsErrPagesConfigNotExist(err) {
|
|
ctx.ServerError("GetPagesConfig", err)
|
|
return
|
|
}
|
|
|
|
if config != nil {
|
|
ctx.Data["PagesEnabled"] = config.Enabled
|
|
ctx.Data["PagesTemplate"] = config.Template
|
|
}
|
|
|
|
// Get pages domains
|
|
domains, err := repo_model.GetPagesDomains(ctx, ctx.Repo.Repository.ID)
|
|
if err != nil {
|
|
ctx.ServerError("GetPagesDomains", err)
|
|
return
|
|
}
|
|
ctx.Data["PagesDomains"] = domains
|
|
|
|
// Generate subdomain
|
|
ctx.Data["PagesSubdomain"] = pages_service.GetPagesSubdomain(ctx.Repo.Repository)
|
|
|
|
// Available templates
|
|
ctx.Data["PagesTemplates"] = []string{"simple", "documentation", "product", "portfolio"}
|
|
|
|
ctx.HTML(http.StatusOK, tplRepoSettingsPages)
|
|
}
|
|
|
|
// PagesPost handles the pages settings form submission
|
|
func PagesPost(ctx *context.Context) {
|
|
ctx.Data["Title"] = ctx.Tr("repo.settings.pages")
|
|
ctx.Data["PageIsSettingsPages"] = true
|
|
|
|
action := ctx.FormString("action")
|
|
|
|
switch action {
|
|
case "enable":
|
|
template := ctx.FormString("template")
|
|
if template == "" {
|
|
template = "simple"
|
|
}
|
|
if err := pages_service.EnablePages(ctx, ctx.Repo.Repository, template); err != nil {
|
|
ctx.ServerError("EnablePages", err)
|
|
return
|
|
}
|
|
ctx.Flash.Success(ctx.Tr("repo.settings.pages.enabled_success"))
|
|
|
|
case "disable":
|
|
if err := pages_service.DisablePages(ctx, ctx.Repo.Repository); err != nil {
|
|
ctx.ServerError("DisablePages", err)
|
|
return
|
|
}
|
|
ctx.Flash.Success(ctx.Tr("repo.settings.pages.disabled_success"))
|
|
|
|
case "update_template":
|
|
template := ctx.FormString("template")
|
|
if template == "" {
|
|
template = "simple"
|
|
}
|
|
if err := pages_service.EnablePages(ctx, ctx.Repo.Repository, template); err != nil {
|
|
ctx.ServerError("EnablePages", err)
|
|
return
|
|
}
|
|
ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
|
|
|
|
case "add_domain":
|
|
domain := ctx.FormString("domain")
|
|
if domain == "" {
|
|
ctx.Flash.Error(ctx.Tr("repo.settings.pages.domain_required"))
|
|
ctx.Redirect(ctx.Repo.Repository.Link() + "/settings/pages")
|
|
return
|
|
}
|
|
_, err := pages_service.AddPagesDomain(ctx, ctx.Repo.Repository.ID, domain)
|
|
if err != nil {
|
|
if repo_model.IsErrPagesDomainAlreadyExist(err) {
|
|
ctx.Flash.Error(ctx.Tr("repo.settings.pages.domain_exists"))
|
|
} else {
|
|
ctx.ServerError("AddPagesDomain", err)
|
|
return
|
|
}
|
|
} else {
|
|
ctx.Flash.Success(ctx.Tr("repo.settings.pages.domain_added"))
|
|
}
|
|
|
|
case "delete_domain":
|
|
domainID := ctx.FormInt64("domain_id")
|
|
if err := repo_model.DeletePagesDomain(ctx, domainID); err != nil {
|
|
ctx.ServerError("DeletePagesDomain", err)
|
|
return
|
|
}
|
|
ctx.Flash.Success(ctx.Tr("repo.settings.pages.domain_deleted"))
|
|
|
|
case "verify_domain":
|
|
domainID := ctx.FormInt64("domain_id")
|
|
if err := pages_service.VerifyDomain(ctx, domainID); err != nil {
|
|
if err.Error() == "DNS verification failed" {
|
|
ctx.Flash.Error(ctx.Tr("repo.settings.pages.domain_verification_failed"))
|
|
} else {
|
|
ctx.ServerError("VerifyDomain", err)
|
|
return
|
|
}
|
|
} else {
|
|
ctx.Flash.Success(ctx.Tr("repo.settings.pages.domain_verified"))
|
|
}
|
|
|
|
default:
|
|
ctx.NotFound(nil)
|
|
return
|
|
}
|
|
|
|
ctx.Redirect(ctx.Repo.Repository.Link() + "/settings/pages")
|
|
}
|