summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/admin/admin.go43
-rw-r--r--routers/api/v1/miscellaneous.go3
-rw-r--r--routers/dashboard.go4
-rw-r--r--routers/dev/template.go14
-rw-r--r--routers/install.go68
-rw-r--r--routers/repo/branch.go7
-rw-r--r--routers/repo/commit.go24
-rw-r--r--routers/repo/download.go21
-rw-r--r--routers/repo/git.go55
-rw-r--r--routers/repo/http.go27
-rw-r--r--routers/repo/issue.go5
-rw-r--r--routers/repo/setting.go3
-rw-r--r--routers/user/social.go6
-rw-r--r--routers/user/user.go47
14 files changed, 129 insertions, 198 deletions
diff --git a/routers/admin/admin.go b/routers/admin/admin.go
index f9c11f8378..a273847a28 100644
--- a/routers/admin/admin.go
+++ b/routers/admin/admin.go
@@ -15,6 +15,7 @@ import (
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/middleware"
+ "github.com/gogits/gogs/modules/setting"
)
var startTime = time.Now()
@@ -177,46 +178,46 @@ func Config(ctx *middleware.Context) {
ctx.Data["Title"] = "Server Configuration"
ctx.Data["PageIsConfig"] = true
- ctx.Data["AppUrl"] = base.AppUrl
- ctx.Data["Domain"] = base.Domain
- ctx.Data["OfflineMode"] = base.OfflineMode
- ctx.Data["DisableRouterLog"] = base.DisableRouterLog
- ctx.Data["RunUser"] = base.RunUser
+ ctx.Data["AppUrl"] = setting.AppUrl
+ ctx.Data["Domain"] = setting.Domain
+ ctx.Data["OfflineMode"] = setting.OfflineMode
+ ctx.Data["DisableRouterLog"] = setting.DisableRouterLog
+ ctx.Data["RunUser"] = setting.RunUser
ctx.Data["RunMode"] = strings.Title(martini.Env)
- ctx.Data["RepoRootPath"] = base.RepoRootPath
- ctx.Data["ScriptType"] = base.ScriptType
+ ctx.Data["RepoRootPath"] = setting.RepoRootPath
+ ctx.Data["ScriptType"] = setting.ScriptType
- ctx.Data["Service"] = base.Service
+ ctx.Data["Service"] = setting.Service
ctx.Data["DbCfg"] = models.DbCfg
ctx.Data["MailerEnabled"] = false
- if base.MailService != nil {
+ if setting.MailService != nil {
ctx.Data["MailerEnabled"] = true
- ctx.Data["Mailer"] = base.MailService
+ ctx.Data["Mailer"] = setting.MailService
}
ctx.Data["OauthEnabled"] = false
- if base.OauthService != nil {
+ if setting.OauthService != nil {
ctx.Data["OauthEnabled"] = true
- ctx.Data["Oauther"] = base.OauthService
+ ctx.Data["Oauther"] = setting.OauthService
}
- ctx.Data["CacheAdapter"] = base.CacheAdapter
- ctx.Data["CacheConfig"] = base.CacheConfig
+ ctx.Data["CacheAdapter"] = setting.CacheAdapter
+ ctx.Data["CacheConfig"] = setting.CacheConfig
- ctx.Data["SessionProvider"] = base.SessionProvider
- ctx.Data["SessionConfig"] = base.SessionConfig
+ ctx.Data["SessionProvider"] = setting.SessionProvider
+ ctx.Data["SessionConfig"] = setting.SessionConfig
- ctx.Data["PictureService"] = base.PictureService
- ctx.Data["DisableGravatar"] = base.DisableGravatar
+ ctx.Data["PictureService"] = setting.PictureService
+ ctx.Data["DisableGravatar"] = setting.DisableGravatar
type logger struct {
Mode, Config string
}
- loggers := make([]*logger, len(base.LogModes))
- for i := range base.LogModes {
- loggers[i] = &logger{base.LogModes[i], base.LogConfigs[i]}
+ loggers := make([]*logger, len(setting.LogModes))
+ for i := range setting.LogModes {
+ loggers[i] = &logger{setting.LogModes[i], setting.LogConfigs[i]}
}
ctx.Data["Loggers"] = loggers
diff --git a/routers/api/v1/miscellaneous.go b/routers/api/v1/miscellaneous.go
index 30751efcca..088bcd9c94 100644
--- a/routers/api/v1/miscellaneous.go
+++ b/routers/api/v1/miscellaneous.go
@@ -11,6 +11,7 @@ import (
"github.com/gogits/gogs/modules/auth/apiv1"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/middleware"
+ "github.com/gogits/gogs/modules/setting"
)
const DOC_URL = "http://gogs.io/docs"
@@ -25,7 +26,7 @@ func Markdown(ctx *middleware.Context, form apiv1.MarkdownForm) {
switch form.Mode {
case "gfm":
ctx.Write(base.RenderMarkdown([]byte(form.Text),
- base.AppUrl+strings.TrimPrefix(form.Context, "/")))
+ setting.AppUrl+strings.TrimPrefix(form.Context, "/")))
default:
ctx.Write(base.RenderRawMarkdown([]byte(form.Text), ""))
}
diff --git a/routers/dashboard.go b/routers/dashboard.go
index 94324b1579..438d03794b 100644
--- a/routers/dashboard.go
+++ b/routers/dashboard.go
@@ -6,8 +6,8 @@ package routers
import (
"github.com/gogits/gogs/models"
- "github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/middleware"
+ "github.com/gogits/gogs/modules/setting"
"github.com/gogits/gogs/routers/user"
)
@@ -18,7 +18,7 @@ func Home(ctx *middleware.Context) {
}
// Check auto-login.
- userName := ctx.GetCookie(base.CookieUserName)
+ userName := ctx.GetCookie(setting.CookieUserName)
if len(userName) != 0 {
ctx.Redirect("/user/login")
return
diff --git a/routers/dev/template.go b/routers/dev/template.go
index 7145bf51fa..5e84d76edb 100644
--- a/routers/dev/template.go
+++ b/routers/dev/template.go
@@ -8,19 +8,19 @@ import (
"github.com/go-martini/martini"
"github.com/gogits/gogs/models"
- "github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/middleware"
+ "github.com/gogits/gogs/modules/setting"
)
func TemplatePreview(ctx *middleware.Context, params martini.Params) {
ctx.Data["User"] = models.User{Name: "Unknown"}
- ctx.Data["AppName"] = base.AppName
- ctx.Data["AppVer"] = base.AppVer
- ctx.Data["AppUrl"] = base.AppUrl
- ctx.Data["AppLogo"] = base.AppLogo
+ ctx.Data["AppName"] = setting.AppName
+ ctx.Data["AppVer"] = setting.AppVer
+ ctx.Data["AppUrl"] = setting.AppUrl
+ ctx.Data["AppLogo"] = setting.AppLogo
ctx.Data["Code"] = "2014031910370000009fff6782aadb2162b4a997acb69d4400888e0b9274657374"
- ctx.Data["ActiveCodeLives"] = base.Service.ActiveCodeLives / 60
- ctx.Data["ResetPwdCodeLives"] = base.Service.ResetPwdCodeLives / 60
+ ctx.Data["ActiveCodeLives"] = setting.Service.ActiveCodeLives / 60
+ ctx.Data["ResetPwdCodeLives"] = setting.Service.ResetPwdCodeLives / 60
ctx.Data["CurDbValue"] = ""
ctx.HTML(200, params["_1"])
}
diff --git a/routers/install.go b/routers/install.go
index da00b90e37..f02c41f87e 100644
--- a/routers/install.go
+++ b/routers/install.go
@@ -8,6 +8,7 @@ import (
"errors"
"os"
"os/exec"
+ "path"
"strings"
"github.com/Unknwon/goconfig"
@@ -22,14 +23,15 @@ import (
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/mailer"
"github.com/gogits/gogs/modules/middleware"
+ "github.com/gogits/gogs/modules/setting"
"github.com/gogits/gogs/modules/social"
)
func checkRunMode() {
- switch base.Cfg.MustValue("", "RUN_MODE") {
+ switch setting.Cfg.MustValue("", "RUN_MODE") {
case "prod":
martini.Env = martini.Prod
- base.ProdMode = true
+ setting.ProdMode = true
case "test":
martini.Env = martini.Test
}
@@ -37,20 +39,20 @@ func checkRunMode() {
}
func NewServices() {
- base.NewBaseServices()
+ setting.NewServices()
social.NewOauthService()
}
// GlobalInit is for global configuration reload-able.
func GlobalInit() {
- base.NewConfigContext()
+ setting.NewConfigContext()
mailer.NewMailerContext()
models.LoadModelsConfig()
models.LoadRepoConfig()
models.NewRepoContext()
NewServices()
- if base.InstallLock {
+ if setting.InstallLock {
if err := models.NewEngine(); err != nil {
qlog.Fatal(err)
}
@@ -69,7 +71,7 @@ func renderDbOption(ctx *middleware.Context) {
}
func Install(ctx *middleware.Context, form auth.InstallForm) {
- if base.InstallLock {
+ if setting.InstallLock {
ctx.Handle(404, "install.Install", errors.New("Installation is prohibited"))
return
}
@@ -95,16 +97,16 @@ func Install(ctx *middleware.Context, form auth.InstallForm) {
}
if len(form.RepoRootPath) == 0 {
- form.RepoRootPath = base.RepoRootPath
+ form.RepoRootPath = setting.RepoRootPath
}
if len(form.RunUser) == 0 {
- form.RunUser = base.RunUser
+ form.RunUser = setting.RunUser
}
if len(form.Domain) == 0 {
- form.Domain = base.Domain
+ form.Domain = setting.Domain
}
if len(form.AppUrl) == 0 {
- form.AppUrl = base.AppUrl
+ form.AppUrl = setting.AppUrl
}
renderDbOption(ctx)
@@ -119,7 +121,7 @@ func Install(ctx *middleware.Context, form auth.InstallForm) {
}
func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
- if base.InstallLock {
+ if setting.InstallLock {
ctx.Handle(404, "install.Install", errors.New("Installation is prohibited"))
return
}
@@ -181,35 +183,35 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
}
// Save settings.
- base.Cfg.SetValue("database", "DB_TYPE", models.DbCfg.Type)
- base.Cfg.SetValue("database", "HOST", models.DbCfg.Host)
- base.Cfg.SetValue("database", "NAME", models.DbCfg.Name)
- base.Cfg.SetValue("database", "USER", models.DbCfg.User)
- base.Cfg.SetValue("database", "PASSWD", models.DbCfg.Pwd)
- base.Cfg.SetValue("database", "SSL_MODE", models.DbCfg.SslMode)
- base.Cfg.SetValue("database", "PATH", models.DbCfg.Path)
-
- base.Cfg.SetValue("repository", "ROOT", form.RepoRootPath)
- base.Cfg.SetValue("", "RUN_USER", form.RunUser)
- base.Cfg.SetValue("server", "DOMAIN", form.Domain)
- base.Cfg.SetValue("server", "ROOT_URL", form.AppUrl)
+ setting.Cfg.SetValue("database", "DB_TYPE", models.DbCfg.Type)
+ setting.Cfg.SetValue("database", "HOST", models.DbCfg.Host)
+ setting.Cfg.SetValue("database", "NAME", models.DbCfg.Name)
+ setting.Cfg.SetValue("database", "USER", models.DbCfg.User)
+ setting.Cfg.SetValue("database", "PASSWD", models.DbCfg.Pwd)
+ setting.Cfg.SetValue("database", "SSL_MODE", models.DbCfg.SslMode)
+ setting.Cfg.SetValue("database", "PATH", models.DbCfg.Path)
+
+ setting.Cfg.SetValue("repository", "ROOT", form.RepoRootPath)
+ setting.Cfg.SetValue("", "RUN_USER", form.RunUser)
+ setting.Cfg.SetValue("server", "DOMAIN", form.Domain)
+ setting.Cfg.SetValue("server", "ROOT_URL", form.AppUrl)
if len(strings.TrimSpace(form.SmtpHost)) > 0 {
- base.Cfg.SetValue("mailer", "ENABLED", "true")
- base.Cfg.SetValue("mailer", "HOST", form.SmtpHost)
- base.Cfg.SetValue("mailer", "USER", form.SmtpEmail)
- base.Cfg.SetValue("mailer", "PASSWD", form.SmtpPasswd)
+ setting.Cfg.SetValue("mailer", "ENABLED", "true")
+ setting.Cfg.SetValue("mailer", "HOST", form.SmtpHost)
+ setting.Cfg.SetValue("mailer", "USER", form.SmtpEmail)
+ setting.Cfg.SetValue("mailer", "PASSWD", form.SmtpPasswd)
- base.Cfg.SetValue("service", "REGISTER_EMAIL_CONFIRM", base.ToStr(form.RegisterConfirm == "on"))
- base.Cfg.SetValue("service", "ENABLE_NOTIFY_MAIL", base.ToStr(form.MailNotify == "on"))
+ setting.Cfg.SetValue("service", "REGISTER_EMAIL_CONFIRM", base.ToStr(form.RegisterConfirm == "on"))
+ setting.Cfg.SetValue("service", "ENABLE_NOTIFY_MAIL", base.ToStr(form.MailNotify == "on"))
}
- base.Cfg.SetValue("", "RUN_MODE", "prod")
+ setting.Cfg.SetValue("", "RUN_MODE", "prod")
- base.Cfg.SetValue("security", "INSTALL_LOCK", "true")
+ setting.Cfg.SetValue("security", "INSTALL_LOCK", "true")
os.MkdirAll("custom/conf", os.ModePerm)
- if err := goconfig.SaveConfigFile(base.Cfg, "custom/conf/app.ini"); err != nil {
+ if err := goconfig.SaveConfigFile(setting.Cfg, path.Join(setting.CustomPath, "conf/app.ini")); err != nil {
ctx.RenderWithErr("Fail to save configuration: "+err.Error(), "install", &form)
return
}
@@ -220,7 +222,7 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
if _, err := models.RegisterUser(&models.User{Name: form.AdminName, Email: form.AdminEmail, Passwd: form.AdminPasswd,
IsAdmin: true, IsActive: true}); err != nil {
if err != models.ErrUserAlreadyExist {
- base.InstallLock = false
+ setting.InstallLock = false
ctx.RenderWithErr("Admin account setting is invalid: "+err.Error(), "install", &form)
return
}
diff --git a/routers/repo/branch.go b/routers/repo/branch.go
index 92265d2e56..2e2ae69254 100644
--- a/routers/repo/branch.go
+++ b/routers/repo/branch.go
@@ -11,9 +11,12 @@ import (
)
func Branches(ctx *middleware.Context, params martini.Params) {
+ ctx.Data["Title"] = "Branches"
+ ctx.Data["IsRepoToolbarBranches"] = true
+
brs, err := ctx.Repo.GitRepo.GetBranches()
if err != nil {
- ctx.Handle(404, "repo.Branches", err)
+ ctx.Handle(500, "repo.Branches", err)
return
} else if len(brs) == 0 {
ctx.Handle(404, "repo.Branches", nil)
@@ -21,7 +24,5 @@ func Branches(ctx *middleware.Context, params martini.Params) {
}
ctx.Data["Branches"] = brs
- ctx.Data["IsRepoToolbarBranches"] = true
-
ctx.HTML(200, "repo/branches")
}
diff --git a/routers/repo/commit.go b/routers/repo/commit.go
index 88b6593e76..44427b8a42 100644
--- a/routers/repo/commit.go
+++ b/routers/repo/commit.go
@@ -15,6 +15,8 @@ import (
)
func Commits(ctx *middleware.Context, params martini.Params) {
+ ctx.Data["IsRepoToolbarCommits"] = true
+
userName := ctx.Repo.Owner.Name
repoName := ctx.Repo.Repository.Name
@@ -47,8 +49,8 @@ func Commits(ctx *middleware.Context, params martini.Params) {
nextPage = 0
}
- //both `git log branchName` and `git log commitId` work
- commits, err := ctx.Repo.Commit.CommitsByRange(page)
+ // Both `git log branchName` and `git log commitId` work.
+ ctx.Data["Commits"], err = ctx.Repo.Commit.CommitsByRange(page)
if err != nil {
ctx.Handle(500, "repo.Commits(CommitsByRange)", err)
return
@@ -57,14 +59,14 @@ func Commits(ctx *middleware.Context, params martini.Params) {
ctx.Data["Username"] = userName
ctx.Data["Reponame"] = repoName
ctx.Data["CommitCount"] = commitsCount
- ctx.Data["Commits"] = commits
ctx.Data["LastPageNum"] = lastPage
ctx.Data["NextPageNum"] = nextPage
- ctx.Data["IsRepoToolbarCommits"] = true
ctx.HTML(200, "repo/commits")
}
func Diff(ctx *middleware.Context, params martini.Params) {
+ ctx.Data["IsRepoToolbarCommits"] = true
+
userName := ctx.Repo.Owner.Name
repoName := ctx.Repo.Repository.Name
commitId := ctx.Repo.CommitId
@@ -109,13 +111,15 @@ func Diff(ctx *middleware.Context, params martini.Params) {
ctx.Data["Diff"] = diff
ctx.Data["Parents"] = parents
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
- ctx.Data["IsRepoToolbarCommits"] = true
ctx.Data["SourcePath"] = "/" + path.Join(userName, repoName, "src", commitId)
ctx.Data["RawPath"] = "/" + path.Join(userName, repoName, "raw", commitId)
ctx.HTML(200, "repo/diff")
}
func SearchCommits(ctx *middleware.Context, params martini.Params) {
+ ctx.Data["IsSearchPage"] = true
+ ctx.Data["IsRepoToolbarCommits"] = true
+
keyword := ctx.Query("q")
if len(keyword) == 0 {
ctx.Redirect(ctx.Repo.RepoLink + "/commits/" + ctx.Repo.BranchName)
@@ -145,12 +149,12 @@ func SearchCommits(ctx *middleware.Context, params martini.Params) {
ctx.Data["Reponame"] = repoName
ctx.Data["CommitCount"] = commits.Len()
ctx.Data["Commits"] = commits
- ctx.Data["IsSearchPage"] = true
- ctx.Data["IsRepoToolbarCommits"] = true
ctx.HTML(200, "repo/commits")
}
func FileHistory(ctx *middleware.Context, params martini.Params) {
+ ctx.Data["IsRepoToolbarCommits"] = true
+
fileName := params["_1"]
if len(fileName) == 0 {
Commits(ctx, params)
@@ -194,8 +198,8 @@ func FileHistory(ctx *middleware.Context, params martini.Params) {
nextPage = 0
}
- //both `git log branchName` and `git log commitId` work
- commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(branchName, fileName, page)
+ ctx.Data["Commits"], err = ctx.Repo.GitRepo.CommitsByFileAndRange(
+ branchName, fileName, page)
if err != nil {
ctx.Handle(500, "repo.FileHistory(CommitsByRange)", err)
return
@@ -205,9 +209,7 @@ func FileHistory(ctx *middleware.Context, params martini.Params) {
ctx.Data["Reponame"] = repoName
ctx.Data["FileName"] = fileName
ctx.Data["CommitCount"] = commitsCount
- ctx.Data["Commits"] = commits
ctx.Data["LastPageNum"] = lastPage
ctx.Data["NextPageNum"] = nextPage
- ctx.Data["IsRepoToolbarCommits"] = true
ctx.HTML(200, "repo/commits")
}
diff --git a/routers/repo/download.go b/routers/repo/download.go
index e5ec1c79f1..5df78dc7d8 100644
--- a/routers/repo/download.go
+++ b/routers/repo/download.go
@@ -18,18 +18,17 @@ import (
)
func SingleDownload(ctx *middleware.Context, params martini.Params) {
- // Get tree path
treename := params["_1"]
blob, err := ctx.Repo.Commit.GetBlobByPath(treename)
if err != nil {
- ctx.Handle(404, "repo.SingleDownload(GetBlobByPath)", err)
+ ctx.Handle(500, "repo.SingleDownload(GetBlobByPath)", err)
return
}
data, err := blob.Data()
if err != nil {
- ctx.Handle(404, "repo.SingleDownload(Data)", err)
+ ctx.Handle(500, "repo.SingleDownload(Data)", err)
return
}
@@ -47,8 +46,8 @@ func ZipDownload(ctx *middleware.Context, params martini.Params) {
commitId := ctx.Repo.CommitId
archivesPath := filepath.Join(ctx.Repo.GitRepo.Path, "archives/zip")
if !com.IsDir(archivesPath) {
- if err := os.MkdirAll(archivesPath, 0755); err != nil {
- ctx.Handle(404, "ZipDownload -> os.Mkdir(archivesPath)", err)
+ if err := os.MkdirAll(archivesPath, 0655); err != nil {
+ ctx.Handle(500, "ZipDownload -> os.Mkdir(archivesPath)", err)
return
}
}
@@ -60,9 +59,8 @@ func ZipDownload(ctx *middleware.Context, params martini.Params) {
return
}
- err := ctx.Repo.Commit.CreateArchive(archivePath, git.AT_ZIP)
- if err != nil {
- ctx.Handle(404, "ZipDownload -> CreateArchive "+archivePath, err)
+ if err := ctx.Repo.Commit.CreateArchive(archivePath, git.AT_ZIP); err != nil {
+ ctx.Handle(500, "ZipDownload -> CreateArchive "+archivePath, err)
return
}
@@ -74,7 +72,7 @@ func TarGzDownload(ctx *middleware.Context, params martini.Params) {
archivesPath := filepath.Join(ctx.Repo.GitRepo.Path, "archives/targz")
if !com.IsDir(archivesPath) {
if err := os.MkdirAll(archivesPath, 0755); err != nil {
- ctx.Handle(404, "TarGzDownload -> os.Mkdir(archivesPath)", err)
+ ctx.Handle(500, "TarGzDownload -> os.Mkdir(archivesPath)", err)
return
}
}
@@ -86,9 +84,8 @@ func TarGzDownload(ctx *middleware.Context, params martini.Params) {
return
}
- err := ctx.Repo.Commit.CreateArchive(archivePath, git.AT_TARGZ)
- if err != nil {
- ctx.Handle(404, "TarGzDownload -> CreateArchive "+archivePath, err)
+ if err := ctx.Repo.Commit.CreateArchive(archivePath, git.AT_TARGZ); err != nil {
+ ctx.Handle(500, "TarGzDownload -> CreateArchive "+archivePath, err)
return
}
diff --git a/routers/repo/git.go b/routers/repo/git.go
deleted file mode 100644
index 30c1042e0a..0000000000
--- a/routers/repo/git.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package repo
-
-import (
- "fmt"
- "strings"
-)
-
-const advertise_refs = "--advertise-refs"
-
-func command(cmd string, opts ...string) string {
- return fmt.Sprintf("git %s %s", cmd, strings.Join(opts, " "))
-}
-
-/*func upload_pack(repository_path string, opts ...string) string {
- cmd = "upload-pack"
- opts = append(opts, "--stateless-rpc", repository_path)
- return command(cmd, opts...)
-}
-
-func receive_pack(repository_path string, opts ...string) string {
- cmd = "receive-pack"
- opts = append(opts, "--stateless-rpc", repository_path)
- return command(cmd, opts...)
-}*/
-
-/*func update_server_info(repository_path, opts = {}, &block)
- cmd = "update-server-info"
- args = []
- opts.each {|k,v| args << command_options[k] if command_options.has_key?(k) }
- opts[:args] = args
- Dir.chdir(repository_path) do # "git update-server-info" does not take a parameter to specify the repository, so set the working directory to the repository
- self.command(cmd, opts, &block)
- end
- end
-
- def get_config_setting(repository_path, key)
- path = get_config_location(repository_path)
- raise "Config file could not be found for repository in #{repository_path}." unless path
- self.command("config", {:args => ["-f #{path}", key]}).chomp
- end
-
- def get_config_location(repository_path)
- non_bare = File.join(repository_path,'.git') # This is where the config file will be if the repository is non-bare
- if File.exists?(non_bare) then # The repository is non-bare
- non_bare_config = File.join(non_bare, 'config')
- return non_bare_config if File.exists?(non_bare_config)
- else # We are dealing with a bare repository
- bare_config = File.join(repository_path, "config")
- return bare_config if File.exists?(bare_config)
- end
- return nil
- end
-
- end
-*/
diff --git a/routers/repo/http.go b/routers/repo/http.go
index a6189ff2c3..f4cc00aaf3 100644
--- a/routers/repo/http.go
+++ b/routers/repo/http.go
@@ -22,8 +22,8 @@ import (
"github.com/go-martini/martini"
"github.com/gogits/gogs/models"
- "github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/middleware"
+ "github.com/gogits/gogs/modules/setting"
)
func Http(ctx *middleware.Context, params martini.Params) {
@@ -59,7 +59,7 @@ func Http(ctx *middleware.Context, params martini.Params) {
// only public pull don't need auth
isPublicPull := !repo.IsPrivate && isPull
- var askAuth = !isPublicPull || base.Service.RequireSignInView
+ var askAuth = !isPublicPull || setting.Service.RequireSignInView
var authUser *models.User
var authUsername, passwd string
@@ -123,7 +123,7 @@ func Http(ctx *middleware.Context, params martini.Params) {
}
}
- config := Config{base.RepoRootPath, "git", true, true, func(rpc string, input []byte) {
+ config := Config{setting.RepoRootPath, "git", true, true, func(rpc string, input []byte) {
if rpc == "receive-pack" {
firstLine := bytes.IndexRune(input, '\000')
if firstLine > -1 {
@@ -141,16 +141,6 @@ func Http(ctx *middleware.Context, params martini.Params) {
handler := HttpBackend(&config)
handler(ctx.ResponseWriter, ctx.Req)
-
- /* Webdav
- dir := models.RepoPath(username, reponame)
-
- prefix := path.Join("/", username, params["reponame"])
- server := webdav.NewServer(
- dir, prefix, true)
-
- server.ServeHTTP(ctx.ResponseWriter, ctx.Req)
- */
}
type route struct {
@@ -483,14 +473,3 @@ func hdrCacheForever(w http.ResponseWriter) {
w.Header().Set("Expires", fmt.Sprintf("%d", expires))
w.Header().Set("Cache-Control", "public, max-age=31536000")
}
-
-// Main
-/*
-func main() {
- http.HandleFunc("/", requestHandler())
-
- err := http.ListenAndServe(":8080", nil)
- if err != nil {
- log.Fatal("ListenAndServe: ", err)
- }
-}*/
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 6e04288c2b..006b467a86 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -19,6 +19,7 @@ import (
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/mailer"
"github.com/gogits/gogs/modules/middleware"
+ "github.com/gogits/gogs/modules/setting"
)
func Issues(ctx *middleware.Context) {
@@ -242,7 +243,7 @@ func CreateIssuePost(ctx *middleware.Context, params martini.Params, form auth.C
}
// Mail watchers and mentions.
- if base.Service.NotifyMail {
+ if setting.Service.NotifyMail {
tos, err := mailer.SendIssueNotifyMail(ctx.User, ctx.Repo.Owner, ctx.Repo.Repository, issue)
if err != nil {
ctx.Handle(500, "issue.CreateIssue(SendIssueNotifyMail)", err)
@@ -677,7 +678,7 @@ func Comment(ctx *middleware.Context, params martini.Params) {
}
// Mail watchers and mentions.
- if base.Service.NotifyMail {
+ if setting.Service.NotifyMail {
issue.Content = content
tos, err := mailer.SendIssueNotifyMail(ctx.User, ctx.Repo.Owner, ctx.Repo.Repository, issue)
if err != nil {
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index fa4973ecd6..fe2489923e 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -16,6 +16,7 @@ import (
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/mailer"
"github.com/gogits/gogs/modules/middleware"
+ "github.com/gogits/gogs/modules/setting"
)
func Setting(ctx *middleware.Context) {
@@ -189,7 +190,7 @@ func CollaborationPost(ctx *middleware.Context) {
return
}
- if base.Service.NotifyMail {
+ if setting.Service.NotifyMail {
if err = mailer.SendCollaboratorMail(ctx.Render, u, ctx.User, ctx.Repo.Repository); err != nil {
ctx.Handle(500, "setting.CollaborationPost(SendCollaboratorMail)", err)
return
diff --git a/routers/user/social.go b/routers/user/social.go
index a258bad1ab..9a56415fd4 100644
--- a/routers/user/social.go
+++ b/routers/user/social.go
@@ -14,9 +14,9 @@ import (
"github.com/go-martini/martini"
"github.com/gogits/gogs/models"
- "github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/middleware"
+ "github.com/gogits/gogs/modules/setting"
"github.com/gogits/gogs/modules/social"
)
@@ -29,7 +29,7 @@ func extractPath(next string) string {
}
func SocialSignIn(ctx *middleware.Context, params martini.Params) {
- if base.OauthService == nil {
+ if setting.OauthService == nil {
ctx.Handle(404, "social.SocialSignIn(oauth service not enabled)", nil)
return
}
@@ -45,7 +45,7 @@ func SocialSignIn(ctx *middleware.Context, params martini.Params) {
code := ctx.Query("code")
if code == "" {
// redirect to social login page
- connect.SetRedirectUrl(strings.TrimSuffix(base.AppUrl, "/") + ctx.Req.URL.Path)
+ connect.SetRedirectUrl(strings.TrimSuffix(setting.AppUrl, "/") + ctx.Req.URL.Path)
ctx.Redirect(connect.AuthCodeURL(next))
return
}
diff --git a/routers/user/user.go b/routers/user/user.go
index 98480a41ce..bdcd524152 100644
--- a/routers/user/user.go
+++ b/routers/user/user.go
@@ -14,6 +14,7 @@ import (
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/mailer"
"github.com/gogits/gogs/modules/middleware"
+ "github.com/gogits/gogs/modules/setting"
)
func SignIn(ctx *middleware.Context) {
@@ -26,23 +27,23 @@ func SignIn(ctx *middleware.Context) {
}
// Check auto-login.
- userName := ctx.GetCookie(base.CookieUserName)
+ userName := ctx.GetCookie(setting.CookieUserName)
if len(userName) == 0 {
ctx.HTML(200, "user/signin")
return
}
- if base.OauthService != nil {
+ if setting.OauthService != nil {
ctx.Data["OauthEnabled"] = true
- ctx.Data["OauthService"] = base.OauthService
+ ctx.Data["OauthService"] = setting.OauthService
}
isSucceed := false
defer func() {
if !isSucceed {
log.Trace("user.SignIn(auto-login cookie cleared): %s", userName)
- ctx.SetCookie(base.CookieUserName, "", -1)
- ctx.SetCookie(base.CookieRememberName, "", -1)
+ ctx.SetCookie(setting.CookieUserName, "", -1)
+ ctx.SetCookie(setting.CookieRememberName, "", -1)
return
}
}()
@@ -54,7 +55,7 @@ func SignIn(ctx *middleware.Context) {
}
secret := base.EncodeMd5(user.Rands + user.Passwd)
- value, _ := ctx.GetSecureCookie(secret, base.CookieRememberName)
+ value, _ := ctx.GetSecureCookie(secret, setting.CookieRememberName)
if value != user.Name {
ctx.HTML(200, "user/signin")
return
@@ -79,9 +80,9 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) {
sid, isOauth := ctx.Session.Get("socialId").(int64)
if isOauth {
ctx.Data["IsSocialLogin"] = true
- } else if base.OauthService != nil {
+ } else if setting.OauthService != nil {
ctx.Data["OauthEnabled"] = true
- ctx.Data["OauthService"] = base.OauthService
+ ctx.Data["OauthService"] = setting.OauthService
}
if ctx.HasError() {
@@ -103,9 +104,9 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) {
if form.Remember {
secret := base.EncodeMd5(user.Rands + user.Passwd)
- days := 86400 * base.LogInRememberDays
- ctx.SetCookie(base.CookieUserName, user.Name, days)
- ctx.SetSecureCookie(secret, base.CookieRememberName, user.Name, days)
+ days := 86400 * setting.LogInRememberDays
+ ctx.SetCookie(setting.CookieUserName, user.Name, days)
+ ctx.SetSecureCookie(secret, setting.CookieRememberName, user.Name, days)
}
// Bind with social account.
@@ -139,8 +140,8 @@ func SignOut(ctx *middleware.Context) {
ctx.Session.Delete("socialId")
ctx.Session.Delete("socialName")
ctx.Session.Delete("socialEmail")
- ctx.SetCookie(base.CookieUserName, "", -1)
- ctx.SetCookie(base.CookieRememberName, "", -1)
+ ctx.SetCookie(setting.CookieUserName, "", -1)
+ ctx.SetCookie(setting.CookieRememberName, "", -1)
ctx.Redirect("/")
}
@@ -148,7 +149,7 @@ func SignUp(ctx *middleware.Context) {
ctx.Data["Title"] = "Sign Up"
ctx.Data["PageIsSignUp"] = true
- if base.Service.DisableRegistration {
+ if setting.Service.DisableRegistration {
ctx.Data["DisableRegistration"] = true
ctx.HTML(200, "user/signup")
return
@@ -186,7 +187,7 @@ func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) {
ctx.Data["Title"] = "Sign Up"
ctx.Data["PageIsSignUp"] = true
- if base.Service.DisableRegistration {
+ if setting.Service.DisableRegistration {
ctx.Handle(403, "user.SignUpPost", nil)
return
}
@@ -212,7 +213,7 @@ func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) {
Name: form.UserName,
Email: form.Email,
Passwd: form.Password,
- IsActive: !base.Service.RegisterEmailConfirm || isOauth,
+ IsActive: !setting.Service.RegisterEmailConfirm || isOauth,
}
var err error
@@ -243,11 +244,11 @@ func SignUpPost(ctx *middleware.Context, form auth.RegisterForm) {
}
// Send confirmation e-mail, no need for social account.
- if !isOauth && base.Service.RegisterEmailConfirm && u.Id > 1 {
+ if !isOauth && setting.Service.RegisterEmailConfirm && u.Id > 1 {
mailer.SendRegisterMail(ctx.Render, u)
ctx.Data["IsSendRegisterMail"] = true
ctx.Data["Email"] = u.Email
- ctx.Data["Hours"] = base.Service.ActiveCodeLives / 60
+ ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
ctx.HTML(200, "user/activate")
if err = ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil {
@@ -304,11 +305,11 @@ func Activate(ctx *middleware.Context) {
return
}
// Resend confirmation e-mail.
- if base.Service.RegisterEmailConfirm {
+ if setting.Service.RegisterEmailConfirm {
if ctx.Cache.IsExist("MailResendLimit_" + ctx.User.LowerName) {
ctx.Data["ResendLimited"] = true
} else {
- ctx.Data["Hours"] = base.Service.ActiveCodeLives / 60
+ ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
mailer.SendActiveMail(ctx.Render, ctx.User)
if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil {
@@ -346,7 +347,7 @@ func Activate(ctx *middleware.Context) {
func ForgotPasswd(ctx *middleware.Context) {
ctx.Data["Title"] = "Forgot Password"
- if base.MailService == nil {
+ if setting.MailService == nil {
ctx.Data["IsResetDisable"] = true
ctx.HTML(200, "user/forgot_passwd")
return
@@ -359,7 +360,7 @@ func ForgotPasswd(ctx *middleware.Context) {
func ForgotPasswdPost(ctx *middleware.Context) {
ctx.Data["Title"] = "Forgot Password"
- if base.MailService == nil {
+ if setting.MailService == nil {
ctx.Handle(403, "user.ForgotPasswdPost", nil)
return
}
@@ -388,7 +389,7 @@ func ForgotPasswdPost(ctx *middleware.Context) {
}
ctx.Data["Email"] = email
- ctx.Data["Hours"] = base.Service.ActiveCodeLives / 60
+ ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
ctx.Data["IsResetSent"] = true
ctx.HTML(200, "user/forgot_passwd")
}