mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-30 23:53:52 +03:00
df789d962b
This PR implements a [Cargo registry](https://doc.rust-lang.org/cargo/) to manage Rust packages. This package type was a little bit more complicated because Cargo needs an additional Git repository to store its package index. Screenshots: ![grafik](https://user-images.githubusercontent.com/1666336/203102004-08d812ac-c066-4969-9bda-2fed818554eb.png) ![grafik](https://user-images.githubusercontent.com/1666336/203102141-d9970f14-dca6-4174-b17a-50ba1bd79087.png) ![grafik](https://user-images.githubusercontent.com/1666336/203102244-dc05743b-78b6-4d97-998e-ef76341a978f.png) --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
97 lines
2.5 KiB
Go
97 lines
2.5 KiB
Go
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"code.gitea.io/gitea/modules/base"
|
|
"code.gitea.io/gitea/modules/context"
|
|
"code.gitea.io/gitea/modules/setting"
|
|
shared "code.gitea.io/gitea/routers/web/shared/packages"
|
|
)
|
|
|
|
const (
|
|
tplSettingsPackages base.TplName = "user/settings/packages"
|
|
tplSettingsPackagesRuleEdit base.TplName = "user/settings/packages_cleanup_rules_edit"
|
|
tplSettingsPackagesRulePreview base.TplName = "user/settings/packages_cleanup_rules_preview"
|
|
)
|
|
|
|
func Packages(ctx *context.Context) {
|
|
ctx.Data["Title"] = ctx.Tr("packages.title")
|
|
ctx.Data["PageIsSettingsPackages"] = true
|
|
|
|
shared.SetPackagesContext(ctx, ctx.Doer)
|
|
|
|
ctx.HTML(http.StatusOK, tplSettingsPackages)
|
|
}
|
|
|
|
func PackagesRuleAdd(ctx *context.Context) {
|
|
ctx.Data["Title"] = ctx.Tr("packages.title")
|
|
ctx.Data["PageIsSettingsPackages"] = true
|
|
|
|
shared.SetRuleAddContext(ctx)
|
|
|
|
ctx.HTML(http.StatusOK, tplSettingsPackagesRuleEdit)
|
|
}
|
|
|
|
func PackagesRuleEdit(ctx *context.Context) {
|
|
ctx.Data["Title"] = ctx.Tr("packages.title")
|
|
ctx.Data["PageIsSettingsPackages"] = true
|
|
|
|
shared.SetRuleEditContext(ctx, ctx.Doer)
|
|
|
|
ctx.HTML(http.StatusOK, tplSettingsPackagesRuleEdit)
|
|
}
|
|
|
|
func PackagesRuleAddPost(ctx *context.Context) {
|
|
ctx.Data["Title"] = ctx.Tr("settings")
|
|
ctx.Data["PageIsSettingsPackages"] = true
|
|
|
|
shared.PerformRuleAddPost(
|
|
ctx,
|
|
ctx.Doer,
|
|
setting.AppSubURL+"/user/settings/packages",
|
|
tplSettingsPackagesRuleEdit,
|
|
)
|
|
}
|
|
|
|
func PackagesRuleEditPost(ctx *context.Context) {
|
|
ctx.Data["Title"] = ctx.Tr("packages.title")
|
|
ctx.Data["PageIsSettingsPackages"] = true
|
|
|
|
shared.PerformRuleEditPost(
|
|
ctx,
|
|
ctx.Doer,
|
|
setting.AppSubURL+"/user/settings/packages",
|
|
tplSettingsPackagesRuleEdit,
|
|
)
|
|
}
|
|
|
|
func PackagesRulePreview(ctx *context.Context) {
|
|
ctx.Data["Title"] = ctx.Tr("packages.title")
|
|
ctx.Data["PageIsSettingsPackages"] = true
|
|
|
|
shared.SetRulePreviewContext(ctx, ctx.Doer)
|
|
|
|
ctx.HTML(http.StatusOK, tplSettingsPackagesRulePreview)
|
|
}
|
|
|
|
func InitializeCargoIndex(ctx *context.Context) {
|
|
ctx.Data["Title"] = ctx.Tr("packages.title")
|
|
ctx.Data["PageIsSettingsPackages"] = true
|
|
|
|
shared.InitializeCargoIndex(ctx, ctx.Doer)
|
|
|
|
ctx.Redirect(setting.AppSubURL + "/user/settings/packages")
|
|
}
|
|
|
|
func RebuildCargoIndex(ctx *context.Context) {
|
|
ctx.Data["Title"] = ctx.Tr("packages.title")
|
|
ctx.Data["PageIsSettingsPackages"] = true
|
|
|
|
shared.RebuildCargoIndex(ctx, ctx.Doer)
|
|
|
|
ctx.Redirect(setting.AppSubURL + "/user/settings/packages")
|
|
}
|