feat(settings): separate update server page from metadata
Generic: Repo Health / Site Health (push) Has been skipped
Generic: Repo Health / Access control (push) Successful in 1s
Generic: Project CI / Lint & Validate (push) Successful in 30s
Deploy MokoGitea / deploy (push) Successful in 3m26s
Generic: Project CI / Tests (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Generic: Repo Health / Report Issues (push) Has been cancelled
Generic: Repo Health / Site Health (push) Has been skipped
Generic: Repo Health / Access control (push) Successful in 1s
Generic: Project CI / Lint & Validate (push) Successful in 30s
Deploy MokoGitea / deploy (push) Successful in 3m26s
Generic: Project CI / Tests (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Generic: Repo Health / Report Issues (push) Has been cancelled
- /settings/metadata: project identity + custom fields - /settings/updateserver: enable, platform, visibility, gating, keys - Update server nav link shown when LicensingEnabled - Old /settings/licensing and /settings/manifest redirect
This commit is contained in:
@@ -9,10 +9,10 @@ import (
|
||||
|
||||
// LicensingSettings redirects to the manifest page where licensing is now consolidated.
|
||||
func LicensingSettings(ctx *context.Context) {
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings/metadata")
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings/updateserver")
|
||||
}
|
||||
|
||||
// LicensingSettingsPost redirects POST to the manifest page.
|
||||
func LicensingSettingsPost(ctx *context.Context) {
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings/metadata")
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings/updateserver")
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
issues_model "code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/issues"
|
||||
repo_model "code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/repo"
|
||||
updateserver_model "code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/updateserver"
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/log"
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/templates"
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/services/context"
|
||||
)
|
||||
@@ -33,9 +32,6 @@ func Metadata(ctx *context.Context) {
|
||||
ctx.ServerError("GetRepoManifest", err)
|
||||
return
|
||||
}
|
||||
if manifest == nil {
|
||||
manifest = tryMigrateManifestXML(ctx)
|
||||
}
|
||||
if manifest == nil {
|
||||
manifest = &repo_model.RepoManifest{
|
||||
RepoID: repoID,
|
||||
@@ -78,8 +74,6 @@ func MetadataPost(ctx *context.Context) {
|
||||
switch ctx.FormString("action") {
|
||||
case "manifest":
|
||||
saveManifest(ctx)
|
||||
case "updateserver":
|
||||
saveLicensingSettings(ctx)
|
||||
case "customfields":
|
||||
saveCustomFields(ctx)
|
||||
default:
|
||||
@@ -138,41 +132,3 @@ func saveCustomFields(ctx *context.Context) {
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings/metadata")
|
||||
}
|
||||
|
||||
// saveLicensingSettings handles the update server form.
|
||||
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("Update server settings saved")
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings/metadata")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
// Copyright 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package setting
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
updateserver_model "code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/updateserver"
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/log"
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/templates"
|
||||
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/services/context"
|
||||
)
|
||||
|
||||
const tplSettingsUpdateServer templates.TplName = "repo/settings/updateserver"
|
||||
|
||||
// UpdateServerSettings displays the update server settings page.
|
||||
func UpdateServerSettings(ctx *context.Context) {
|
||||
ctx.Data["Title"] = "Update Server"
|
||||
ctx.Data["PageIsSettingsUpdateServer"] = true
|
||||
|
||||
repoCfg, _ := updateserver_model.GetRepoConfig(ctx, ctx.Repo.Repository.ID)
|
||||
ctx.Data["RepoUpdateConfig"] = repoCfg
|
||||
|
||||
ctx.HTML(http.StatusOK, tplSettingsUpdateServer)
|
||||
}
|
||||
|
||||
// UpdateServerSettingsPost saves update server settings.
|
||||
func UpdateServerSettingsPost(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("Update server settings saved")
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings/updateserver")
|
||||
}
|
||||
+3
-2
@@ -1230,8 +1230,9 @@ func registerWebRoutes(m *web.Router, webAuth *AuthMiddleware) {
|
||||
m.Combo("/advanced").Get(repo_setting.AdvancedSettings).Post(web.Bind(forms.RepoSettingForm{}), repo_setting.SettingsPost)
|
||||
}, repo_setting.SettingsCtxData)
|
||||
m.Combo("/metadata").Get(repo_setting.Metadata).Post(repo_setting.MetadataPost)
|
||||
m.Combo("/manifest").Get(repo_setting.LicensingSettings).Post(repo_setting.LicensingSettingsPost) // redirect to metadata
|
||||
m.Combo("/licensing").Get(repo_setting.LicensingSettings).Post(repo_setting.LicensingSettingsPost) // redirect to metadata
|
||||
m.Combo("/updateserver").Get(repo_setting.UpdateServerSettings).Post(repo_setting.UpdateServerSettingsPost)
|
||||
m.Combo("/manifest").Get(repo_setting.LicensingSettings).Post(repo_setting.LicensingSettingsPost) // redirect
|
||||
m.Combo("/licensing").Get(repo_setting.LicensingSettings).Post(repo_setting.LicensingSettingsPost) // redirect
|
||||
m.Group("/security", func() {
|
||||
m.Combo("").Get(repo_setting.SecuritySettings).Post(repo_setting.SecuritySettingsPost)
|
||||
m.Post("/scan", repo_setting.SecurityScanNow)
|
||||
|
||||
@@ -136,76 +136,6 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{{if .LicensingEnabled}}
|
||||
<h4 class="ui top attached header">
|
||||
{{svg "octicon-broadcast" 16}} Update Server
|
||||
</h4>
|
||||
<div class="ui attached segment">
|
||||
<form class="ui form" method="post" action="{{.RepoLink}}/settings/metadata?action=updateserver">
|
||||
{{.CsrfTokenHtml}}
|
||||
|
||||
<div class="inline field">
|
||||
<div class="ui checkbox">
|
||||
<input name="enable_licensing" type="checkbox" {{if and .RepoUpdateConfig .RepoUpdateConfig.LicensingEnabled}}checked{{end}}>
|
||||
<label><strong>Enable Update Server</strong></label>
|
||||
</div>
|
||||
<p class="help">Serve update feeds from releases and show the Licenses tab for optional key management.</p>
|
||||
</div>
|
||||
|
||||
<div class="ui divider"></div>
|
||||
|
||||
<div class="inline field">
|
||||
<label>Feed Platform</label>
|
||||
<select name="update_platform" class="ui dropdown">
|
||||
<option value="joomla" {{if or (not .RepoUpdateConfig) (eq .RepoUpdateConfig.Platform "joomla") (eq .RepoUpdateConfig.Platform "")}}selected{{end}}>Joomla (updates.xml)</option>
|
||||
<option value="dolibarr" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.Platform "dolibarr")}}selected{{end}}>Dolibarr (JSON)</option>
|
||||
<option value="wordpress" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.Platform "wordpress")}}selected{{end}}>WordPress (JSON)</option>
|
||||
<option value="composer" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.Platform "composer")}}selected{{end}}>Composer (packages.json)</option>
|
||||
<option value="prestashop" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.Platform "prestashop")}}selected{{end}}>PrestaShop</option>
|
||||
<option value="drupal" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.Platform "drupal")}}selected{{end}}>Drupal</option>
|
||||
<option value="both" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.Platform "both")}}selected{{end}}>Both (Joomla + Dolibarr)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="inline field">
|
||||
<label>Feed Visibility</label>
|
||||
<select name="feed_visibility" class="ui dropdown">
|
||||
<option value="public" {{if or (not .RepoUpdateConfig) (eq .RepoUpdateConfig.FeedVisibility "") (eq .RepoUpdateConfig.FeedVisibility "public")}}selected{{end}}>Public (show versions and downloads)</option>
|
||||
<option value="no-download" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.FeedVisibility "no-download")}}selected{{end}}>No downloads (show versions only)</option>
|
||||
<option value="hidden" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.FeedVisibility "hidden")}}selected{{end}}>Hidden (require license key)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="inline field">
|
||||
<label>Download Gating</label>
|
||||
<select name="download_gating" class="ui dropdown">
|
||||
<option value="none" {{if or (not .RepoUpdateConfig) (eq .RepoUpdateConfig.DownloadGating "") (eq .RepoUpdateConfig.DownloadGating "none")}}selected{{end}}>None</option>
|
||||
<option value="prerelease" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.DownloadGating "prerelease")}}selected{{end}}>Pre-release only</option>
|
||||
<option value="all" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.DownloadGating "all")}}selected{{end}}>All releases</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{if and .RepoUpdateConfig (ne .RepoUpdateConfig.Platform "joomla") (ne .RepoUpdateConfig.Platform "both") (ne .RepoUpdateConfig.Platform "")}}
|
||||
<div class="inline field">
|
||||
<div class="ui checkbox">
|
||||
<input name="require_update_key" type="checkbox" {{if .RepoUpdateConfig.RequireKey}}checked{{end}}>
|
||||
<label>Require license key for update feed</label>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div class="inline field">
|
||||
<label>Support URL</label>
|
||||
<input name="support_url" value="{{if .RepoUpdateConfig}}{{.RepoUpdateConfig.SupportURL}}{{end}}" placeholder="https://mokoconsulting.tech/support">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<button class="ui primary button">Save Update Server</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if .CustomFieldDefs}}
|
||||
<h4 class="ui top attached header">
|
||||
{{svg "octicon-list-unordered" 16}} Custom Fields
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
<a class="{{if .PageIsSettingsMetadata}}active {{end}}item" href="{{.RepoLink}}/settings/metadata">
|
||||
{{svg "octicon-file-code"}} Metadata
|
||||
</a>
|
||||
{{if .LicensingEnabled}}
|
||||
<a class="{{if .PageIsSettingsUpdateServer}}active {{end}}item" href="{{.RepoLink}}/settings/updateserver">
|
||||
{{svg "octicon-broadcast"}} Update Server
|
||||
</a>
|
||||
{{end}}
|
||||
<a class="{{if .PageIsSettingsSecurity}}active {{end}}item" href="{{.RepoLink}}/settings/security">
|
||||
{{svg "octicon-shield"}} {{ctx.Locale.Tr "repo.settings.security"}}
|
||||
</a>
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
{{template "repo/settings/layout_head" (dict "pageClass" "repository settings updateserver")}}
|
||||
<div class="user-main-content twelve wide column">
|
||||
<h4 class="ui top attached header">
|
||||
{{svg "octicon-broadcast" 16}} Update Server
|
||||
</h4>
|
||||
<div class="ui attached segment">
|
||||
<form class="ui form" method="post" action="{{.RepoLink}}/settings/updateserver">
|
||||
{{.CsrfTokenHtml}}
|
||||
|
||||
<div class="inline field">
|
||||
<div class="ui checkbox">
|
||||
<input name="enable_licensing" type="checkbox" {{if and .RepoUpdateConfig .RepoUpdateConfig.LicensingEnabled}}checked{{end}}>
|
||||
<label><strong>Enable Update Server</strong></label>
|
||||
</div>
|
||||
<p class="help">Serve update feeds from releases and show the Licenses tab for optional key management.</p>
|
||||
</div>
|
||||
|
||||
<div class="ui divider"></div>
|
||||
|
||||
<div class="inline field">
|
||||
<label>Feed Platform</label>
|
||||
<select name="update_platform" class="ui dropdown">
|
||||
<option value="joomla" {{if or (not .RepoUpdateConfig) (eq .RepoUpdateConfig.Platform "joomla") (eq .RepoUpdateConfig.Platform "")}}selected{{end}}>Joomla (updates.xml)</option>
|
||||
<option value="dolibarr" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.Platform "dolibarr")}}selected{{end}}>Dolibarr (JSON)</option>
|
||||
<option value="wordpress" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.Platform "wordpress")}}selected{{end}}>WordPress (JSON)</option>
|
||||
<option value="composer" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.Platform "composer")}}selected{{end}}>Composer (packages.json)</option>
|
||||
<option value="prestashop" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.Platform "prestashop")}}selected{{end}}>PrestaShop</option>
|
||||
<option value="drupal" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.Platform "drupal")}}selected{{end}}>Drupal</option>
|
||||
<option value="both" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.Platform "both")}}selected{{end}}>Both (Joomla + Dolibarr)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="inline field">
|
||||
<label>Feed Visibility</label>
|
||||
<select name="feed_visibility" class="ui dropdown">
|
||||
<option value="public" {{if or (not .RepoUpdateConfig) (eq .RepoUpdateConfig.FeedVisibility "") (eq .RepoUpdateConfig.FeedVisibility "public")}}selected{{end}}>Public (show versions and downloads)</option>
|
||||
<option value="no-download" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.FeedVisibility "no-download")}}selected{{end}}>No downloads (show versions only)</option>
|
||||
<option value="hidden" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.FeedVisibility "hidden")}}selected{{end}}>Hidden (require license key)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="inline field">
|
||||
<label>Download Gating</label>
|
||||
<select name="download_gating" class="ui dropdown">
|
||||
<option value="none" {{if or (not .RepoUpdateConfig) (eq .RepoUpdateConfig.DownloadGating "") (eq .RepoUpdateConfig.DownloadGating "none")}}selected{{end}}>None</option>
|
||||
<option value="prerelease" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.DownloadGating "prerelease")}}selected{{end}}>Pre-release only</option>
|
||||
<option value="all" {{if and .RepoUpdateConfig (eq .RepoUpdateConfig.DownloadGating "all")}}selected{{end}}>All releases</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{if and .RepoUpdateConfig (ne .RepoUpdateConfig.Platform "joomla") (ne .RepoUpdateConfig.Platform "both") (ne .RepoUpdateConfig.Platform "")}}
|
||||
<div class="inline field">
|
||||
<div class="ui checkbox">
|
||||
<input name="require_update_key" type="checkbox" {{if .RepoUpdateConfig.RequireKey}}checked{{end}}>
|
||||
<label>Require license key for update feed</label>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div class="inline field">
|
||||
<label>Support URL</label>
|
||||
<input name="support_url" value="{{if .RepoUpdateConfig}}{{.RepoUpdateConfig.SupportURL}}{{end}}" placeholder="https://mokoconsulting.tech/support">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<button class="ui primary button">Save Update Server</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{{template "repo/settings/layout_footer" .}}
|
||||
Reference in New Issue
Block a user