From 82a48d69cc581d06ee2c4bfecff18a2f68376152 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Tue, 9 Jun 2026 23:26:19 -0500 Subject: [PATCH] chore: remove old manifest files (consolidated into metadata) --- routers/web/repo/setting/manifest.go | 240 -------------------------- templates/repo/settings/manifest.tmpl | 223 ------------------------ 2 files changed, 463 deletions(-) delete mode 100644 routers/web/repo/setting/manifest.go delete mode 100644 templates/repo/settings/manifest.tmpl diff --git a/routers/web/repo/setting/manifest.go b/routers/web/repo/setting/manifest.go deleted file mode 100644 index e010accaa2..0000000000 --- a/routers/web/repo/setting/manifest.go +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright 2026 Moko Consulting -// SPDX-License-Identifier: GPL-3.0-or-later - -package setting - -import ( - "encoding/xml" - "fmt" - "net/http" - - updateserver_model "code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/updateserver" - repo_model "code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/repo" - "code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/log" - "code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/templates" - "code.mokoconsulting.tech/MokoConsulting/MokoGitea/services/context" -) - -const tplSettingsManifest templates.TplName = "repo/settings/manifest" - -// manifestXML mirrors the .mokogitea/manifest.xml schema for XML parsing. -type manifestXML struct { - XMLName xml.Name `xml:"mokoplatform"` - Identity manifestIdentity `xml:"identity"` - Governance manifestGovernance `xml:"governance"` - Distribution manifestDistribution `xml:"distribution"` - Build manifestBuild `xml:"build"` -} - -type manifestIdentity struct { - Name string `xml:"name"` - Org string `xml:"org"` - Description string `xml:"description"` - Version string `xml:"version"` - VersionPrefix string `xml:"version-prefix"` - License manifestLicense `xml:"license"` -} - -type manifestLicense struct { - SPDX string `xml:"spdx,attr"` - Name string `xml:",chardata"` -} - -type manifestGovernance struct { - Platform string `xml:"platform"` - StandardsVersion string `xml:"standards-version"` - StandardsSource string `xml:"standards-source"` -} - -type manifestDistribution struct { - DisplayName string `xml:"display-name"` - Maintainer string `xml:"maintainer"` - MaintainerURL string `xml:"maintainer-url"` - InfoURL string `xml:"info-url"` - TargetVersion string `xml:"target-version"` - PHPMinimum string `xml:"php-minimum"` -} - -type manifestBuild struct { - Language string `xml:"language"` - PackageType string `xml:"package-type"` - EntryPoint string `xml:"entry-point"` -} - -// ManifestSettings displays the repo manifest settings page. -// On first visit, if no manifest exists in DB but .mokogitea/manifest.xml -// exists in the repo, it auto-migrates the XML values into the database. -func ManifestSettings(ctx *context.Context) { - ctx.Data["Title"] = ctx.Tr("repo.settings.manifest") - ctx.Data["PageIsSettingsManifest"] = true - - repoID := ctx.Repo.Repository.ID - manifest, err := repo_model.GetRepoManifest(ctx, repoID) - if err != nil { - ctx.ServerError("GetRepoManifest", err) - return - } - - // Auto-detect and migrate .mokogitea/manifest.xml if no DB record exists. - if manifest == nil { - manifest = tryMigrateManifestXML(ctx) - } - - if manifest == nil { - // No manifest found — provide empty defaults from repo metadata. - manifest = &repo_model.RepoManifest{ - RepoID: repoID, - Name: ctx.Repo.Repository.Name, - Org: ctx.Repo.Repository.OwnerName, - Description: ctx.Repo.Repository.Description, - } - } - - ctx.Data["Manifest"] = manifest - - // Load update server / licensing config for the combined page. - repoCfg, _ := updateserver_model.GetRepoConfig(ctx, ctx.Repo.Repository.ID) - ctx.Data["RepoUpdateConfig"] = repoCfg - - ctx.HTML(http.StatusOK, tplSettingsManifest) -} - -// ManifestSettingsPost saves manifest or licensing settings from the form. -func ManifestSettingsPost(ctx *context.Context) { - // Handle licensing sub-form. - if ctx.FormString("action") == "licensing" { - saveLicensingSettings(ctx) - return - } - - manifest := &repo_model.RepoManifest{ - RepoID: ctx.Repo.Repository.ID, - Name: ctx.FormString("name"), - Org: ctx.FormString("org"), - Description: ctx.Repo.Repository.Description, - Version: ctx.FormString("version"), - LicenseSPDX: ctx.FormString("license_spdx"), - LicenseName: ctx.FormString("license_name"), - VersionPrefix: ctx.FormString("version_prefix"), - ElementName: ctx.FormString("element_name"), - Platform: ctx.FormString("platform"), - StandardsVersion: ctx.FormString("standards_version"), - StandardsSource: ctx.FormString("standards_source"), - DisplayName: ctx.FormString("display_name"), - Maintainer: ctx.FormString("maintainer"), - MaintainerURL: ctx.FormString("maintainer_url"), - InfoURL: ctx.FormString("info_url"), - TargetVersion: ctx.FormString("target_version"), - PHPMinimum: ctx.FormString("php_minimum"), - Language: ctx.FormString("language"), - PackageType: ctx.FormString("package_type"), - EntryPoint: ctx.FormString("entry_point"), - } - - if err := repo_model.CreateOrUpdateRepoManifest(ctx, manifest); err != nil { - ctx.ServerError("CreateOrUpdateRepoManifest", err) - return - } - - ctx.Flash.Success(ctx.Tr("repo.settings.manifest_saved")) - ctx.Redirect(ctx.Repo.RepoLink + "/settings/manifest") -} - -// saveLicensingSettings handles the update server / licensing form submission. -func saveLicensingSettings(ctx *context.Context) { - repo := ctx.Repo.Repository - - updatePlatform := ctx.FormString("update_platform") - if updatePlatform == "" { - updatePlatform = "joomla" - } - - enabled := ctx.FormString("enable_licensing") == "on" - - if !enabled { - if err := updateserver_model.DeleteRepoConfig(ctx, repo.ID); err != nil { - log.Error("DeleteRepoConfig: %v", err) - } - } else { - updateCfg := &updateserver_model.UpdateStreamConfig{ - OwnerID: repo.OwnerID, - RepoID: repo.ID, - Platform: updatePlatform, - LicensingEnabled: true, - RequireKey: ctx.FormString("require_update_key") == "on", - DownloadGating: ctx.FormString("download_gating"), - FeedVisibility: ctx.FormString("feed_visibility"), - SupportURL: ctx.FormString("support_url"), - StreamMode: "joomla", - } - - if err := updateserver_model.SaveConfig(ctx, updateCfg); err != nil { - log.Error("SaveConfig: %v", err) - ctx.ServerError("SaveConfig", err) - return - } - } - - ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success")) - ctx.Redirect(ctx.Repo.RepoLink + "/settings/manifest") -} - -// tryMigrateManifestXML reads .mokogitea/manifest.xml from the repo, -// parses it, and stores the values in the DB. Returns nil if no file found. -func tryMigrateManifestXML(ctx *context.Context) *repo_model.RepoManifest { - if ctx.Repo.GitRepo == nil || ctx.Repo.Commit == nil { - return nil - } - - entry, err := ctx.Repo.Commit.GetTreeEntryByPath(".mokogitea/manifest.xml") - if err != nil || entry == nil { - return nil // no manifest.xml found — not an error - } - - reader, err := entry.Blob().DataAsync() - if err != nil { - log.Error("ManifestMigrate: read blob: %v", err) - return nil - } - defer reader.Close() - - var mxml manifestXML - if err := xml.NewDecoder(reader).Decode(&mxml); err != nil { - log.Error("ManifestMigrate: parse XML: %v", err) - return nil - } - - manifest := &repo_model.RepoManifest{ - RepoID: ctx.Repo.Repository.ID, - Name: mxml.Identity.Name, - Org: mxml.Identity.Org, - Description: mxml.Identity.Description, - Version: mxml.Identity.Version, - LicenseSPDX: mxml.Identity.License.SPDX, - LicenseName: mxml.Identity.License.Name, - VersionPrefix: mxml.Identity.VersionPrefix, - Platform: mxml.Governance.Platform, - StandardsVersion: mxml.Governance.StandardsVersion, - StandardsSource: mxml.Governance.StandardsSource, - DisplayName: mxml.Distribution.DisplayName, - Maintainer: mxml.Distribution.Maintainer, - MaintainerURL: mxml.Distribution.MaintainerURL, - InfoURL: mxml.Distribution.InfoURL, - TargetVersion: mxml.Distribution.TargetVersion, - PHPMinimum: mxml.Distribution.PHPMinimum, - Language: mxml.Build.Language, - PackageType: mxml.Build.PackageType, - EntryPoint: mxml.Build.EntryPoint, - } - - if err := repo_model.CreateOrUpdateRepoManifest(ctx, manifest); err != nil { - log.Error("ManifestMigrate: save to DB: %v", err) - return nil - } - - log.Info("ManifestMigrate: migrated .mokogitea/manifest.xml for repo %s/%s", - ctx.Repo.Repository.OwnerName, ctx.Repo.Repository.Name) - - ctx.Flash.Info(fmt.Sprintf("Manifest settings imported from .mokogitea/manifest.xml. You can now delete the file from the repository.")) - return manifest -} diff --git a/templates/repo/settings/manifest.tmpl b/templates/repo/settings/manifest.tmpl deleted file mode 100644 index cd611ca89c..0000000000 --- a/templates/repo/settings/manifest.tmpl +++ /dev/null @@ -1,223 +0,0 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings manifest")}} -

