mirror of
https://github.com/gogs/gogs.git
synced 2026-09-08 05:28:16 +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",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/mailer"
|
||||
"gogs.io/gogs/internal/route/api/v1/user"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
func parseLoginSource(c *context.APIContext, u *db.User, sourceID int64, loginName string) {
|
||||
@@ -68,7 +68,7 @@ func CreateUser(c *context.APIContext, form api.CreateUserOption) {
|
||||
log.Trace("Account created by admin %q: %s", c.User.Name, u.Name)
|
||||
|
||||
// Send email notification.
|
||||
if form.SendNotify && setting.MailService != nil {
|
||||
if form.SendNotify && conf.MailService != nil {
|
||||
mailer.SendRegisterNotifyMail(c.Context.Context, db.NewMailerUser(u))
|
||||
}
|
||||
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
package convert
|
||||
|
||||
import (
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
// ToCorrectPageSize makes sure page size is in allowed range.
|
||||
func ToCorrectPageSize(size int) int {
|
||||
if size <= 0 {
|
||||
size = 10
|
||||
} else if size > setting.API.MaxResponseItems {
|
||||
size = setting.API.MaxResponseItems
|
||||
} else if size > conf.API.MaxResponseItems {
|
||||
size = conf.API.MaxResponseItems
|
||||
}
|
||||
return size
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ import (
|
||||
"github.com/gogs/git-module"
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
func GetSingleCommit(c *context.APIContext) {
|
||||
@@ -70,12 +70,12 @@ func GetSingleCommit(c *context.APIContext) {
|
||||
|
||||
c.JSONSuccess(&api.Commit{
|
||||
CommitMeta: &api.CommitMeta{
|
||||
URL: setting.AppURL + c.Link[1:],
|
||||
URL: conf.Server.ExternalURL + c.Link[1:],
|
||||
SHA: commit.ID.String(),
|
||||
},
|
||||
HTMLURL: c.Repo.Repository.HTMLURL() + "/commits/" + commit.ID.String(),
|
||||
RepoCommit: &api.RepoCommit{
|
||||
URL: setting.AppURL + c.Link[1:],
|
||||
URL: conf.Server.ExternalURL + c.Link[1:],
|
||||
Author: &api.CommitUser{
|
||||
Name: commit.Author.Name,
|
||||
Email: commit.Author.Email,
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
func listIssues(c *context.APIContext, opts *db.IssuesOptions) {
|
||||
@@ -40,7 +40,7 @@ func listIssues(c *context.APIContext, opts *db.IssuesOptions) {
|
||||
apiIssues[i] = issues[i].APIFormat()
|
||||
}
|
||||
|
||||
c.SetLinkHeader(int(count), setting.UI.IssuePagingNum)
|
||||
c.SetLinkHeader(int(count), conf.UI.IssuePagingNum)
|
||||
c.JSONSuccess(&apiIssues)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ import (
|
||||
|
||||
api "github.com/gogs/go-gogs-client"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
func composeDeployKeysAPILink(repoPath string) string {
|
||||
return setting.AppURL + "api/v1/repos/" + repoPath + "/keys/"
|
||||
return conf.Server.ExternalURL + "api/v1/repos/" + repoPath + "/keys/"
|
||||
}
|
||||
|
||||
// https://github.com/gogs/go-gogs-client/wiki/Repositories-Deploy-Keys#list-deploy-keys
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/route/api/v1/convert"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
func Search(c *context.APIContext) {
|
||||
@@ -263,7 +263,7 @@ func Migrate(c *context.APIContext, f form.MigrateRepo) {
|
||||
repo, err := db.MigrateRepository(c.User, ctxUser, db.MigrateRepoOptions{
|
||||
Name: f.RepoName,
|
||||
Description: f.Description,
|
||||
IsPrivate: f.Private || setting.Repository.ForcePrivate,
|
||||
IsPrivate: f.Private || conf.Repository.ForcePrivate,
|
||||
IsMirror: f.Mirror,
|
||||
RemoteAddr: remoteAddr,
|
||||
})
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
func ListEmails(c *context.APIContext) {
|
||||
@@ -39,7 +39,7 @@ func AddEmail(c *context.APIContext, form api.CreateEmailOption) {
|
||||
emails[i] = &db.EmailAddress{
|
||||
UID: c.User.ID,
|
||||
Email: form.Emails[i],
|
||||
IsActivated: !setting.Service.RegisterEmailConfirm,
|
||||
IsActivated: !conf.Service.RegisterEmailConfirm,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
repo2 "gogs.io/gogs/internal/route/api/v1/repo"
|
||||
"net/http"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
func GetUserByParamsName(c *context.APIContext, name string) *db.User {
|
||||
@@ -31,7 +31,7 @@ func GetUserByParams(c *context.APIContext) *db.User {
|
||||
}
|
||||
|
||||
func composePublicKeysAPILink() string {
|
||||
return setting.AppURL + "api/v1/user/keys/"
|
||||
return conf.Server.ExternalURL + "api/v1/user/keys/"
|
||||
}
|
||||
|
||||
func listPublicKeys(c *context.APIContext, uid int64) {
|
||||
|
||||
@@ -5,19 +5,19 @@
|
||||
package dev
|
||||
|
||||
import (
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
func TemplatePreview(c *context.Context) {
|
||||
c.Data["User"] = db.User{Name: "Unknown"}
|
||||
c.Data["AppName"] = setting.AppName
|
||||
c.Data["AppVersion"] = setting.AppVersion
|
||||
c.Data["AppURL"] = setting.AppURL
|
||||
c.Data["AppName"] = conf.App.BrandName
|
||||
c.Data["AppVersion"] = conf.App.Version
|
||||
c.Data["AppURL"] = conf.Server.ExternalURL
|
||||
c.Data["Code"] = "2014031910370000009fff6782aadb2162b4a997acb69d4400888e0b9274657374"
|
||||
c.Data["ActiveCodeLives"] = setting.Service.ActiveCodeLives / 60
|
||||
c.Data["ResetPwdCodeLives"] = setting.Service.ResetPwdCodeLives / 60
|
||||
c.Data["ActiveCodeLives"] = conf.Service.ActiveCodeLives / 60
|
||||
c.Data["ResetPwdCodeLives"] = conf.Service.ResetPwdCodeLives / 60
|
||||
c.Data["CurDbValue"] = ""
|
||||
|
||||
c.HTML(200, (c.Params("*")))
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"github.com/unknwon/paginater"
|
||||
user2 "gogs.io/gogs/internal/route/user"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -22,7 +22,7 @@ const (
|
||||
|
||||
func Home(c *context.Context) {
|
||||
if c.IsLogged {
|
||||
if !c.User.IsActive && setting.Service.RegisterEmailConfirm {
|
||||
if !c.User.IsActive && conf.Service.RegisterEmailConfirm {
|
||||
c.Data["Title"] = c.Tr("auth.active_your_account")
|
||||
c.Success(user2.ACTIVATE)
|
||||
} else {
|
||||
@@ -32,9 +32,9 @@ func Home(c *context.Context) {
|
||||
}
|
||||
|
||||
// Check auto-login.
|
||||
uname := c.GetCookie(setting.CookieUserName)
|
||||
uname := c.GetCookie(conf.CookieUserName)
|
||||
if len(uname) != 0 {
|
||||
c.Redirect(setting.AppSubURL + "/user/login")
|
||||
c.Redirect(conf.Server.Subpath + "/user/login")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func ExploreRepos(c *context.Context) {
|
||||
UserID: c.UserID(),
|
||||
OrderBy: "updated_unix DESC",
|
||||
Page: page,
|
||||
PageSize: setting.UI.ExplorePagingNum,
|
||||
PageSize: conf.UI.ExplorePagingNum,
|
||||
})
|
||||
if err != nil {
|
||||
c.ServerError("SearchRepositoryByName", err)
|
||||
@@ -66,7 +66,7 @@ func ExploreRepos(c *context.Context) {
|
||||
}
|
||||
c.Data["Keyword"] = keyword
|
||||
c.Data["Total"] = count
|
||||
c.Data["Page"] = paginater.New(int(count), setting.UI.ExplorePagingNum, page, 5)
|
||||
c.Data["Page"] = paginater.New(int(count), conf.UI.ExplorePagingNum, page, 5)
|
||||
|
||||
if err = db.RepositoryList(repos).LoadAttributes(); err != nil {
|
||||
c.ServerError("RepositoryList.LoadAttributes", err)
|
||||
@@ -136,7 +136,7 @@ func ExploreUsers(c *context.Context) {
|
||||
Type: db.USER_TYPE_INDIVIDUAL,
|
||||
Counter: db.CountUsers,
|
||||
Ranger: db.Users,
|
||||
PageSize: setting.UI.ExplorePagingNum,
|
||||
PageSize: conf.UI.ExplorePagingNum,
|
||||
OrderBy: "updated_unix DESC",
|
||||
TplName: EXPLORE_USERS,
|
||||
})
|
||||
@@ -151,7 +151,7 @@ func ExploreOrganizations(c *context.Context) {
|
||||
Type: db.USER_TYPE_ORGANIZATION,
|
||||
Counter: db.CountOrganizations,
|
||||
Ranger: db.Organizations,
|
||||
PageSize: setting.UI.ExplorePagingNum,
|
||||
PageSize: conf.UI.ExplorePagingNum,
|
||||
OrderBy: "updated_unix DESC",
|
||||
TplName: EXPLORE_ORGANIZATIONS,
|
||||
})
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/unknwon/com"
|
||||
"gopkg.in/ini.v1"
|
||||
"gopkg.in/macaron.v1"
|
||||
@@ -19,13 +20,14 @@ import (
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/cron"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/mailer"
|
||||
"gogs.io/gogs/internal/markup"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/osutil"
|
||||
"gogs.io/gogs/internal/ssh"
|
||||
"gogs.io/gogs/internal/template/highlight"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
@@ -37,7 +39,7 @@ const (
|
||||
)
|
||||
|
||||
func checkRunMode() {
|
||||
if setting.ProdMode {
|
||||
if conf.IsProdMode() {
|
||||
macaron.Env = macaron.PROD
|
||||
macaron.ColorLog = false
|
||||
} else {
|
||||
@@ -47,20 +49,26 @@ func checkRunMode() {
|
||||
}
|
||||
|
||||
// GlobalInit is for global configuration reload-able.
|
||||
func GlobalInit() {
|
||||
setting.Init()
|
||||
setting.InitLogging()
|
||||
log.Info("%s %s", setting.AppName, setting.AppVersion)
|
||||
log.Trace("Custom path: %s", setting.CustomPath)
|
||||
log.Trace("Log path: %s", setting.LogRootPath)
|
||||
log.Trace("Build time: %s", setting.BuildTime)
|
||||
log.Trace("Build commit: %s", setting.BuildCommit)
|
||||
func GlobalInit(customConf string) error {
|
||||
err := conf.Init(customConf)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "init configuration")
|
||||
}
|
||||
|
||||
conf.InitLogging()
|
||||
log.Info("%s %s", conf.App.BrandName, conf.App.Version)
|
||||
log.Trace("Work directory: %s", conf.WorkDir())
|
||||
log.Trace("Custom path: %s", conf.CustomDir())
|
||||
log.Trace("Custom config: %s", conf.CustomConf)
|
||||
log.Trace("Log path: %s", conf.LogRootPath)
|
||||
log.Trace("Build time: %s", conf.BuildTime)
|
||||
log.Trace("Build commit: %s", conf.BuildCommit)
|
||||
|
||||
db.LoadConfigs()
|
||||
setting.NewServices()
|
||||
conf.NewServices()
|
||||
mailer.NewContext()
|
||||
|
||||
if setting.InstallLock {
|
||||
if conf.InstallLock {
|
||||
highlight.NewContext()
|
||||
markup.NewSanitizer()
|
||||
if err := db.NewEngine(); err != nil {
|
||||
@@ -81,33 +89,35 @@ func GlobalInit() {
|
||||
if db.EnableSQLite3 {
|
||||
log.Info("SQLite3 is supported")
|
||||
}
|
||||
if setting.SupportWindowsService() {
|
||||
if conf.HasMinWinSvc {
|
||||
log.Info("Builtin Windows Service is supported")
|
||||
}
|
||||
if setting.LoadAssetsFromDisk {
|
||||
if conf.Server.LoadAssetsFromDisk {
|
||||
log.Trace("Assets are loaded from disk")
|
||||
}
|
||||
checkRunMode()
|
||||
|
||||
if !setting.InstallLock {
|
||||
return
|
||||
if !conf.InstallLock {
|
||||
return nil
|
||||
}
|
||||
|
||||
if setting.SSH.StartBuiltinServer {
|
||||
ssh.Listen(setting.SSH.ListenHost, setting.SSH.ListenPort, setting.SSH.ServerCiphers)
|
||||
log.Info("SSH server started on %s:%v", setting.SSH.ListenHost, setting.SSH.ListenPort)
|
||||
log.Trace("SSH server cipher list: %v", setting.SSH.ServerCiphers)
|
||||
if conf.SSH.StartBuiltinServer {
|
||||
ssh.Listen(conf.SSH.ListenHost, conf.SSH.ListenPort, conf.SSH.ServerCiphers)
|
||||
log.Info("SSH server started on %s:%v", conf.SSH.ListenHost, conf.SSH.ListenPort)
|
||||
log.Trace("SSH server cipher list: %v", conf.SSH.ServerCiphers)
|
||||
}
|
||||
|
||||
if setting.SSH.RewriteAuthorizedKeysAtStart {
|
||||
if conf.SSH.RewriteAuthorizedKeysAtStart {
|
||||
if err := db.RewriteAuthorizedKeys(); err != nil {
|
||||
log.Warn("Failed to rewrite authorized_keys file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func InstallInit(c *context.Context) {
|
||||
if setting.InstallLock {
|
||||
if conf.InstallLock {
|
||||
c.NotFound()
|
||||
return
|
||||
}
|
||||
@@ -144,40 +154,40 @@ func Install(c *context.Context) {
|
||||
}
|
||||
|
||||
// Application general settings
|
||||
f.AppName = setting.AppName
|
||||
f.RepoRootPath = setting.RepoRootPath
|
||||
f.AppName = conf.App.BrandName
|
||||
f.RepoRootPath = conf.RepoRootPath
|
||||
|
||||
// Note(unknwon): it's hard for Windows users change a running user,
|
||||
// so just use current one if config says default.
|
||||
if setting.IsWindows && setting.RunUser == "git" {
|
||||
if conf.IsWindowsRuntime() && conf.App.RunUser == "git" {
|
||||
f.RunUser = user.CurrentUsername()
|
||||
} else {
|
||||
f.RunUser = setting.RunUser
|
||||
f.RunUser = conf.App.RunUser
|
||||
}
|
||||
|
||||
f.Domain = setting.Domain
|
||||
f.SSHPort = setting.SSH.Port
|
||||
f.UseBuiltinSSHServer = setting.SSH.StartBuiltinServer
|
||||
f.HTTPPort = setting.HTTPPort
|
||||
f.AppUrl = setting.AppURL
|
||||
f.LogRootPath = setting.LogRootPath
|
||||
f.Domain = conf.Server.Domain
|
||||
f.SSHPort = conf.SSH.Port
|
||||
f.UseBuiltinSSHServer = conf.SSH.StartBuiltinServer
|
||||
f.HTTPPort = conf.Server.HTTPPort
|
||||
f.AppUrl = conf.Server.ExternalURL
|
||||
f.LogRootPath = conf.LogRootPath
|
||||
|
||||
// E-mail service settings
|
||||
if setting.MailService != nil {
|
||||
f.SMTPHost = setting.MailService.Host
|
||||
f.SMTPFrom = setting.MailService.From
|
||||
f.SMTPUser = setting.MailService.User
|
||||
if conf.MailService != nil {
|
||||
f.SMTPHost = conf.MailService.Host
|
||||
f.SMTPFrom = conf.MailService.From
|
||||
f.SMTPUser = conf.MailService.User
|
||||
}
|
||||
f.RegisterConfirm = setting.Service.RegisterEmailConfirm
|
||||
f.MailNotify = setting.Service.EnableNotifyMail
|
||||
f.RegisterConfirm = conf.Service.RegisterEmailConfirm
|
||||
f.MailNotify = conf.Service.EnableNotifyMail
|
||||
|
||||
// Server and other services settings
|
||||
f.OfflineMode = setting.OfflineMode
|
||||
f.DisableGravatar = setting.DisableGravatar
|
||||
f.EnableFederatedAvatar = setting.EnableFederatedAvatar
|
||||
f.DisableRegistration = setting.Service.DisableRegistration
|
||||
f.EnableCaptcha = setting.Service.EnableCaptcha
|
||||
f.RequireSignInView = setting.Service.RequireSignInView
|
||||
f.OfflineMode = conf.Server.OfflineMode
|
||||
f.DisableGravatar = conf.DisableGravatar
|
||||
f.EnableFederatedAvatar = conf.EnableFederatedAvatar
|
||||
f.DisableRegistration = conf.Service.DisableRegistration
|
||||
f.EnableCaptcha = conf.Service.EnableCaptcha
|
||||
f.RequireSignInView = conf.Service.RequireSignInView
|
||||
|
||||
form.Assign(f, c.Data)
|
||||
c.Success(INSTALL)
|
||||
@@ -251,7 +261,7 @@ func InstallPost(c *context.Context, f form.Install) {
|
||||
return
|
||||
}
|
||||
|
||||
currentUser, match := setting.IsRunUserMatchCurrentUser(f.RunUser)
|
||||
currentUser, match := conf.IsRunUserMatchCurrentUser(f.RunUser)
|
||||
if !match {
|
||||
c.FormErr("RunUser")
|
||||
c.RenderWithErr(c.Tr("install.run_user_not_match", f.RunUser, currentUser), INSTALL, &f)
|
||||
@@ -300,10 +310,10 @@ func InstallPost(c *context.Context, f form.Install) {
|
||||
|
||||
// Save settings.
|
||||
cfg := ini.Empty()
|
||||
if com.IsFile(setting.CustomConf) {
|
||||
if osutil.IsFile(conf.CustomConf) {
|
||||
// Keeps custom settings if there is already something.
|
||||
if err := cfg.Append(setting.CustomConf); err != nil {
|
||||
log.Error("Failed to load custom conf '%s': %v", setting.CustomConf, err)
|
||||
if err := cfg.Append(conf.CustomConf); err != nil {
|
||||
log.Error("Failed to load custom conf %q: %v", conf.CustomConf, err)
|
||||
}
|
||||
}
|
||||
cfg.Section("database").Key("DB_TYPE").SetValue(db.DbCfg.Type)
|
||||
@@ -368,13 +378,18 @@ func InstallPost(c *context.Context, f form.Install) {
|
||||
}
|
||||
cfg.Section("security").Key("SECRET_KEY").SetValue(secretKey)
|
||||
|
||||
os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm)
|
||||
if err := cfg.SaveTo(setting.CustomConf); err != nil {
|
||||
_ = os.MkdirAll(filepath.Dir(conf.CustomConf), os.ModePerm)
|
||||
if err := cfg.SaveTo(conf.CustomConf); err != nil {
|
||||
c.RenderWithErr(c.Tr("install.save_config_failed", err), INSTALL, &f)
|
||||
return
|
||||
}
|
||||
|
||||
GlobalInit()
|
||||
// NOTE: We reuse the current value because this handler does not have access to CLI flags.
|
||||
err = GlobalInit(conf.CustomConf)
|
||||
if err != nil {
|
||||
c.RenderWithErr(c.Tr("install.init_failed", err), INSTALL, &f)
|
||||
return
|
||||
}
|
||||
|
||||
// Create admin account
|
||||
if len(f.AdminName) > 0 {
|
||||
@@ -387,7 +402,7 @@ func InstallPost(c *context.Context, f form.Install) {
|
||||
}
|
||||
if err := db.CreateUser(u); err != nil {
|
||||
if !db.IsErrUserAlreadyExist(err) {
|
||||
setting.InstallLock = false
|
||||
conf.InstallLock = false
|
||||
c.FormErr("AdminName", "AdminEmail")
|
||||
c.RenderWithErr(c.Tr("install.invalid_admin_setting", err), INSTALL, &f)
|
||||
return
|
||||
|
||||
@@ -8,10 +8,10 @@ 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/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -87,7 +87,7 @@ func MembersAction(c *context.Context) {
|
||||
if c.Params(":action") != "leave" {
|
||||
c.Redirect(c.Org.OrgLink + "/members")
|
||||
} else {
|
||||
c.Redirect(setting.AppSubURL + "/")
|
||||
c.Redirect(conf.Server.Subpath + "/")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ package org
|
||||
import (
|
||||
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/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -52,5 +52,5 @@ func CreatePost(c *context.Context, f form.CreateOrg) {
|
||||
}
|
||||
log.Trace("Organization created: %s", org.Name)
|
||||
|
||||
c.Redirect(setting.AppSubURL + "/org/" + f.OrgName + "/dashboard")
|
||||
c.Redirect(conf.Server.Subpath + "/org/" + f.OrgName + "/dashboard")
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
|
||||
log "unknwon.dev/clog/v2"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/route/user"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -63,7 +63,7 @@ func SettingsPost(c *context.Context, f form.UpdateOrgSetting) {
|
||||
return
|
||||
}
|
||||
// reset c.org.OrgLink with new name
|
||||
c.Org.OrgLink = setting.AppSubURL + "/org/" + f.Name
|
||||
c.Org.OrgLink = conf.Server.Subpath + "/org/" + f.Name
|
||||
log.Trace("Organization name changed: %s -> %s", org.Name, f.Name)
|
||||
}
|
||||
// In case it's just a case change.
|
||||
@@ -130,7 +130,7 @@ func SettingsDelete(c *context.Context) {
|
||||
}
|
||||
} else {
|
||||
log.Trace("Organization deleted: %s", org.Name)
|
||||
c.Redirect(setting.AppSubURL + "/")
|
||||
c.Redirect(conf.Server.Subpath + "/")
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func Webhooks(c *context.Context) {
|
||||
c.Data["PageIsSettingsHooks"] = true
|
||||
c.Data["BaseLink"] = c.Org.OrgLink
|
||||
c.Data["Description"] = c.Tr("org.settings.hooks_desc")
|
||||
c.Data["Types"] = setting.Webhook.Types
|
||||
c.Data["Types"] = conf.Webhook.Types
|
||||
|
||||
ws, err := db.GetWebhooksByOrgID(c.Org.Organization.ID)
|
||||
if err != nil {
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -135,8 +135,8 @@ func Diff(c *context.Context) {
|
||||
}
|
||||
|
||||
diff, err := db.GetDiffCommit(db.RepoPath(userName, repoName),
|
||||
commitID, setting.Git.MaxGitDiffLines,
|
||||
setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles)
|
||||
commitID, conf.Git.MaxGitDiffLines,
|
||||
conf.Git.MaxGitDiffLineCharacters, conf.Git.MaxGitDiffFiles)
|
||||
if err != nil {
|
||||
c.NotFoundOrServerError("get diff commit", git.IsErrNotExist, err)
|
||||
return
|
||||
@@ -168,11 +168,11 @@ func Diff(c *context.Context) {
|
||||
c.Data["Diff"] = diff
|
||||
c.Data["Parents"] = parents
|
||||
c.Data["DiffNotAvailable"] = diff.NumFiles() == 0
|
||||
c.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", commitID)
|
||||
c.Data["SourcePath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "src", commitID)
|
||||
if commit.ParentCount() > 0 {
|
||||
c.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", parents[0])
|
||||
c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "src", parents[0])
|
||||
}
|
||||
c.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "raw", commitID)
|
||||
c.Data["RawPath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "raw", commitID)
|
||||
c.Success(DIFF)
|
||||
}
|
||||
|
||||
@@ -202,8 +202,8 @@ func CompareDiff(c *context.Context) {
|
||||
}
|
||||
|
||||
diff, err := db.GetDiffRange(db.RepoPath(userName, repoName), beforeCommitID,
|
||||
afterCommitID, setting.Git.MaxGitDiffLines,
|
||||
setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles)
|
||||
afterCommitID, conf.Git.MaxGitDiffLines,
|
||||
conf.Git.MaxGitDiffLineCharacters, conf.Git.MaxGitDiffFiles)
|
||||
if err != nil {
|
||||
c.Handle(404, "GetDiffRange", err)
|
||||
return
|
||||
@@ -229,8 +229,8 @@ func CompareDiff(c *context.Context) {
|
||||
c.Data["Commit"] = commit
|
||||
c.Data["Diff"] = diff
|
||||
c.Data["DiffNotAvailable"] = diff.NumFiles() == 0
|
||||
c.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", afterCommitID)
|
||||
c.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", beforeCommitID)
|
||||
c.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "raw", afterCommitID)
|
||||
c.Data["SourcePath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "src", afterCommitID)
|
||||
c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "src", beforeCommitID)
|
||||
c.Data["RawPath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "raw", afterCommitID)
|
||||
c.HTML(200, DIFF)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -35,7 +35,7 @@ func serveData(c *context.Context, name string, r io.Reader) error {
|
||||
c.Resp.Header().Set("Content-Disposition", "attachment; filename=\""+name+"\"")
|
||||
c.Resp.Header().Set("Content-Transfer-Encoding", "binary")
|
||||
}
|
||||
} else if !setting.Repository.EnableRawFileRenderMode || !c.QueryBool("render") {
|
||||
} else if !conf.Repository.EnableRawFileRenderMode || !c.QueryBool("render") {
|
||||
c.Resp.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
}
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@ import (
|
||||
log "unknwon.dev/clog/v2"
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/pathutil"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/template"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
@@ -110,10 +110,10 @@ func editFile(c *context.Context, isNewFile bool) {
|
||||
c.Data["commit_choice"] = "direct"
|
||||
c.Data["new_branch_name"] = ""
|
||||
c.Data["last_commit"] = c.Repo.Commit.ID
|
||||
c.Data["MarkdownFileExts"] = strings.Join(setting.Markdown.FileExtensions, ",")
|
||||
c.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",")
|
||||
c.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
|
||||
c.Data["EditorconfigURLPrefix"] = fmt.Sprintf("%s/api/v1/repos/%s/editorconfig/", setting.AppSubURL, c.Repo.Repository.FullName())
|
||||
c.Data["MarkdownFileExts"] = strings.Join(conf.Markdown.FileExtensions, ",")
|
||||
c.Data["LineWrapExtensions"] = strings.Join(conf.Repository.Editor.LineWrapExtensions, ",")
|
||||
c.Data["PreviewableFileModes"] = strings.Join(conf.Repository.Editor.PreviewableFileModes, ",")
|
||||
c.Data["EditorconfigURLPrefix"] = fmt.Sprintf("%s/api/v1/repos/%s/editorconfig/", conf.Server.Subpath, c.Repo.Repository.FullName())
|
||||
|
||||
c.Success(EDIT_FILE)
|
||||
}
|
||||
@@ -156,9 +156,9 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
|
||||
c.Data["commit_choice"] = f.CommitChoice
|
||||
c.Data["new_branch_name"] = branchName
|
||||
c.Data["last_commit"] = f.LastCommit
|
||||
c.Data["MarkdownFileExts"] = strings.Join(setting.Markdown.FileExtensions, ",")
|
||||
c.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",")
|
||||
c.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
|
||||
c.Data["MarkdownFileExts"] = strings.Join(conf.Markdown.FileExtensions, ",")
|
||||
c.Data["LineWrapExtensions"] = strings.Join(conf.Repository.Editor.LineWrapExtensions, ",")
|
||||
c.Data["PreviewableFileModes"] = strings.Join(conf.Repository.Editor.PreviewableFileModes, ",")
|
||||
|
||||
if c.HasError() {
|
||||
c.Success(EDIT_FILE)
|
||||
@@ -400,9 +400,9 @@ func DeleteFilePost(c *context.Context, f form.DeleteRepoFile) {
|
||||
|
||||
func renderUploadSettings(c *context.Context) {
|
||||
c.RequireDropzone()
|
||||
c.Data["UploadAllowedTypes"] = strings.Join(setting.Repository.Upload.AllowedTypes, ",")
|
||||
c.Data["UploadMaxSize"] = setting.Repository.Upload.FileMaxSize
|
||||
c.Data["UploadMaxFiles"] = setting.Repository.Upload.MaxFiles
|
||||
c.Data["UploadAllowedTypes"] = strings.Join(conf.Repository.Upload.AllowedTypes, ",")
|
||||
c.Data["UploadMaxSize"] = conf.Repository.Upload.FileMaxSize
|
||||
c.Data["UploadMaxFiles"] = conf.Repository.Upload.MaxFiles
|
||||
}
|
||||
|
||||
func UploadFile(c *context.Context) {
|
||||
@@ -533,9 +533,9 @@ func UploadFileToServer(c *context.Context) {
|
||||
}
|
||||
fileType := http.DetectContentType(buf)
|
||||
|
||||
if len(setting.Repository.Upload.AllowedTypes) > 0 {
|
||||
if len(conf.Repository.Upload.AllowedTypes) > 0 {
|
||||
allowed := false
|
||||
for _, t := range setting.Repository.Upload.AllowedTypes {
|
||||
for _, t := range conf.Repository.Upload.AllowedTypes {
|
||||
t := strings.Trim(t, " ")
|
||||
if t == "*/*" || t == fileType {
|
||||
allowed = true
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/lazyregexp"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -44,9 +44,9 @@ func askCredentials(c *context.Context, status int, text string) {
|
||||
|
||||
func HTTPContexter() macaron.Handler {
|
||||
return func(c *context.Context) {
|
||||
if len(setting.HTTP.AccessControlAllowOrigin) > 0 {
|
||||
if len(conf.HTTP.AccessControlAllowOrigin) > 0 {
|
||||
// Set CORS headers for browser-based git clients
|
||||
c.Resp.Header().Set("Access-Control-Allow-Origin", setting.HTTP.AccessControlAllowOrigin)
|
||||
c.Resp.Header().Set("Access-Control-Allow-Origin", conf.HTTP.AccessControlAllowOrigin)
|
||||
c.Resp.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization, User-Agent")
|
||||
|
||||
// Handle preflight OPTIONS request
|
||||
@@ -77,7 +77,7 @@ func HTTPContexter() macaron.Handler {
|
||||
}
|
||||
|
||||
// Authentication is not required for pulling from public repositories.
|
||||
if isPull && !repo.IsPrivate && !setting.Service.RequireSignInView {
|
||||
if isPull && !repo.IsPrivate && !conf.Service.RequireSignInView {
|
||||
c.Map(&HTTPContext{
|
||||
Context: c,
|
||||
})
|
||||
@@ -368,7 +368,7 @@ func getGitRepoPath(dir string) (string, error) {
|
||||
dir += ".git"
|
||||
}
|
||||
|
||||
filename := path.Join(setting.RepoRootPath, dir)
|
||||
filename := path.Join(conf.RepoRootPath, dir)
|
||||
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
||||
return "", err
|
||||
}
|
||||
@@ -387,7 +387,7 @@ func HTTP(c *HTTPContext) {
|
||||
// We perform check here because route matched in cmd/web.go is wider than needed,
|
||||
// but we only want to output this message only if user is really trying to access
|
||||
// Git HTTP endpoints.
|
||||
if setting.Repository.DisableHTTPGit {
|
||||
if conf.Repository.DisableHTTPGit {
|
||||
c.HandleText(http.StatusForbidden, "Interacting with repositories by HTTP protocol is not disabled")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ 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/db/errors"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/markup"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -116,8 +116,8 @@ func issues(c *context.Context, isPullList bool) {
|
||||
|
||||
// Must sign in to see issues about you.
|
||||
if viewType != "all" && !c.IsLogged {
|
||||
c.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubURL+c.Req.RequestURI), 0, setting.AppSubURL)
|
||||
c.Redirect(setting.AppSubURL + "/user/login")
|
||||
c.SetCookie("redirect_to", "/"+url.QueryEscape(conf.Server.Subpath+c.Req.RequestURI), 0, conf.Server.Subpath)
|
||||
c.Redirect(conf.Server.Subpath + "/user/login")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ func issues(c *context.Context, isPullList bool) {
|
||||
} else {
|
||||
total = int(issueStats.ClosedCount)
|
||||
}
|
||||
pager := paginater.New(total, setting.UI.IssuePagingNum, page, 5)
|
||||
pager := paginater.New(total, conf.UI.IssuePagingNum, page, 5)
|
||||
c.Data["Page"] = pager
|
||||
|
||||
issues, err := db.Issues(&db.IssuesOptions{
|
||||
@@ -256,10 +256,10 @@ func Pulls(c *context.Context) {
|
||||
|
||||
func renderAttachmentSettings(c *context.Context) {
|
||||
c.Data["RequireDropzone"] = true
|
||||
c.Data["IsAttachmentEnabled"] = setting.AttachmentEnabled
|
||||
c.Data["AttachmentAllowedTypes"] = setting.AttachmentAllowedTypes
|
||||
c.Data["AttachmentMaxSize"] = setting.AttachmentMaxSize
|
||||
c.Data["AttachmentMaxFiles"] = setting.AttachmentMaxFiles
|
||||
c.Data["IsAttachmentEnabled"] = conf.AttachmentEnabled
|
||||
c.Data["AttachmentAllowedTypes"] = conf.AttachmentAllowedTypes
|
||||
c.Data["AttachmentMaxSize"] = conf.AttachmentMaxSize
|
||||
c.Data["AttachmentMaxFiles"] = conf.AttachmentMaxFiles
|
||||
}
|
||||
|
||||
func RetrieveRepoMilestonesAndAssignees(c *context.Context, repo *db.Repository) {
|
||||
@@ -429,7 +429,7 @@ func NewIssuePost(c *context.Context, f form.NewIssue) {
|
||||
}
|
||||
|
||||
var attachments []string
|
||||
if setting.AttachmentEnabled {
|
||||
if conf.AttachmentEnabled {
|
||||
attachments = f.Files
|
||||
}
|
||||
|
||||
@@ -493,12 +493,12 @@ func uploadAttachment(c *context.Context, allowedTypes []string) {
|
||||
}
|
||||
|
||||
func UploadIssueAttachment(c *context.Context) {
|
||||
if !setting.AttachmentEnabled {
|
||||
if !conf.AttachmentEnabled {
|
||||
c.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
uploadAttachment(c, strings.Split(setting.AttachmentAllowedTypes, ","))
|
||||
uploadAttachment(c, strings.Split(conf.AttachmentAllowedTypes, ","))
|
||||
}
|
||||
|
||||
func viewIssue(c *context.Context, isPullList bool) {
|
||||
@@ -669,7 +669,7 @@ func viewIssue(c *context.Context, isPullList bool) {
|
||||
c.Data["NumParticipants"] = len(participants)
|
||||
c.Data["Issue"] = issue
|
||||
c.Data["IsIssueOwner"] = c.Repo.IsWriter() || (c.IsLogged && issue.IsPoster(c.User.ID))
|
||||
c.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + c.Data["Link"].(string)
|
||||
c.Data["SignInLink"] = conf.Server.Subpath + "/user/login?redirect_to=" + c.Data["Link"].(string)
|
||||
c.HTML(200, ISSUE_VIEW)
|
||||
}
|
||||
|
||||
@@ -845,7 +845,7 @@ func NewComment(c *context.Context, f form.CreateComment) {
|
||||
}
|
||||
|
||||
var attachments []string
|
||||
if setting.AttachmentEnabled {
|
||||
if conf.AttachmentEnabled {
|
||||
attachments = f.Files
|
||||
}
|
||||
|
||||
@@ -1098,7 +1098,7 @@ func Milestones(c *context.Context) {
|
||||
} else {
|
||||
total = int(closedCount)
|
||||
}
|
||||
c.Data["Page"] = paginater.New(total, setting.UI.IssuePagingNum, page, 5)
|
||||
c.Data["Page"] = paginater.New(total, conf.UI.IssuePagingNum, page, 5)
|
||||
|
||||
miles, err := db.GetMilestones(c.Repo.Repository.ID, page, isShowClosed)
|
||||
if err != nil {
|
||||
@@ -1130,7 +1130,7 @@ func NewMilestone(c *context.Context) {
|
||||
c.Data["PageIsIssueList"] = true
|
||||
c.Data["PageIsMilestones"] = true
|
||||
c.Data["RequireDatetimepicker"] = true
|
||||
c.Data["DateLang"] = setting.DateLang(c.Locale.Language())
|
||||
c.Data["DateLang"] = conf.DateLang(c.Locale.Language())
|
||||
c.HTML(200, MILESTONE_NEW)
|
||||
}
|
||||
|
||||
@@ -1139,7 +1139,7 @@ func NewMilestonePost(c *context.Context, f form.CreateMilestone) {
|
||||
c.Data["PageIsIssueList"] = true
|
||||
c.Data["PageIsMilestones"] = true
|
||||
c.Data["RequireDatetimepicker"] = true
|
||||
c.Data["DateLang"] = setting.DateLang(c.Locale.Language())
|
||||
c.Data["DateLang"] = conf.DateLang(c.Locale.Language())
|
||||
|
||||
if c.HasError() {
|
||||
c.HTML(200, MILESTONE_NEW)
|
||||
@@ -1175,7 +1175,7 @@ func EditMilestone(c *context.Context) {
|
||||
c.Data["PageIsMilestones"] = true
|
||||
c.Data["PageIsEditMilestone"] = true
|
||||
c.Data["RequireDatetimepicker"] = true
|
||||
c.Data["DateLang"] = setting.DateLang(c.Locale.Language())
|
||||
c.Data["DateLang"] = conf.DateLang(c.Locale.Language())
|
||||
|
||||
m, err := db.GetMilestoneByRepoID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
@@ -1199,7 +1199,7 @@ func EditMilestonePost(c *context.Context, f form.CreateMilestone) {
|
||||
c.Data["PageIsMilestones"] = true
|
||||
c.Data["PageIsEditMilestone"] = true
|
||||
c.Data["RequireDatetimepicker"] = true
|
||||
c.Data["DateLang"] = setting.DateLang(c.Locale.Language())
|
||||
c.Data["DateLang"] = conf.DateLang(c.Locale.Language())
|
||||
|
||||
if c.HasError() {
|
||||
c.HTML(200, MILESTONE_NEW)
|
||||
|
||||
@@ -14,11 +14,11 @@ import (
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -354,8 +354,8 @@ func ViewPullFiles(c *context.Context) {
|
||||
}
|
||||
|
||||
diff, err := db.GetDiffRange(diffRepoPath,
|
||||
startCommitID, endCommitID, setting.Git.MaxGitDiffLines,
|
||||
setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles)
|
||||
startCommitID, endCommitID, conf.Git.MaxGitDiffLines,
|
||||
conf.Git.MaxGitDiffLineCharacters, conf.Git.MaxGitDiffFiles)
|
||||
if err != nil {
|
||||
c.ServerError("GetDiffRange", err)
|
||||
return
|
||||
@@ -383,9 +383,9 @@ func ViewPullFiles(c *context.Context) {
|
||||
c.Data["Reponame"] = pull.HeadRepo.Name
|
||||
|
||||
headTarget := path.Join(pull.HeadUserName, pull.HeadRepo.Name)
|
||||
c.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", endCommitID)
|
||||
c.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", startCommitID)
|
||||
c.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(headTarget, "raw", endCommitID)
|
||||
c.Data["SourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", endCommitID)
|
||||
c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", startCommitID)
|
||||
c.Data["RawPath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "raw", endCommitID)
|
||||
}
|
||||
|
||||
c.Data["RequireHighlightJS"] = true
|
||||
@@ -570,8 +570,8 @@ func PrepareCompareDiff(
|
||||
}
|
||||
|
||||
diff, err := db.GetDiffRange(db.RepoPath(headUser.Name, headRepo.Name),
|
||||
prInfo.MergeBase, headCommitID, setting.Git.MaxGitDiffLines,
|
||||
setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles)
|
||||
prInfo.MergeBase, headCommitID, conf.Git.MaxGitDiffLines,
|
||||
conf.Git.MaxGitDiffLineCharacters, conf.Git.MaxGitDiffFiles)
|
||||
if err != nil {
|
||||
c.ServerError("GetDiffRange", err)
|
||||
return false
|
||||
@@ -593,9 +593,9 @@ func PrepareCompareDiff(
|
||||
c.Data["IsImageFile"] = headCommit.IsImageFile
|
||||
|
||||
headTarget := path.Join(headUser.Name, repo.Name)
|
||||
c.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", headCommitID)
|
||||
c.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", prInfo.MergeBase)
|
||||
c.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(headTarget, "raw", headCommitID)
|
||||
c.Data["SourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", headCommitID)
|
||||
c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", prInfo.MergeBase)
|
||||
c.Data["RawPath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "raw", headCommitID)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -677,7 +677,7 @@ func CompareAndPullRequestPost(c *context.Context, f form.NewIssue) {
|
||||
return
|
||||
}
|
||||
|
||||
if setting.AttachmentEnabled {
|
||||
if conf.AttachmentEnabled {
|
||||
attachments = f.Files
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/markup"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -151,10 +151,10 @@ func Releases(c *context.Context) {
|
||||
|
||||
func renderReleaseAttachmentSettings(c *context.Context) {
|
||||
c.Data["RequireDropzone"] = true
|
||||
c.Data["IsAttachmentEnabled"] = setting.Release.Attachment.Enabled
|
||||
c.Data["AttachmentAllowedTypes"] = strings.Join(setting.Release.Attachment.AllowedTypes, ",")
|
||||
c.Data["AttachmentMaxSize"] = setting.Release.Attachment.MaxSize
|
||||
c.Data["AttachmentMaxFiles"] = setting.Release.Attachment.MaxFiles
|
||||
c.Data["IsAttachmentEnabled"] = conf.Release.Attachment.Enabled
|
||||
c.Data["AttachmentAllowedTypes"] = strings.Join(conf.Release.Attachment.AllowedTypes, ",")
|
||||
c.Data["AttachmentMaxSize"] = conf.Release.Attachment.MaxSize
|
||||
c.Data["AttachmentMaxFiles"] = conf.Release.Attachment.MaxFiles
|
||||
}
|
||||
|
||||
func NewRelease(c *context.Context) {
|
||||
@@ -203,7 +203,7 @@ func NewReleasePost(c *context.Context, f form.NewRelease) {
|
||||
}
|
||||
|
||||
var attachments []string
|
||||
if setting.Release.Attachment.Enabled {
|
||||
if conf.Release.Attachment.Enabled {
|
||||
attachments = f.Files
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ func EditReleasePost(c *context.Context, f form.EditRelease) {
|
||||
}
|
||||
|
||||
var attachments []string
|
||||
if setting.Release.Attachment.Enabled {
|
||||
if conf.Release.Attachment.Enabled {
|
||||
attachments = f.Files
|
||||
}
|
||||
|
||||
@@ -312,11 +312,11 @@ func EditReleasePost(c *context.Context, f form.EditRelease) {
|
||||
}
|
||||
|
||||
func UploadReleaseAttachment(c *context.Context) {
|
||||
if !setting.Release.Attachment.Enabled {
|
||||
if !conf.Release.Attachment.Enabled {
|
||||
c.NotFound()
|
||||
return
|
||||
}
|
||||
uploadAttachment(c, setting.Release.Attachment.AllowedTypes)
|
||||
uploadAttachment(c, conf.Release.Attachment.AllowedTypes)
|
||||
}
|
||||
|
||||
func DeleteRelease(c *context.Context) {
|
||||
|
||||
@@ -15,11 +15,11 @@ import (
|
||||
|
||||
"github.com/gogs/git-module"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -75,7 +75,7 @@ func Create(c *context.Context) {
|
||||
c.Data["Readmes"] = db.Readmes
|
||||
c.Data["readme"] = "Default"
|
||||
c.Data["private"] = c.User.LastRepoVisibility
|
||||
c.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate
|
||||
c.Data["IsForcedPrivate"] = conf.Repository.ForcePrivate
|
||||
|
||||
ctxUser := checkContextUser(c, c.QueryInt64("org"))
|
||||
if c.Written() {
|
||||
@@ -128,12 +128,12 @@ func CreatePost(c *context.Context, f form.CreateRepo) {
|
||||
Gitignores: f.Gitignores,
|
||||
License: f.License,
|
||||
Readme: f.Readme,
|
||||
IsPrivate: f.Private || setting.Repository.ForcePrivate,
|
||||
IsPrivate: f.Private || conf.Repository.ForcePrivate,
|
||||
AutoInit: f.AutoInit,
|
||||
})
|
||||
if err == nil {
|
||||
log.Trace("Repository created [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name)
|
||||
c.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name)
|
||||
c.Redirect(conf.Server.Subpath + "/" + ctxUser.Name + "/" + repo.Name)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ func CreatePost(c *context.Context, f form.CreateRepo) {
|
||||
func Migrate(c *context.Context) {
|
||||
c.Data["Title"] = c.Tr("new_migrate")
|
||||
c.Data["private"] = c.User.LastRepoVisibility
|
||||
c.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate
|
||||
c.Data["IsForcedPrivate"] = conf.Repository.ForcePrivate
|
||||
c.Data["mirror"] = c.Query("mirror") == "1"
|
||||
|
||||
ctxUser := checkContextUser(c, c.QueryInt64("org"))
|
||||
@@ -199,13 +199,13 @@ func MigratePost(c *context.Context, f form.MigrateRepo) {
|
||||
repo, err := db.MigrateRepository(c.User, ctxUser, db.MigrateRepoOptions{
|
||||
Name: f.RepoName,
|
||||
Description: f.Description,
|
||||
IsPrivate: f.Private || setting.Repository.ForcePrivate,
|
||||
IsPrivate: f.Private || conf.Repository.ForcePrivate,
|
||||
IsMirror: f.Mirror,
|
||||
RemoteAddr: remoteAddr,
|
||||
})
|
||||
if err == nil {
|
||||
log.Trace("Repository migrated [%d]: %s/%s", repo.ID, ctxUser.Name, f.RepoName)
|
||||
c.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + f.RepoName)
|
||||
c.Redirect(conf.Server.Subpath + "/" + ctxUser.Name + "/" + f.RepoName)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -14,12 +14,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/db/errors"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/mailer"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -196,7 +196,7 @@ func SettingsPost(c *context.Context, f form.RepoSetting) {
|
||||
}
|
||||
log.Trace("Repository converted from mirror to regular: %s/%s", c.Repo.Owner.Name, repo.Name)
|
||||
c.Flash.Success(c.Tr("repo.settings.convert_succeed"))
|
||||
c.Redirect(setting.AppSubURL + "/" + c.Repo.Owner.Name + "/" + repo.Name)
|
||||
c.Redirect(conf.Server.Subpath + "/" + c.Repo.Owner.Name + "/" + repo.Name)
|
||||
|
||||
case "transfer":
|
||||
if !c.Repo.IsOwner() {
|
||||
@@ -235,7 +235,7 @@ func SettingsPost(c *context.Context, f form.RepoSetting) {
|
||||
}
|
||||
log.Trace("Repository transfered: %s/%s -> %s", c.Repo.Owner.Name, repo.Name, newOwner)
|
||||
c.Flash.Success(c.Tr("repo.settings.transfer_succeed"))
|
||||
c.Redirect(setting.AppSubURL + "/" + newOwner + "/" + repo.Name)
|
||||
c.Redirect(conf.Server.Subpath + "/" + newOwner + "/" + repo.Name)
|
||||
|
||||
case "delete":
|
||||
if !c.Repo.IsOwner() {
|
||||
@@ -371,7 +371,7 @@ func SettingsCollaboration(c *context.Context) {
|
||||
func SettingsCollaborationPost(c *context.Context) {
|
||||
name := strings.ToLower(c.Query("collaborator"))
|
||||
if len(name) == 0 || c.Repo.Owner.LowerName == name {
|
||||
c.Redirect(setting.AppSubURL + c.Req.URL.Path)
|
||||
c.Redirect(conf.Server.Subpath + c.Req.URL.Path)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ func SettingsCollaborationPost(c *context.Context) {
|
||||
if err != nil {
|
||||
if errors.IsUserNotExist(err) {
|
||||
c.Flash.Error(c.Tr("form.user_not_exist"))
|
||||
c.Redirect(setting.AppSubURL + c.Req.URL.Path)
|
||||
c.Redirect(conf.Server.Subpath + c.Req.URL.Path)
|
||||
} else {
|
||||
c.Handle(500, "GetUserByName", err)
|
||||
}
|
||||
@@ -389,7 +389,7 @@ func SettingsCollaborationPost(c *context.Context) {
|
||||
// Organization is not allowed to be added as a collaborator
|
||||
if u.IsOrganization() {
|
||||
c.Flash.Error(c.Tr("repo.settings.org_not_allowed_to_be_collaborator"))
|
||||
c.Redirect(setting.AppSubURL + c.Req.URL.Path)
|
||||
c.Redirect(conf.Server.Subpath + c.Req.URL.Path)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -398,12 +398,12 @@ func SettingsCollaborationPost(c *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if setting.Service.EnableNotifyMail {
|
||||
if conf.Service.EnableNotifyMail {
|
||||
mailer.SendCollaboratorMail(db.NewMailerUser(u), db.NewMailerUser(c.User), db.NewMailerRepo(c.Repo.Repository))
|
||||
}
|
||||
|
||||
c.Flash.Success(c.Tr("repo.settings.add_collaborator_success"))
|
||||
c.Redirect(setting.AppSubURL + c.Req.URL.Path)
|
||||
c.Redirect(conf.Server.Subpath + c.Req.URL.Path)
|
||||
}
|
||||
|
||||
func ChangeCollaborationAccessMode(c *context.Context) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/markup"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/template"
|
||||
"gogs.io/gogs/internal/template/highlight"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
@@ -47,7 +47,7 @@ func renderDirectory(c *context.Context, treeLink string) {
|
||||
}
|
||||
entries.Sort()
|
||||
|
||||
c.Data["Files"], err = entries.GetCommitsInfoWithCustomConcurrency(c.Repo.Commit, c.Repo.TreePath, setting.Repository.CommitsFetchConcurrency)
|
||||
c.Data["Files"], err = entries.GetCommitsInfoWithCustomConcurrency(c.Repo.Commit, c.Repo.TreePath, conf.Repository.CommitsFetchConcurrency)
|
||||
if err != nil {
|
||||
c.ServerError("GetCommitsInfoWithCustomConcurrency", err)
|
||||
return
|
||||
@@ -118,7 +118,7 @@ func renderDirectory(c *context.Context, treeLink string) {
|
||||
|
||||
if c.Repo.CanEnableEditor() {
|
||||
c.Data["CanAddFile"] = true
|
||||
c.Data["CanUploadFile"] = setting.Repository.Upload.Enabled
|
||||
c.Data["CanUploadFile"] = conf.Repository.Upload.Enabled
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ func renderFile(c *context.Context, entry *git.TreeEntry, treeLink, rawLink stri
|
||||
canEnableEditor := c.Repo.CanEnableEditor()
|
||||
switch {
|
||||
case isTextFile:
|
||||
if blob.Size() >= setting.UI.MaxDisplayFileSize {
|
||||
if blob.Size() >= conf.UI.MaxDisplayFileSize {
|
||||
c.Data["IsFileTooLarge"] = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -32,7 +32,7 @@ func Webhooks(c *context.Context) {
|
||||
c.Data["PageIsSettingsHooks"] = true
|
||||
c.Data["BaseLink"] = c.Repo.RepoLink
|
||||
c.Data["Description"] = c.Tr("repo.settings.hooks_desc", "https://github.com/gogs/docs-api/blob/master/Repositories/Webhooks.md")
|
||||
c.Data["Types"] = setting.Webhook.Types
|
||||
c.Data["Types"] = conf.Webhook.Types
|
||||
|
||||
ws, err := db.GetWebhooksByRepoID(c.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
@@ -76,7 +76,7 @@ func getOrgRepoCtx(c *context.Context) (*OrgRepoCtx, error) {
|
||||
|
||||
func checkHookType(c *context.Context) string {
|
||||
hookType := strings.ToLower(c.Params(":type"))
|
||||
if !com.IsSliceContainsStr(setting.Webhook.Types, hookType) {
|
||||
if !com.IsSliceContainsStr(conf.Webhook.Types, hookType) {
|
||||
c.Handle(404, "checkHookType", nil)
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ import (
|
||||
"github.com/go-macaron/captcha"
|
||||
log "unknwon.dev/clog/v2"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/mailer"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ func AutoLogin(c *context.Context) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
uname := c.GetCookie(setting.CookieUserName)
|
||||
uname := c.GetCookie(conf.CookieUserName)
|
||||
if len(uname) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
@@ -45,9 +45,9 @@ func AutoLogin(c *context.Context) (bool, error) {
|
||||
defer func() {
|
||||
if !isSucceed {
|
||||
log.Trace("auto-login cookie cleared: %s", uname)
|
||||
c.SetCookie(setting.CookieUserName, "", -1, setting.AppSubURL)
|
||||
c.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubURL)
|
||||
c.SetCookie(setting.LoginStatusCookieName, "", -1, setting.AppSubURL)
|
||||
c.SetCookie(conf.CookieUserName, "", -1, conf.Server.Subpath)
|
||||
c.SetCookie(conf.CookieRememberName, "", -1, conf.Server.Subpath)
|
||||
c.SetCookie(conf.LoginStatusCookieName, "", -1, conf.Server.Subpath)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -59,16 +59,16 @@ func AutoLogin(c *context.Context) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if val, ok := c.GetSuperSecureCookie(u.Rands+u.Passwd, setting.CookieRememberName); !ok || val != u.Name {
|
||||
if val, ok := c.GetSuperSecureCookie(u.Rands+u.Passwd, conf.CookieRememberName); !ok || val != u.Name {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
isSucceed = true
|
||||
c.Session.Set("uid", u.ID)
|
||||
c.Session.Set("uname", u.Name)
|
||||
c.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubURL)
|
||||
if setting.EnableLoginStatusCookie {
|
||||
c.SetCookie(setting.LoginStatusCookieName, "true", 0, setting.AppSubURL)
|
||||
c.SetCookie(conf.CSRFCookieName, "", -1, conf.Server.Subpath)
|
||||
if conf.EnableLoginStatusCookie {
|
||||
c.SetCookie(conf.LoginStatusCookieName, "true", 0, conf.Server.Subpath)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func Login(c *context.Context) {
|
||||
|
||||
redirectTo := c.Query("redirect_to")
|
||||
if len(redirectTo) > 0 {
|
||||
c.SetCookie("redirect_to", redirectTo, 0, setting.AppSubURL)
|
||||
c.SetCookie("redirect_to", redirectTo, 0, conf.Server.Subpath)
|
||||
} else {
|
||||
redirectTo, _ = url.QueryUnescape(c.GetCookie("redirect_to"))
|
||||
}
|
||||
@@ -96,7 +96,7 @@ func Login(c *context.Context) {
|
||||
} else {
|
||||
c.SubURLRedirect("/")
|
||||
}
|
||||
c.SetCookie("redirect_to", "", -1, setting.AppSubURL)
|
||||
c.SetCookie("redirect_to", "", -1, conf.Server.Subpath)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -119,9 +119,9 @@ func Login(c *context.Context) {
|
||||
|
||||
func afterLogin(c *context.Context, u *db.User, remember bool) {
|
||||
if remember {
|
||||
days := 86400 * setting.LoginRememberDays
|
||||
c.SetCookie(setting.CookieUserName, u.Name, days, setting.AppSubURL, "", setting.CookieSecure, true)
|
||||
c.SetSuperSecureCookie(u.Rands+u.Passwd, setting.CookieRememberName, u.Name, days, setting.AppSubURL, "", setting.CookieSecure, true)
|
||||
days := 86400 * conf.LoginRememberDays
|
||||
c.SetCookie(conf.CookieUserName, u.Name, days, conf.Server.Subpath, "", conf.CookieSecure, true)
|
||||
c.SetSuperSecureCookie(u.Rands+u.Passwd, conf.CookieRememberName, u.Name, days, conf.Server.Subpath, "", conf.CookieSecure, true)
|
||||
}
|
||||
|
||||
c.Session.Set("uid", u.ID)
|
||||
@@ -130,13 +130,13 @@ func afterLogin(c *context.Context, u *db.User, remember bool) {
|
||||
c.Session.Delete("twoFactorUserID")
|
||||
|
||||
// Clear whatever CSRF has right now, force to generate a new one
|
||||
c.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubURL)
|
||||
if setting.EnableLoginStatusCookie {
|
||||
c.SetCookie(setting.LoginStatusCookieName, "true", 0, setting.AppSubURL)
|
||||
c.SetCookie(conf.CSRFCookieName, "", -1, conf.Server.Subpath)
|
||||
if conf.EnableLoginStatusCookie {
|
||||
c.SetCookie(conf.LoginStatusCookieName, "true", 0, conf.Server.Subpath)
|
||||
}
|
||||
|
||||
redirectTo, _ := url.QueryUnescape(c.GetCookie("redirect_to"))
|
||||
c.SetCookie("redirect_to", "", -1, setting.AppSubURL)
|
||||
c.SetCookie("redirect_to", "", -1, conf.Server.Subpath)
|
||||
if tool.IsSameSiteURLPath(redirectTo) {
|
||||
c.Redirect(redirectTo)
|
||||
return
|
||||
@@ -283,18 +283,18 @@ func LoginTwoFactorRecoveryCodePost(c *context.Context) {
|
||||
func SignOut(c *context.Context) {
|
||||
c.Session.Flush()
|
||||
c.Session.Destory(c.Context)
|
||||
c.SetCookie(setting.CookieUserName, "", -1, setting.AppSubURL)
|
||||
c.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubURL)
|
||||
c.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubURL)
|
||||
c.SetCookie(conf.CookieUserName, "", -1, conf.Server.Subpath)
|
||||
c.SetCookie(conf.CookieRememberName, "", -1, conf.Server.Subpath)
|
||||
c.SetCookie(conf.CSRFCookieName, "", -1, conf.Server.Subpath)
|
||||
c.SubURLRedirect("/")
|
||||
}
|
||||
|
||||
func SignUp(c *context.Context) {
|
||||
c.Title("sign_up")
|
||||
|
||||
c.Data["EnableCaptcha"] = setting.Service.EnableCaptcha
|
||||
c.Data["EnableCaptcha"] = conf.Service.EnableCaptcha
|
||||
|
||||
if setting.Service.DisableRegistration {
|
||||
if conf.Service.DisableRegistration {
|
||||
c.Data["DisableRegistration"] = true
|
||||
c.Success(SIGNUP)
|
||||
return
|
||||
@@ -306,9 +306,9 @@ func SignUp(c *context.Context) {
|
||||
func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
|
||||
c.Title("sign_up")
|
||||
|
||||
c.Data["EnableCaptcha"] = setting.Service.EnableCaptcha
|
||||
c.Data["EnableCaptcha"] = conf.Service.EnableCaptcha
|
||||
|
||||
if setting.Service.DisableRegistration {
|
||||
if conf.Service.DisableRegistration {
|
||||
c.Status(403)
|
||||
return
|
||||
}
|
||||
@@ -318,7 +318,7 @@ func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
|
||||
return
|
||||
}
|
||||
|
||||
if setting.Service.EnableCaptcha && !cpt.VerifyReq(c.Req) {
|
||||
if conf.Service.EnableCaptcha && !cpt.VerifyReq(c.Req) {
|
||||
c.FormErr("Captcha")
|
||||
c.RenderWithErr(c.Tr("form.captcha_incorrect"), SIGNUP, &f)
|
||||
return
|
||||
@@ -334,7 +334,7 @@ func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
|
||||
Name: f.UserName,
|
||||
Email: f.Email,
|
||||
Passwd: f.Password,
|
||||
IsActive: !setting.Service.RegisterEmailConfirm,
|
||||
IsActive: !conf.Service.RegisterEmailConfirm,
|
||||
}
|
||||
if err := db.CreateUser(u); err != nil {
|
||||
switch {
|
||||
@@ -368,11 +368,11 @@ func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
|
||||
}
|
||||
|
||||
// Send confirmation email, no need for social account.
|
||||
if setting.Service.RegisterEmailConfirm && u.ID > 1 {
|
||||
if conf.Service.RegisterEmailConfirm && u.ID > 1 {
|
||||
mailer.SendActivateAccountMail(c.Context, db.NewMailerUser(u))
|
||||
c.Data["IsSendRegisterMail"] = true
|
||||
c.Data["Email"] = u.Email
|
||||
c.Data["Hours"] = setting.Service.ActiveCodeLives / 60
|
||||
c.Data["Hours"] = conf.Service.ActiveCodeLives / 60
|
||||
c.Success(ACTIVATE)
|
||||
|
||||
if err := c.Cache.Put(u.MailResendCacheKey(), 1, 180); err != nil {
|
||||
@@ -393,11 +393,11 @@ func Activate(c *context.Context) {
|
||||
return
|
||||
}
|
||||
// Resend confirmation email.
|
||||
if setting.Service.RegisterEmailConfirm {
|
||||
if conf.Service.RegisterEmailConfirm {
|
||||
if c.Cache.IsExist(c.User.MailResendCacheKey()) {
|
||||
c.Data["ResendLimited"] = true
|
||||
} else {
|
||||
c.Data["Hours"] = setting.Service.ActiveCodeLives / 60
|
||||
c.Data["Hours"] = conf.Service.ActiveCodeLives / 60
|
||||
mailer.SendActivateAccountMail(c.Context, db.NewMailerUser(c.User))
|
||||
|
||||
if err := c.Cache.Put(c.User.MailResendCacheKey(), 1, 180); err != nil {
|
||||
@@ -457,7 +457,7 @@ func ActivateEmail(c *context.Context) {
|
||||
func ForgotPasswd(c *context.Context) {
|
||||
c.Title("auth.forgot_password")
|
||||
|
||||
if setting.MailService == nil {
|
||||
if conf.MailService == nil {
|
||||
c.Data["IsResetDisable"] = true
|
||||
c.Success(FORGOT_PASSWORD)
|
||||
return
|
||||
@@ -470,7 +470,7 @@ func ForgotPasswd(c *context.Context) {
|
||||
func ForgotPasswdPost(c *context.Context) {
|
||||
c.Title("auth.forgot_password")
|
||||
|
||||
if setting.MailService == nil {
|
||||
if conf.MailService == nil {
|
||||
c.Status(403)
|
||||
return
|
||||
}
|
||||
@@ -482,7 +482,7 @@ func ForgotPasswdPost(c *context.Context) {
|
||||
u, err := db.GetUserByEmail(email)
|
||||
if err != nil {
|
||||
if errors.IsUserNotExist(err) {
|
||||
c.Data["Hours"] = setting.Service.ActiveCodeLives / 60
|
||||
c.Data["Hours"] = conf.Service.ActiveCodeLives / 60
|
||||
c.Data["IsResetSent"] = true
|
||||
c.Success(FORGOT_PASSWORD)
|
||||
return
|
||||
@@ -509,7 +509,7 @@ func ForgotPasswdPost(c *context.Context) {
|
||||
log.Error("Failed to put cache key 'mail resend': %v", err)
|
||||
}
|
||||
|
||||
c.Data["Hours"] = setting.Service.ActiveCodeLives / 60
|
||||
c.Data["Hours"] = conf.Service.ActiveCodeLives / 60
|
||||
c.Data["IsResetSent"] = true
|
||||
c.Success(FORGOT_PASSWORD)
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ import (
|
||||
"github.com/unknwon/com"
|
||||
"github.com/unknwon/paginater"
|
||||
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/db/errors"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -110,7 +110,7 @@ func Dashboard(c *context.Context) {
|
||||
|
||||
// Only user can have collaborative repositories.
|
||||
if !ctxUser.IsOrganization() {
|
||||
collaborateRepos, err := c.User.GetAccessibleRepositories(setting.UI.User.RepoPagingNum)
|
||||
collaborateRepos, err := c.User.GetAccessibleRepositories(conf.UI.User.RepoPagingNum)
|
||||
if err != nil {
|
||||
c.Handle(500, "GetAccessibleRepositories", err)
|
||||
return
|
||||
@@ -125,7 +125,7 @@ func Dashboard(c *context.Context) {
|
||||
var repos, mirrors []*db.Repository
|
||||
var repoCount int64
|
||||
if ctxUser.IsOrganization() {
|
||||
repos, repoCount, err = ctxUser.GetUserRepositories(c.User.ID, 1, setting.UI.User.RepoPagingNum)
|
||||
repos, repoCount, err = ctxUser.GetUserRepositories(c.User.ID, 1, conf.UI.User.RepoPagingNum)
|
||||
if err != nil {
|
||||
c.Handle(500, "GetUserRepositories", err)
|
||||
return
|
||||
@@ -137,7 +137,7 @@ func Dashboard(c *context.Context) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if err = ctxUser.GetRepositories(1, setting.UI.User.RepoPagingNum); err != nil {
|
||||
if err = ctxUser.GetRepositories(1, conf.UI.User.RepoPagingNum); err != nil {
|
||||
c.Handle(500, "GetRepositories", err)
|
||||
return
|
||||
}
|
||||
@@ -152,7 +152,7 @@ func Dashboard(c *context.Context) {
|
||||
}
|
||||
c.Data["Repos"] = repos
|
||||
c.Data["RepoCount"] = repoCount
|
||||
c.Data["MaxShowRepoNum"] = setting.UI.User.RepoPagingNum
|
||||
c.Data["MaxShowRepoNum"] = conf.UI.User.RepoPagingNum
|
||||
|
||||
if err := db.MirrorRepositoryList(mirrors).LoadAttributes(); err != nil {
|
||||
c.Handle(500, "MirrorRepositoryList.LoadAttributes", err)
|
||||
@@ -328,7 +328,7 @@ func Issues(c *context.Context) {
|
||||
|
||||
c.Data["Issues"] = issues
|
||||
c.Data["Repos"] = showRepos
|
||||
c.Data["Page"] = paginater.New(total, setting.UI.IssuePagingNum, page, 5)
|
||||
c.Data["Page"] = paginater.New(total, conf.UI.IssuePagingNum, page, 5)
|
||||
c.Data["IssueStats"] = issueStats
|
||||
c.Data["ViewType"] = string(filterMode)
|
||||
c.Data["SortType"] = sortType
|
||||
@@ -380,7 +380,7 @@ func showOrgProfile(c *context.Context) {
|
||||
err error
|
||||
)
|
||||
if c.IsLogged && !c.User.IsAdmin {
|
||||
repos, count, err = org.GetUserRepositories(c.User.ID, page, setting.UI.User.RepoPagingNum)
|
||||
repos, count, err = org.GetUserRepositories(c.User.ID, page, conf.UI.User.RepoPagingNum)
|
||||
if err != nil {
|
||||
c.Handle(500, "GetUserRepositories", err)
|
||||
return
|
||||
@@ -392,7 +392,7 @@ func showOrgProfile(c *context.Context) {
|
||||
UserID: org.ID,
|
||||
Private: showPrivate,
|
||||
Page: page,
|
||||
PageSize: setting.UI.User.RepoPagingNum,
|
||||
PageSize: conf.UI.User.RepoPagingNum,
|
||||
})
|
||||
if err != nil {
|
||||
c.Handle(500, "GetRepositories", err)
|
||||
@@ -401,7 +401,7 @@ func showOrgProfile(c *context.Context) {
|
||||
c.Data["Repos"] = repos
|
||||
count = db.CountUserRepositories(org.ID, showPrivate)
|
||||
}
|
||||
c.Data["Page"] = paginater.New(int(count), setting.UI.User.RepoPagingNum, page, 5)
|
||||
c.Data["Page"] = paginater.New(int(count), conf.UI.User.RepoPagingNum, page, 5)
|
||||
|
||||
if err := org.GetMembers(); err != nil {
|
||||
c.Handle(500, "GetMembers", err)
|
||||
@@ -420,5 +420,5 @@ func Email2User(c *context.Context) {
|
||||
c.NotFoundOrServerError("GetUserByEmail", errors.IsUserNotExist, err)
|
||||
return
|
||||
}
|
||||
c.Redirect(setting.AppSubURL + "/user/" + u.Name)
|
||||
c.Redirect(conf.Server.Subpath + "/user/" + u.Name)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
"gogs.io/gogs/internal/context"
|
||||
"gogs.io/gogs/internal/db"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -70,7 +70,7 @@ func Profile(c *context.Context, puser *context.ParamsUser) {
|
||||
UserID: puser.ID,
|
||||
Private: showPrivate,
|
||||
Page: page,
|
||||
PageSize: setting.UI.User.RepoPagingNum,
|
||||
PageSize: conf.UI.User.RepoPagingNum,
|
||||
})
|
||||
if err != nil {
|
||||
c.ServerError("GetRepositories", err)
|
||||
@@ -78,7 +78,7 @@ func Profile(c *context.Context, puser *context.ParamsUser) {
|
||||
}
|
||||
|
||||
count := db.CountUserRepositories(puser.ID, showPrivate)
|
||||
c.Data["Page"] = paginater.New(int(count), setting.UI.User.RepoPagingNum, page, 5)
|
||||
c.Data["Page"] = paginater.New(int(count), conf.UI.User.RepoPagingNum, page, 5)
|
||||
}
|
||||
|
||||
c.Success(PROFILE)
|
||||
|
||||
@@ -18,12 +18,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/db/errors"
|
||||
"gogs.io/gogs/internal/form"
|
||||
"gogs.io/gogs/internal/mailer"
|
||||
"gogs.io/gogs/internal/setting"
|
||||
"gogs.io/gogs/internal/tool"
|
||||
)
|
||||
|
||||
@@ -262,7 +262,7 @@ func SettingsEmailPost(c *context.Context, f form.AddEmail) {
|
||||
email := &db.EmailAddress{
|
||||
UID: c.User.ID,
|
||||
Email: f.Email,
|
||||
IsActivated: !setting.Service.RegisterEmailConfirm,
|
||||
IsActivated: !conf.Service.RegisterEmailConfirm,
|
||||
}
|
||||
if err := db.AddEmailAddress(email); err != nil {
|
||||
if db.IsErrEmailAlreadyUsed(err) {
|
||||
@@ -274,13 +274,13 @@ func SettingsEmailPost(c *context.Context, f form.AddEmail) {
|
||||
}
|
||||
|
||||
// Send confirmation email
|
||||
if setting.Service.RegisterEmailConfirm {
|
||||
if conf.Service.RegisterEmailConfirm {
|
||||
mailer.SendActivateEmailMail(c.Context, db.NewMailerUser(c.User), email.Email)
|
||||
|
||||
if err := c.Cache.Put("MailResendLimit_"+c.User.LowerName, c.User.LowerName, 180); err != nil {
|
||||
log.Error("Set cache 'MailResendLimit' failed: %v", err)
|
||||
}
|
||||
c.Flash.Info(c.Tr("settings.add_email_confirmation_sent", email.Email, setting.Service.ActiveCodeLives/60))
|
||||
c.Flash.Info(c.Tr("settings.add_email_confirmation_sent", email.Email, conf.Service.ActiveCodeLives/60))
|
||||
} else {
|
||||
c.Flash.Success(c.Tr("settings.add_email_success"))
|
||||
}
|
||||
@@ -299,7 +299,7 @@ func DeleteEmail(c *context.Context) {
|
||||
|
||||
c.Flash.Success(c.Tr("settings.email_deletion_success"))
|
||||
c.JSONSuccess(map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/user/settings/email",
|
||||
"redirect": conf.Server.Subpath + "/user/settings/email",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ func DeleteSSHKey(c *context.Context) {
|
||||
}
|
||||
|
||||
c.JSONSuccess(map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/user/settings/ssh",
|
||||
"redirect": conf.Server.Subpath + "/user/settings/ssh",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ func SettingsTwoFactorEnable(c *context.Context) {
|
||||
}
|
||||
if key == nil {
|
||||
key, err = totp.Generate(totp.GenerateOpts{
|
||||
Issuer: setting.AppName,
|
||||
Issuer: conf.App.BrandName,
|
||||
AccountName: c.User.Email,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -506,7 +506,7 @@ func SettingsTwoFactorDisable(c *context.Context) {
|
||||
|
||||
c.Flash.Success(c.Tr("settings.two_factor_disable_success"))
|
||||
c.JSONSuccess(map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/user/settings/security",
|
||||
"redirect": conf.Server.Subpath + "/user/settings/security",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ func SettingsLeaveRepo(c *context.Context) {
|
||||
|
||||
c.Flash.Success(c.Tr("settings.repos.leave_success", repo.FullName()))
|
||||
c.JSONSuccess(map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/user/settings/repositories",
|
||||
"redirect": conf.Server.Subpath + "/user/settings/repositories",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@ func SettingsLeaveOrganization(c *context.Context) {
|
||||
}
|
||||
|
||||
c.JSONSuccess(map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/user/settings/organizations",
|
||||
"redirect": conf.Server.Subpath + "/user/settings/organizations",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -632,7 +632,7 @@ func SettingsDeleteApplication(c *context.Context) {
|
||||
}
|
||||
|
||||
c.JSONSuccess(map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/user/settings/applications",
|
||||
"redirect": conf.Server.Subpath + "/user/settings/applications",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -654,16 +654,16 @@ func SettingsDelete(c *context.Context) {
|
||||
switch {
|
||||
case db.IsErrUserOwnRepos(err):
|
||||
c.Flash.Error(c.Tr("form.still_own_repo"))
|
||||
c.Redirect(setting.AppSubURL + "/user/settings/delete")
|
||||
c.Redirect(conf.Server.Subpath + "/user/settings/delete")
|
||||
case db.IsErrUserHasOrgs(err):
|
||||
c.Flash.Error(c.Tr("form.still_has_org"))
|
||||
c.Redirect(setting.AppSubURL + "/user/settings/delete")
|
||||
c.Redirect(conf.Server.Subpath + "/user/settings/delete")
|
||||
default:
|
||||
c.ServerError("DeleteUser", err)
|
||||
}
|
||||
} else {
|
||||
log.Trace("Account deleted: %s", c.User.Name)
|
||||
c.Redirect(setting.AppSubURL + "/")
|
||||
c.Redirect(conf.Server.Subpath + "/")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user