mirror of
https://github.com/gogs/gogs.git
synced 2026-06-25 02:11:40 +02:00
conf: overhaul server settings (#5928)
* conf: rename package * Requires Go 1.12 * Fix lint * Fix lint * Overhaul * db: fix tests * Save my work * Fix tests * Server.UnixSocketPermission * Server.LocalRootURL * SSH settings * Server.OfflineMode * Save my work * App.Version * Remove [server] STATIC_ROOT_PATH * Server.LandingURL
This commit is contained in:
@@ -14,12 +14,12 @@ import (
|
||||
"github.com/unknwon/com"
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/cron"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/mailer"
|
||||
"gogs.io/gogs/internal/process"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -168,10 +168,10 @@ func Dashboard(c *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.Data["GitVersion"] = setting.Git.Version
|
||||
c.Data["GitVersion"] = conf.Git.Version
|
||||
c.Data["GoVersion"] = runtime.Version()
|
||||
c.Data["BuildTime"] = setting.BuildTime
|
||||
c.Data["BuildCommit"] = setting.BuildCommit
|
||||
c.Data["BuildTime"] = conf.BuildTime
|
||||
c.Data["BuildCommit"] = conf.BuildCommit
|
||||
|
||||
c.Data["Stats"] = db.GetStatistic()
|
||||
// FIXME: update periodically
|
||||
@@ -189,7 +189,7 @@ func SendTestMail(c *context.Context) {
|
||||
c.Flash.Info(c.Tr("admin.config.test_mail_sent", email))
|
||||
}
|
||||
|
||||
c.Redirect(setting.AppSubURL + "/admin/config")
|
||||
c.Redirect(conf.Server.Subpath + "/admin/config")
|
||||
}
|
||||
|
||||
func Config(c *context.Context) {
|
||||
@@ -197,54 +197,53 @@ func Config(c *context.Context) {
|
||||
c.Data["PageIsAdmin"] = true
|
||||
c.Data["PageIsAdminConfig"] = true
|
||||
|
||||
c.Data["AppURL"] = setting.AppURL
|
||||
c.Data["Domain"] = setting.Domain
|
||||
c.Data["OfflineMode"] = setting.OfflineMode
|
||||
c.Data["DisableRouterLog"] = setting.DisableRouterLog
|
||||
c.Data["RunUser"] = setting.RunUser
|
||||
c.Data["AppURL"] = conf.Server.ExternalURL
|
||||
c.Data["Domain"] = conf.Server.Domain
|
||||
c.Data["OfflineMode"] = conf.Server.OfflineMode
|
||||
c.Data["DisableRouterLog"] = conf.Server.DisableRouterLog
|
||||
c.Data["RunUser"] = conf.App.RunUser
|
||||
c.Data["RunMode"] = strings.Title(macaron.Env)
|
||||
c.Data["StaticRootPath"] = setting.StaticRootPath
|
||||
c.Data["LogRootPath"] = setting.LogRootPath
|
||||
c.Data["ReverseProxyAuthUser"] = setting.ReverseProxyAuthUser
|
||||
c.Data["LogRootPath"] = conf.LogRootPath
|
||||
c.Data["ReverseProxyAuthUser"] = conf.ReverseProxyAuthUser
|
||||
|
||||
c.Data["SSH"] = setting.SSH
|
||||
c.Data["SSH"] = conf.SSH
|
||||
|
||||
c.Data["RepoRootPath"] = setting.RepoRootPath
|
||||
c.Data["ScriptType"] = setting.ScriptType
|
||||
c.Data["Repository"] = setting.Repository
|
||||
c.Data["HTTP"] = setting.HTTP
|
||||
c.Data["RepoRootPath"] = conf.RepoRootPath
|
||||
c.Data["ScriptType"] = conf.ScriptType
|
||||
c.Data["Repository"] = conf.Repository
|
||||
c.Data["HTTP"] = conf.HTTP
|
||||
|
||||
c.Data["DbCfg"] = db.DbCfg
|
||||
c.Data["Service"] = setting.Service
|
||||
c.Data["Webhook"] = setting.Webhook
|
||||
c.Data["Service"] = conf.Service
|
||||
c.Data["Webhook"] = conf.Webhook
|
||||
|
||||
c.Data["MailerEnabled"] = false
|
||||
if setting.MailService != nil {
|
||||
if conf.MailService != nil {
|
||||
c.Data["MailerEnabled"] = true
|
||||
c.Data["Mailer"] = setting.MailService
|
||||
c.Data["Mailer"] = conf.MailService
|
||||
}
|
||||
|
||||
c.Data["CacheAdapter"] = setting.CacheAdapter
|
||||
c.Data["CacheInterval"] = setting.CacheInterval
|
||||
c.Data["CacheConn"] = setting.CacheConn
|
||||
c.Data["CacheAdapter"] = conf.CacheAdapter
|
||||
c.Data["CacheInterval"] = conf.CacheInterval
|
||||
c.Data["CacheConn"] = conf.CacheConn
|
||||
|
||||
c.Data["SessionConfig"] = setting.SessionConfig
|
||||
c.Data["SessionConfig"] = conf.SessionConfig
|
||||
|
||||
c.Data["DisableGravatar"] = setting.DisableGravatar
|
||||
c.Data["EnableFederatedAvatar"] = setting.EnableFederatedAvatar
|
||||
c.Data["DisableGravatar"] = conf.DisableGravatar
|
||||
c.Data["EnableFederatedAvatar"] = conf.EnableFederatedAvatar
|
||||
|
||||
c.Data["Git"] = setting.Git
|
||||
c.Data["Git"] = conf.Git
|
||||
|
||||
type logger struct {
|
||||
Mode, Config string
|
||||
}
|
||||
loggers := make([]*logger, len(setting.LogModes))
|
||||
for i := range setting.LogModes {
|
||||
loggers := make([]*logger, len(conf.LogModes))
|
||||
for i := range conf.LogModes {
|
||||
loggers[i] = &logger{
|
||||
Mode: strings.Title(setting.LogModes[i]),
|
||||
Mode: strings.Title(conf.LogModes[i]),
|
||||
}
|
||||
|
||||
result, _ := jsoniter.MarshalIndent(setting.LogConfigs[i], "", " ")
|
||||
result, _ := jsoniter.MarshalIndent(conf.LogConfigs[i], "", " ")
|
||||
loggers[i].Config = string(result)
|
||||
}
|
||||
c.Data["Loggers"] = loggers
|
||||
|
||||
@@ -14,10 +14,10 @@ import (
|
||||
"xorm.io/core"
|
||||
|
||||
"gogs.io/gogs/internal/auth/ldap"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -175,7 +175,7 @@ func NewAuthSourcePost(c *context.Context, f form.Authentication) {
|
||||
log.Trace("Authentication created by admin(%s): %s", c.User.Name, f.Name)
|
||||
|
||||
c.Flash.Success(c.Tr("admin.auths.new_success", f.Name))
|
||||
c.Redirect(setting.AppSubURL + "/admin/auths")
|
||||
c.Redirect(conf.Server.Subpath + "/admin/auths")
|
||||
}
|
||||
|
||||
func EditAuthSource(c *context.Context) {
|
||||
@@ -248,7 +248,7 @@ func EditAuthSourcePost(c *context.Context, f form.Authentication) {
|
||||
log.Trace("Authentication changed by admin '%s': %d", c.User.Name, source.ID)
|
||||
|
||||
c.Flash.Success(c.Tr("admin.auths.update_success"))
|
||||
c.Redirect(setting.AppSubURL + "/admin/auths/" + com.ToStr(f.ID))
|
||||
c.Redirect(conf.Server.Subpath + "/admin/auths/" + com.ToStr(f.ID))
|
||||
}
|
||||
|
||||
func DeleteAuthSource(c *context.Context) {
|
||||
@@ -265,7 +265,7 @@ func DeleteAuthSource(c *context.Context) {
|
||||
c.Flash.Error(fmt.Sprintf("DeleteSource: %v", err))
|
||||
}
|
||||
c.JSONSuccess(map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/admin/auths/" + c.Params(":authid"),
|
||||
"redirect": conf.Server.Subpath + "/admin/auths/" + c.Params(":authid"),
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -273,6 +273,6 @@ func DeleteAuthSource(c *context.Context) {
|
||||
|
||||
c.Flash.Success(c.Tr("admin.auths.deletion_success"))
|
||||
c.JSONSuccess(map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/admin/auths",
|
||||
"redirect": conf.Server.Subpath + "/admin/auths",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"github.com/unknwon/paginater"
|
||||
log "unknwon.dev/clog/v2"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -28,9 +28,9 @@ func Notices(c *context.Context) {
|
||||
if page <= 1 {
|
||||
page = 1
|
||||
}
|
||||
c.Data["Page"] = paginater.New(int(total), setting.UI.Admin.NoticePagingNum, page, 5)
|
||||
c.Data["Page"] = paginater.New(int(total), conf.UI.Admin.NoticePagingNum, page, 5)
|
||||
|
||||
notices, err := db.Notices(page, setting.UI.Admin.NoticePagingNum)
|
||||
notices, err := db.Notices(page, conf.UI.Admin.NoticePagingNum)
|
||||
if err != nil {
|
||||
c.Handle(500, "Notices", err)
|
||||
return
|
||||
@@ -68,5 +68,5 @@ func EmptyNotices(c *context.Context) {
|
||||
|
||||
log.Trace("System notices deleted by admin (%s): [start: %d]", c.User.Name, 0)
|
||||
c.Flash.Success(c.Tr("admin.notices.delete_success"))
|
||||
c.Redirect(setting.AppSubURL + "/admin/notices")
|
||||
c.Redirect(conf.Server.Subpath + "/admin/notices")
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/route"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -24,7 +24,7 @@ func Organizations(c *context.Context) {
|
||||
Type: db.USER_TYPE_ORGANIZATION,
|
||||
Counter: db.CountOrganizations,
|
||||
Ranger: db.Organizations,
|
||||
PageSize: setting.UI.Admin.OrgPagingNum,
|
||||
PageSize: conf.UI.Admin.OrgPagingNum,
|
||||
OrderBy: "id ASC",
|
||||
TplName: ORGS,
|
||||
})
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"github.com/unknwon/paginater"
|
||||
log "unknwon.dev/clog/v2"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -35,7 +35,7 @@ func Repos(c *context.Context) {
|
||||
|
||||
keyword := c.Query("q")
|
||||
if len(keyword) == 0 {
|
||||
repos, err = db.Repositories(page, setting.UI.Admin.RepoPagingNum)
|
||||
repos, err = db.Repositories(page, conf.UI.Admin.RepoPagingNum)
|
||||
if err != nil {
|
||||
c.Handle(500, "Repositories", err)
|
||||
return
|
||||
@@ -47,7 +47,7 @@ func Repos(c *context.Context) {
|
||||
OrderBy: "id ASC",
|
||||
Private: true,
|
||||
Page: page,
|
||||
PageSize: setting.UI.Admin.RepoPagingNum,
|
||||
PageSize: conf.UI.Admin.RepoPagingNum,
|
||||
})
|
||||
if err != nil {
|
||||
c.Handle(500, "SearchRepositoryByName", err)
|
||||
@@ -56,7 +56,7 @@ func Repos(c *context.Context) {
|
||||
}
|
||||
c.Data["Keyword"] = keyword
|
||||
c.Data["Total"] = count
|
||||
c.Data["Page"] = paginater.New(int(count), setting.UI.Admin.RepoPagingNum, page, 5)
|
||||
c.Data["Page"] = paginater.New(int(count), conf.UI.Admin.RepoPagingNum, page, 5)
|
||||
|
||||
if err = db.RepositoryList(repos).LoadAttributes(); err != nil {
|
||||
c.Handle(500, "LoadAttributes", err)
|
||||
@@ -82,6 +82,6 @@ func DeleteRepo(c *context.Context) {
|
||||
|
||||
c.Flash.Success(c.Tr("repo.settings.deletion_success"))
|
||||
c.JSON(200, map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/admin/repos?page=" + c.Query("page"),
|
||||
"redirect": conf.Server.Subpath + "/admin/repos?page=" + c.Query("page"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ import (
|
||||
"github.com/unknwon/com"
|
||||
log "unknwon.dev/clog/v2"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/mailer"
|
||||
"gogs.io/gogs/internal/route"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -33,7 +33,7 @@ func Users(c *context.Context) {
|
||||
Type: db.USER_TYPE_INDIVIDUAL,
|
||||
Counter: db.CountUsers,
|
||||
Ranger: db.Users,
|
||||
PageSize: setting.UI.Admin.UserPagingNum,
|
||||
PageSize: conf.UI.Admin.UserPagingNum,
|
||||
OrderBy: "id ASC",
|
||||
TplName: USERS,
|
||||
})
|
||||
@@ -53,7 +53,7 @@ func NewUser(c *context.Context) {
|
||||
}
|
||||
c.Data["Sources"] = sources
|
||||
|
||||
c.Data["CanSendEmail"] = setting.MailService != nil
|
||||
c.Data["CanSendEmail"] = conf.MailService != nil
|
||||
c.HTML(200, USER_NEW)
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func NewUserPost(c *context.Context, f form.AdminCrateUser) {
|
||||
}
|
||||
c.Data["Sources"] = sources
|
||||
|
||||
c.Data["CanSendEmail"] = setting.MailService != nil
|
||||
c.Data["CanSendEmail"] = conf.MailService != nil
|
||||
|
||||
if c.HasError() {
|
||||
c.HTML(200, USER_NEW)
|
||||
@@ -115,12 +115,12 @@ func NewUserPost(c *context.Context, f form.AdminCrateUser) {
|
||||
log.Trace("Account created by admin (%s): %s", c.User.Name, u.Name)
|
||||
|
||||
// Send email notification.
|
||||
if f.SendNotify && setting.MailService != nil {
|
||||
if f.SendNotify && conf.MailService != nil {
|
||||
mailer.SendRegisterNotifyMail(c.Context, db.NewMailerUser(u))
|
||||
}
|
||||
|
||||
c.Flash.Success(c.Tr("admin.users.new_success", u.Name))
|
||||
c.Redirect(setting.AppSubURL + "/admin/users/" + com.ToStr(u.ID))
|
||||
c.Redirect(conf.Server.Subpath + "/admin/users/" + com.ToStr(u.ID))
|
||||
}
|
||||
|
||||
func prepareUserInfo(c *context.Context) *db.User {
|
||||
@@ -155,7 +155,7 @@ func EditUser(c *context.Context) {
|
||||
c.Data["Title"] = c.Tr("admin.users.edit_account")
|
||||
c.Data["PageIsAdmin"] = true
|
||||
c.Data["PageIsAdminUsers"] = true
|
||||
c.Data["EnableLocalPathMigration"] = setting.Repository.EnableLocalPathMigration
|
||||
c.Data["EnableLocalPathMigration"] = conf.Repository.EnableLocalPathMigration
|
||||
|
||||
prepareUserInfo(c)
|
||||
if c.Written() {
|
||||
@@ -169,7 +169,7 @@ func EditUserPost(c *context.Context, f form.AdminEditUser) {
|
||||
c.Data["Title"] = c.Tr("admin.users.edit_account")
|
||||
c.Data["PageIsAdmin"] = true
|
||||
c.Data["PageIsAdminUsers"] = true
|
||||
c.Data["EnableLocalPathMigration"] = setting.Repository.EnableLocalPathMigration
|
||||
c.Data["EnableLocalPathMigration"] = conf.Repository.EnableLocalPathMigration
|
||||
|
||||
u := prepareUserInfo(c)
|
||||
if c.Written() {
|
||||
@@ -226,7 +226,7 @@ func EditUserPost(c *context.Context, f form.AdminEditUser) {
|
||||
log.Trace("Account profile updated by admin (%s): %s", c.User.Name, u.Name)
|
||||
|
||||
c.Flash.Success(c.Tr("admin.users.update_profile_success"))
|
||||
c.Redirect(setting.AppSubURL + "/admin/users/" + c.Params(":userid"))
|
||||
c.Redirect(conf.Server.Subpath + "/admin/users/" + c.Params(":userid"))
|
||||
}
|
||||
|
||||
func DeleteUser(c *context.Context) {
|
||||
@@ -241,12 +241,12 @@ func DeleteUser(c *context.Context) {
|
||||
case db.IsErrUserOwnRepos(err):
|
||||
c.Flash.Error(c.Tr("admin.users.still_own_repo"))
|
||||
c.JSON(200, map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/admin/users/" + c.Params(":userid"),
|
||||
"redirect": conf.Server.Subpath + "/admin/users/" + c.Params(":userid"),
|
||||
})
|
||||
case db.IsErrUserHasOrgs(err):
|
||||
c.Flash.Error(c.Tr("admin.users.still_has_org"))
|
||||
c.JSON(200, map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/admin/users/" + c.Params(":userid"),
|
||||
"redirect": conf.Server.Subpath + "/admin/users/" + c.Params(":userid"),
|
||||
})
|
||||
default:
|
||||
c.Handle(500, "DeleteUser", err)
|
||||
@@ -257,6 +257,6 @@ func DeleteUser(c *context.Context) {
|
||||
|
||||
c.Flash.Success(c.Tr("admin.users.deletion_success"))
|
||||
c.JSON(200, map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/admin/users",
|
||||
"redirect": conf.Server.Subpath + "/admin/users",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user