- {{ctx.Locale.Tr "repo.settings.manifest"}} -

-
-

{{ctx.Locale.Tr "repo.settings.manifest_desc"}}

- -
- {{.CsrfTokenHtml}} - -
{{ctx.Locale.Tr "repo.settings.manifest_identity"}}
-
-
- {{if eq .Manifest.Platform "joomla"}} - - -

{{ctx.Locale.Tr "repo.settings.manifest_element_name_help"}}

- {{else}} - - - {{end}} -
-
- - -
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
{{ctx.Locale.Tr "repo.settings.manifest_governance"}}
-
-
- - -
-
- - -
-
- - -
-
- - {{if or (eq .Manifest.Platform "joomla") (eq .Manifest.Platform "wordpress") (eq .Manifest.Platform "dolibarr")}} -
{{ctx.Locale.Tr "repo.settings.manifest_distribution"}}
-
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
- {{if or (eq .Manifest.Platform "joomla") (eq .Manifest.Platform "wordpress")}} -
-
- - -
-
- - -
-
- {{end}} - {{end}} - -
{{ctx.Locale.Tr "repo.settings.manifest_build"}}
-
-
- - -
- {{if eq .Manifest.Platform "joomla"}} -
- - -

{{ctx.Locale.Tr "repo.settings.manifest_package_type_help"}}

