diff --git a/options/locale/locale_en-US.json b/options/locale/locale_en-US.json index 49bc4e96cd..2a8ec5f596 100644 --- a/options/locale/locale_en-US.json +++ b/options/locale/locale_en-US.json @@ -2716,6 +2716,8 @@ "repo.settings.download_gating": "Download Gating", "repo.settings.support_url": "Support / Product Page URL", "repo.settings.support_url_help": "Shown when downloads are gated. Can point to your wiki, product page, or external support site.", + "repo.settings.features": "Features", + "repo.settings.features_units": "Units", "repo.settings.change_visibility": "Change Visibility", "repo.settings.visibility.warning": "Changing repository visibility affects who can access code, releases, and update feeds.", "repo.settings.visibility.public.label": "Public", diff --git a/routers/web/repo/setting/licensing.go b/routers/web/repo/setting/licensing.go new file mode 100644 index 0000000000..4b76e4fe16 --- /dev/null +++ b/routers/web/repo/setting/licensing.go @@ -0,0 +1,62 @@ +// Copyright 2026 Moko Consulting +// SPDX-License-Identifier: GPL-3.0-or-later + +package setting + +import ( + "net/http" + + licenses_model "code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/licenses" + "code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/log" + "code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/templates" + "code.mokoconsulting.tech/MokoConsulting/MokoGitea/services/context" +) + +const tplSettingsLicensing templates.TplName = "repo/settings/licensing" + +// LicensingSettings displays the licensing settings page. +func LicensingSettings(ctx *context.Context) { + ctx.Data["Title"] = ctx.Tr("repo.settings.licensing_section") + ctx.Data["PageIsSettingsLicensing"] = true + + repoCfg, _ := licenses_model.GetRepoConfig(ctx, ctx.Repo.Repository.ID) + ctx.Data["RepoUpdateConfig"] = repoCfg + + ctx.HTML(http.StatusOK, tplSettingsLicensing) +} + +// LicensingSettingsPost saves the licensing settings. +func LicensingSettingsPost(ctx *context.Context) { + repo := ctx.Repo.Repository + + updatePlatform := ctx.FormString("update_platform") + if updatePlatform == "" { + updatePlatform = "joomla" + } + + updateCfg := &licenses_model.UpdateStreamConfig{ + OwnerID: repo.OwnerID, + RepoID: repo.ID, + Platform: updatePlatform, + LicensingEnabled: ctx.FormString("enable_licensing") == "on", + RequireKey: ctx.FormString("require_update_key") == "on", + DownloadGating: ctx.FormString("download_gating"), + SupportURL: ctx.FormString("support_url"), + ExtensionName: ctx.FormString("extension_name"), + DisplayName: ctx.FormString("display_name"), + ExtensionType: ctx.FormString("extension_type"), + TargetVersion: ctx.FormString("target_version"), + Maintainer: ctx.FormString("maintainer"), + PHPMinimum: ctx.FormString("php_minimum"), + StreamMode: "joomla", + } + + if err := licenses_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/licensing") +} diff --git a/routers/web/web.go b/routers/web/web.go index 67b4be89ec..0aceeddf0b 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1183,6 +1183,7 @@ func registerWebRoutes(m *web.Router, webAuth *AuthMiddleware) { m.Post("/avatar/delete", repo_setting.SettingsDeleteAvatar) m.Combo("/public_access").Get(repo_setting.PublicAccess).Post(repo_setting.PublicAccessPost) + m.Combo("/licensing").Get(repo_setting.LicensingSettings).Post(repo_setting.LicensingSettingsPost) m.Group("/collaboration", func() { m.Combo("").Get(repo_setting.Collaboration).Post(repo_setting.CollaborationPost) diff --git a/templates/repo/settings/licensing.tmpl b/templates/repo/settings/licensing.tmpl new file mode 100644 index 0000000000..da748d5644 --- /dev/null +++ b/templates/repo/settings/licensing.tmpl @@ -0,0 +1,110 @@ +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings licensing")}} +
+

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

+
+
+ + +
+
+ + +
+

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

+
+ +
+ +
+ + +

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

+
+ +
+
+ + +
+

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

+
+ +
+ + +

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

+
+ +
+ + +

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

+
+ +
+
{{ctx.Locale.Tr "repo.settings.extension_metadata"}}
+

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

+ +
+
+ + +

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

+
+
+ + +

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

+
+
+
+
+ + +
+
+ + +

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

+
+
+
+
+ + +
+
+ + +
+
+ +
+ +
+
+
+
+{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/navbar.tmpl b/templates/repo/settings/navbar.tmpl index ba25e34ba4..8a096e94e9 100644 --- a/templates/repo/settings/navbar.tmpl +++ b/templates/repo/settings/navbar.tmpl @@ -38,8 +38,16 @@ {{end}} {{end}} + + {{svg "octicon-tools"}} {{ctx.Locale.Tr "repo.settings.advanced_settings"}} + + {{if .LicensingEnabled}} + + {{svg "octicon-key"}} {{ctx.Locale.Tr "repo.settings.licensing_section"}} + + {{end}}
- {{ctx.Locale.Tr "actions.actions"}} + {{svg "octicon-play"}} {{ctx.Locale.Tr "actions.actions"}}