Compare commits
2 Commits
dev
..
development
| Author | SHA1 | Date | |
|---|---|---|---|
| fd41da0eb6 | |||
| 527b69555a |
@@ -434,6 +434,7 @@ func prepareMigrationTasks() []*migration {
|
|||||||
newMigration(354, "Add org wiki settings to user table", v1_27.AddOrgWikiSettings),
|
newMigration(354, "Add org wiki settings to user table", v1_27.AddOrgWikiSettings),
|
||||||
newMigration(355, "Migrate update server metadata to repo manifest", v1_27.MigrateUpdateServerFieldsToManifest),
|
newMigration(355, "Migrate update server metadata to repo manifest", v1_27.MigrateUpdateServerFieldsToManifest),
|
||||||
newMigration(356, "Rename package_type to extension_type in repo manifest", v1_27.RenamePackageTypeToExtensionType),
|
newMigration(356, "Rename package_type to extension_type in repo manifest", v1_27.RenamePackageTypeToExtensionType),
|
||||||
|
newMigration(357, "Drop display_name from repo manifest and update stream config", v1_27.DropDisplayNameColumns),
|
||||||
}
|
}
|
||||||
return preparedMigrations
|
return preparedMigrations
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
package v1_27
|
||||||
|
|
||||||
|
import "xorm.io/xorm"
|
||||||
|
|
||||||
|
// DropDisplayNameColumns removes the display_name column from repo_manifest
|
||||||
|
// and update_stream_config. Display name is now computed from extension_type + name.
|
||||||
|
func DropDisplayNameColumns(x *xorm.Engine) error {
|
||||||
|
if _, err := x.Exec("ALTER TABLE repo_manifest DROP COLUMN IF EXISTS display_name"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err := x.Exec("ALTER TABLE update_stream_config DROP COLUMN IF EXISTS display_name")
|
||||||
|
return err
|
||||||
|
}
|
||||||
@@ -39,7 +39,6 @@ type RepoMetadata struct {
|
|||||||
ElementName string `xorm:"TEXT 'element_name'"` // full element name override, e.g. "pkg_mokowaas" (auto-constructed if empty)
|
ElementName string `xorm:"TEXT 'element_name'"` // full element name override, e.g. "pkg_mokowaas" (auto-constructed if empty)
|
||||||
|
|
||||||
// distribution metadata (used by update server feed generation)
|
// distribution metadata (used by update server feed generation)
|
||||||
DisplayName string `xorm:"TEXT 'display_name'"` // human-readable name for update feeds, e.g. "Package - MokoWaaS"
|
|
||||||
Maintainer string `xorm:"TEXT 'maintainer'"` // maintainer/author name
|
Maintainer string `xorm:"TEXT 'maintainer'"` // maintainer/author name
|
||||||
MaintainerURL string `xorm:"TEXT 'maintainer_url'"` // maintainer website
|
MaintainerURL string `xorm:"TEXT 'maintainer_url'"` // maintainer website
|
||||||
InfoURL string `xorm:"TEXT 'info_url'"` // extension info/product page URL
|
InfoURL string `xorm:"TEXT 'info_url'"` // extension info/product page URL
|
||||||
@@ -115,6 +114,20 @@ func (m *RepoMetadata) ElementNameMismatch() bool {
|
|||||||
return auto != "" && m.ElementName != auto
|
return auto != "" && m.ElementName != auto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DerivedDisplayName computes the display name from ExtensionType and Name.
|
||||||
|
// Format: "Package - MokoSuiteBackup" (titlecased type + repo name).
|
||||||
|
// Falls back to just the Name if ExtensionType is empty.
|
||||||
|
func (m *RepoMetadata) DerivedDisplayName() string {
|
||||||
|
if m.Name == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if m.ExtensionType == "" {
|
||||||
|
return m.Name
|
||||||
|
}
|
||||||
|
title := strings.ToUpper(m.ExtensionType[:1]) + m.ExtensionType[1:]
|
||||||
|
return title + " - " + m.Name
|
||||||
|
}
|
||||||
|
|
||||||
// GetRepoMetadata returns the metadata for a repo, or nil if none exists.
|
// GetRepoMetadata returns the metadata for a repo, or nil if none exists.
|
||||||
func GetRepoMetadata(ctx context.Context, repoID int64) (*RepoMetadata, error) {
|
func GetRepoMetadata(ctx context.Context, repoID int64) (*RepoMetadata, error) {
|
||||||
m := new(RepoMetadata)
|
m := new(RepoMetadata)
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ type UpdateStreamConfig struct {
|
|||||||
KeyPrefix string `xorm:"VARCHAR(20) 'key_prefix'"` // org-specific license key prefix (e.g. "ACME")
|
KeyPrefix string `xorm:"VARCHAR(20) 'key_prefix'"` // org-specific license key prefix (e.g. "ACME")
|
||||||
// Extension metadata — used in update feed generation.
|
// Extension metadata — used in update feed generation.
|
||||||
ExtensionName string `xorm:"TEXT 'extension_name'"` // element identifier (e.g. pkg_mokowaas, com_mokowaas)
|
ExtensionName string `xorm:"TEXT 'extension_name'"` // element identifier (e.g. pkg_mokowaas, com_mokowaas)
|
||||||
DisplayName string `xorm:"TEXT 'display_name'"` // human-readable name (e.g. "Package - MokoWaaS")
|
|
||||||
Description string `xorm:"TEXT"` // short description for update feeds
|
Description string `xorm:"TEXT"` // short description for update feeds
|
||||||
ExtensionType string `xorm:"VARCHAR(50) 'extension_type'"` // component, module, plugin, package, template, library
|
ExtensionType string `xorm:"VARCHAR(50) 'extension_type'"` // component, module, plugin, package, template, library
|
||||||
Maintainer string `xorm:"TEXT"` // maintainer/author name
|
Maintainer string `xorm:"TEXT"` // maintainer/author name
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
repo_model "code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/repo"
|
||||||
updateserver_model "code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/updateserver"
|
updateserver_model "code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/updateserver"
|
||||||
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/structs"
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/structs"
|
||||||
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/timeutil"
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/timeutil"
|
||||||
@@ -21,6 +22,11 @@ func GetLicenseSettings(ctx *context.APIContext) {
|
|||||||
ctx.JSON(http.StatusOK, &structs.LicenseSettings{})
|
ctx.JSON(http.StatusOK, &structs.LicenseSettings{})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// Compute display_name from repo metadata
|
||||||
|
var displayName string
|
||||||
|
if meta, err := repo_model.GetRepoMetadata(ctx, ctx.Repo.Repository.ID); err == nil && meta != nil {
|
||||||
|
displayName = meta.DerivedDisplayName()
|
||||||
|
}
|
||||||
ctx.JSON(http.StatusOK, &structs.LicenseSettings{
|
ctx.JSON(http.StatusOK, &structs.LicenseSettings{
|
||||||
LicensingEnabled: cfg.LicensingEnabled,
|
LicensingEnabled: cfg.LicensingEnabled,
|
||||||
RequireKey: cfg.RequireKey,
|
RequireKey: cfg.RequireKey,
|
||||||
@@ -28,7 +34,7 @@ func GetLicenseSettings(ctx *context.APIContext) {
|
|||||||
Platform: cfg.Platform,
|
Platform: cfg.Platform,
|
||||||
SupportURL: cfg.SupportURL,
|
SupportURL: cfg.SupportURL,
|
||||||
ExtensionName: cfg.ExtensionName,
|
ExtensionName: cfg.ExtensionName,
|
||||||
DisplayName: cfg.DisplayName,
|
DisplayName: displayName,
|
||||||
ExtensionType: cfg.ExtensionType,
|
ExtensionType: cfg.ExtensionType,
|
||||||
Maintainer: cfg.Maintainer,
|
Maintainer: cfg.Maintainer,
|
||||||
MaintainerURL: cfg.MaintainerURL,
|
MaintainerURL: cfg.MaintainerURL,
|
||||||
@@ -51,7 +57,6 @@ func UpdateLicenseSettings(ctx *context.APIContext) {
|
|||||||
Platform: form.Platform,
|
Platform: form.Platform,
|
||||||
SupportURL: form.SupportURL,
|
SupportURL: form.SupportURL,
|
||||||
ExtensionName: form.ExtensionName,
|
ExtensionName: form.ExtensionName,
|
||||||
DisplayName: form.DisplayName,
|
|
||||||
ExtensionType: form.ExtensionType,
|
ExtensionType: form.ExtensionType,
|
||||||
Maintainer: form.Maintainer,
|
Maintainer: form.Maintainer,
|
||||||
MaintainerURL: form.MaintainerURL,
|
MaintainerURL: form.MaintainerURL,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ type apiMetadata struct {
|
|||||||
Platform string `json:"platform"`
|
Platform string `json:"platform"`
|
||||||
StandardsVersion string `json:"standards_version"`
|
StandardsVersion string `json:"standards_version"`
|
||||||
StandardsSource string `json:"standards_source"`
|
StandardsSource string `json:"standards_source"`
|
||||||
DisplayName string `json:"display_name"`
|
DisplayName string `json:"display_name"` // read-only, computed from extension_type + name
|
||||||
Maintainer string `json:"maintainer"`
|
Maintainer string `json:"maintainer"`
|
||||||
MaintainerURL string `json:"maintainer_url"`
|
MaintainerURL string `json:"maintainer_url"`
|
||||||
InfoURL string `json:"info_url"`
|
InfoURL string `json:"info_url"`
|
||||||
@@ -72,7 +72,7 @@ func GetRepoMetadata(ctx *context.APIContext) {
|
|||||||
Platform: m.Platform,
|
Platform: m.Platform,
|
||||||
StandardsVersion: m.StandardsVersion,
|
StandardsVersion: m.StandardsVersion,
|
||||||
StandardsSource: m.StandardsSource,
|
StandardsSource: m.StandardsSource,
|
||||||
DisplayName: m.DisplayName,
|
DisplayName: m.DerivedDisplayName(),
|
||||||
Maintainer: m.Maintainer,
|
Maintainer: m.Maintainer,
|
||||||
MaintainerURL: m.MaintainerURL,
|
MaintainerURL: m.MaintainerURL,
|
||||||
InfoURL: m.InfoURL,
|
InfoURL: m.InfoURL,
|
||||||
@@ -115,7 +115,6 @@ func UpdateRepoMetadata(ctx *context.APIContext) {
|
|||||||
Platform: req.Platform,
|
Platform: req.Platform,
|
||||||
StandardsVersion: req.StandardsVersion,
|
StandardsVersion: req.StandardsVersion,
|
||||||
StandardsSource: req.StandardsSource,
|
StandardsSource: req.StandardsSource,
|
||||||
DisplayName: req.DisplayName,
|
|
||||||
Maintainer: req.Maintainer,
|
Maintainer: req.Maintainer,
|
||||||
MaintainerURL: req.MaintainerURL,
|
MaintainerURL: req.MaintainerURL,
|
||||||
InfoURL: req.InfoURL,
|
InfoURL: req.InfoURL,
|
||||||
@@ -143,7 +142,7 @@ func UpdateRepoMetadata(ctx *context.APIContext) {
|
|||||||
Platform: m.Platform,
|
Platform: m.Platform,
|
||||||
StandardsVersion: m.StandardsVersion,
|
StandardsVersion: m.StandardsVersion,
|
||||||
StandardsSource: m.StandardsSource,
|
StandardsSource: m.StandardsSource,
|
||||||
DisplayName: m.DisplayName,
|
DisplayName: m.DerivedDisplayName(),
|
||||||
Maintainer: m.Maintainer,
|
Maintainer: m.Maintainer,
|
||||||
MaintainerURL: m.MaintainerURL,
|
MaintainerURL: m.MaintainerURL,
|
||||||
InfoURL: m.InfoURL,
|
InfoURL: m.InfoURL,
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ func SettingsUpdateStreamsPost(ctx *context.Context) {
|
|||||||
SupportURL: ctx.FormString("support_url"),
|
SupportURL: ctx.FormString("support_url"),
|
||||||
KeyPrefix: strings.ToUpper(strings.TrimSpace(ctx.FormString("key_prefix"))),
|
KeyPrefix: strings.ToUpper(strings.TrimSpace(ctx.FormString("key_prefix"))),
|
||||||
ExtensionName: ctx.FormString("extension_name"),
|
ExtensionName: ctx.FormString("extension_name"),
|
||||||
DisplayName: ctx.FormString("display_name"),
|
|
||||||
Description: ctx.FormString("feed_description"),
|
Description: ctx.FormString("feed_description"),
|
||||||
ExtensionType: ctx.FormString("extension_type"),
|
ExtensionType: ctx.FormString("extension_type"),
|
||||||
Maintainer: ctx.FormString("maintainer"),
|
Maintainer: ctx.FormString("maintainer"),
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ func saveMetadata(ctx *context.Context) {
|
|||||||
manifest.ElementName = existing.ElementName
|
manifest.ElementName = existing.ElementName
|
||||||
manifest.StandardsVersion = existing.StandardsVersion
|
manifest.StandardsVersion = existing.StandardsVersion
|
||||||
manifest.StandardsSource = existing.StandardsSource
|
manifest.StandardsSource = existing.StandardsSource
|
||||||
manifest.DisplayName = existing.DisplayName
|
|
||||||
manifest.Maintainer = existing.Maintainer
|
manifest.Maintainer = existing.Maintainer
|
||||||
manifest.MaintainerURL = existing.MaintainerURL
|
manifest.MaintainerURL = existing.MaintainerURL
|
||||||
manifest.Language = existing.Language
|
manifest.Language = existing.Language
|
||||||
|
|||||||
@@ -696,7 +696,6 @@ func handleSettingsPostAdvanced(ctx *context.Context) {
|
|||||||
DownloadGating: form.DownloadGating,
|
DownloadGating: form.DownloadGating,
|
||||||
SupportURL: form.SupportURL,
|
SupportURL: form.SupportURL,
|
||||||
ExtensionName: form.ExtensionName,
|
ExtensionName: form.ExtensionName,
|
||||||
DisplayName: form.DisplayName,
|
|
||||||
ExtensionType: form.ExtensionType,
|
ExtensionType: form.ExtensionType,
|
||||||
TargetVersion: form.TargetVersion,
|
TargetVersion: form.TargetVersion,
|
||||||
Maintainer: form.Maintainer,
|
Maintainer: form.Maintainer,
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ type RepoSettingForm struct {
|
|||||||
DownloadGating string
|
DownloadGating string
|
||||||
SupportURL string
|
SupportURL string
|
||||||
ExtensionName string
|
ExtensionName string
|
||||||
DisplayName string
|
|
||||||
ExtensionType string
|
ExtensionType string
|
||||||
TargetVersion string
|
TargetVersion string
|
||||||
Maintainer string
|
Maintainer string
|
||||||
|
|||||||
@@ -198,8 +198,8 @@ func resolveExtensionMetadata(ctx context.Context, repo *repo_model.Repository,
|
|||||||
if manifest.ExtensionType != "" {
|
if manifest.ExtensionType != "" {
|
||||||
m.ExtType = manifest.ExtensionType
|
m.ExtType = manifest.ExtensionType
|
||||||
}
|
}
|
||||||
if manifest.DisplayName != "" {
|
if dn := manifest.DerivedDisplayName(); dn != "" {
|
||||||
m.DisplayName = manifest.DisplayName
|
m.DisplayName = dn
|
||||||
}
|
}
|
||||||
if manifest.TargetVersion != "" {
|
if manifest.TargetVersion != "" {
|
||||||
m.TargetVersion = manifest.TargetVersion
|
m.TargetVersion = manifest.TargetVersion
|
||||||
|
|||||||
@@ -86,11 +86,6 @@
|
|||||||
<input name="extension_name" value="{{.StreamConfig.ExtensionName}}" placeholder="pkg_mokowaas">
|
<input name="extension_name" value="{{.StreamConfig.ExtensionName}}" placeholder="pkg_mokowaas">
|
||||||
<p class="help">{{ctx.Locale.Tr "org.settings.extension_name_help"}}</p>
|
<p class="help">{{ctx.Locale.Tr "org.settings.extension_name_help"}}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
|
||||||
<label>{{ctx.Locale.Tr "org.settings.display_name"}}</label>
|
|
||||||
<input name="display_name" value="{{.StreamConfig.DisplayName}}" placeholder="Package - MokoWaaS">
|
|
||||||
<p class="help">{{ctx.Locale.Tr "org.settings.display_name_help"}}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|||||||
@@ -67,11 +67,6 @@
|
|||||||
<input name="extension_name" value="{{if .RepoUpdateConfig}}{{.RepoUpdateConfig.ExtensionName}}{{end}}" placeholder="pkg_myextension">
|
<input name="extension_name" value="{{if .RepoUpdateConfig}}{{.RepoUpdateConfig.ExtensionName}}{{end}}" placeholder="pkg_myextension">
|
||||||
<p class="help">{{ctx.Locale.Tr "org.settings.extension_name_help"}}</p>
|
<p class="help">{{ctx.Locale.Tr "org.settings.extension_name_help"}}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
|
||||||
<label>{{ctx.Locale.Tr "org.settings.display_name"}}</label>
|
|
||||||
<input name="display_name" value="{{if .RepoUpdateConfig}}{{.RepoUpdateConfig.DisplayName}}{{end}}" placeholder="Package - My Extension">
|
|
||||||
<p class="help">{{ctx.Locale.Tr "org.settings.display_name_help"}}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="two fields">
|
<div class="two fields">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|||||||
Reference in New Issue
Block a user