-
-
- - - {{if .Manifest.ElementNameMismatch}} -

{{ctx.Locale.Tr "repo.settings.manifest_element_mismatch" .Manifest.AutoElementName}}

- {{else}} -

{{ctx.Locale.Tr "repo.settings.manifest_element_full_help"}}

- {{end}} -
- {{end}} -
- - -
-
- - -
-
- -{{if .LicensingEnabled}} -

- {{svg "octicon-broadcast" 16}} {{ctx.Locale.Tr "repo.settings.licensing_section"}} -

-
-
- {{.CsrfTokenHtml}} - -
-
- - -
-

{{ctx.Locale.Tr "repo.settings.licensing_section_desc"}}

-
- -
- -
- - -

{{ctx.Locale.Tr "repo.settings.update_platform_help"}}

-
- - {{if and .RepoUpdateConfig (ne .RepoUpdateConfig.Platform "joomla") (ne .RepoUpdateConfig.Platform "both") (ne .RepoUpdateConfig.Platform "")}} -
-
- - -
-

{{ctx.Locale.Tr "repo.settings.require_update_key_help"}}

-
- {{end}} - -
- - -

{{ctx.Locale.Tr "org.settings.download_gating_help"}}

-
- -
- - -
- -
- - -

{{ctx.Locale.Tr "repo.settings.support_url_help"}}

-
- -
- -
-
-
-{{end}} - -{{template "repo/settings/layout_footer" .}}