Merge utils to modules
This commit is contained in:
parent
a2a59f8ad1
commit
5a05d6633d
2
bee.json
2
bee.json
|
@ -11,7 +11,7 @@
|
||||||
"controllers": "routers",
|
"controllers": "routers",
|
||||||
"models": "",
|
"models": "",
|
||||||
"others": [
|
"others": [
|
||||||
"utils", "modules",
|
"modules",
|
||||||
"$GOPATH/src/github.com/gogits/binding"
|
"$GOPATH/src/github.com/gogits/binding"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
6
gogs.go
6
gogs.go
|
@ -11,7 +11,7 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
"github.com/gogits/gogs/utils"
|
"github.com/gogits/gogs/modules/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +build go1.1
|
// +build go1.1
|
||||||
|
@ -31,12 +31,12 @@ func checkRunUser() bool {
|
||||||
// TODO: log
|
// TODO: log
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return user.Username == utils.Cfg.MustValue("", "RUN_USER")
|
return user.Username == base.Cfg.MustValue("", "RUN_USER")
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
/*if !checkRunUser() {
|
/*if !checkRunUser() {
|
||||||
println("The command should be run as", utils.Cfg.MustValue("", "RUN_USER"))
|
println("The command should be run as", base.Cfg.MustValue("", "RUN_USER"))
|
||||||
return
|
return
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
"github.com/lunny/xorm"
|
"github.com/lunny/xorm"
|
||||||
|
|
||||||
"github.com/gogits/gogs/utils"
|
"github.com/gogits/gogs/modules/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -41,11 +41,11 @@ type Comment struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setEngine() {
|
func setEngine() {
|
||||||
dbType := utils.Cfg.MustValue("database", "DB_TYPE")
|
dbType := base.Cfg.MustValue("database", "DB_TYPE")
|
||||||
dbHost := utils.Cfg.MustValue("database", "HOST")
|
dbHost := base.Cfg.MustValue("database", "HOST")
|
||||||
dbName := utils.Cfg.MustValue("database", "NAME")
|
dbName := base.Cfg.MustValue("database", "NAME")
|
||||||
dbUser := utils.Cfg.MustValue("database", "USER")
|
dbUser := base.Cfg.MustValue("database", "USER")
|
||||||
dbPwd := utils.Cfg.MustValue("database", "PASSWD")
|
dbPwd := base.Cfg.MustValue("database", "PASSWD")
|
||||||
|
|
||||||
uname, err := user.Current()
|
uname, err := user.Current()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -54,7 +54,7 @@ func setEngine() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if uname.Username == "jiahuachen" {
|
if uname.Username == "jiahuachen" {
|
||||||
dbPwd = utils.Cfg.MustValue("database", "PASSWD_jiahua")
|
dbPwd = base.Cfg.MustValue("database", "PASSWD_jiahua")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch dbType {
|
switch dbType {
|
||||||
|
@ -82,9 +82,9 @@ func setEngine() {
|
||||||
|
|
||||||
//log.Trace("Initialized database -> %s", dbName)
|
//log.Trace("Initialized database -> %s", dbName)
|
||||||
|
|
||||||
RepoRootPath = utils.Cfg.MustValue("repository", "ROOT")
|
RepoRootPath = base.Cfg.MustValue("repository", "ROOT")
|
||||||
if uname.Username == "jiahuachen" {
|
if uname.Username == "jiahuachen" {
|
||||||
RepoRootPath = utils.Cfg.MustValue("repository", "ROOT_jiahuachen")
|
RepoRootPath = base.Cfg.MustValue("repository", "ROOT_jiahuachen")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gogits/gogs/utils/log"
|
|
||||||
git "github.com/libgit2/git2go"
|
git "github.com/libgit2/git2go"
|
||||||
|
|
||||||
|
"github.com/gogits/gogs/modules/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Repo struct {
|
type Repo struct {
|
||||||
|
|
|
@ -14,13 +14,13 @@ import (
|
||||||
|
|
||||||
"github.com/dchest/scrypt"
|
"github.com/dchest/scrypt"
|
||||||
|
|
||||||
"github.com/gogits/gogs/utils"
|
"github.com/gogits/gogs/modules/base"
|
||||||
)
|
)
|
||||||
|
|
||||||
var UserPasswdSalt string
|
var UserPasswdSalt string
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
UserPasswdSalt = utils.Cfg.MustValue("security", "USER_PASSWD_SALT")
|
UserPasswdSalt = base.Cfg.MustValue("security", "USER_PASSWD_SALT")
|
||||||
}
|
}
|
||||||
|
|
||||||
// User types.
|
// User types.
|
||||||
|
@ -115,7 +115,7 @@ func RegisterUser(user *User) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
user.LowerName = strings.ToLower(user.Name)
|
user.LowerName = strings.ToLower(user.Name)
|
||||||
user.Avatar = utils.EncodeMd5(user.Email)
|
user.Avatar = base.EncodeMd5(user.Email)
|
||||||
if err = user.EncodePasswd(); err != nil {
|
if err = user.EncodePasswd(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/gogits/binding"
|
"github.com/gogits/binding"
|
||||||
|
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/utils/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Form interface {
|
type Form interface {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/utils/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SignedInId(session sessions.Session) int64 {
|
func SignedInId(session sessions.Session) int64 {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a MIT-style
|
// Use of this source code is governed by a MIT-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package utils
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a MIT-style
|
// Use of this source code is governed by a MIT-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package utils
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/auth"
|
"github.com/gogits/gogs/modules/auth"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/utils/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Create(req *http.Request, r render.Render, data base.TmplData, session sessions.Session) {
|
func Create(req *http.Request, r render.Render, data base.TmplData, session sessions.Session) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/auth"
|
"github.com/gogits/gogs/modules/auth"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/utils/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func AddPublicKey(req *http.Request, data base.TmplData, r render.Render, session sessions.Session) {
|
func AddPublicKey(req *http.Request, data base.TmplData, r render.Render, session sessions.Session) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/auth"
|
"github.com/gogits/gogs/modules/auth"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/utils/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Dashboard(r render.Render, data base.TmplData, session sessions.Session) {
|
func Dashboard(r render.Render, data base.TmplData, session sessions.Session) {
|
||||||
|
|
11
web.go
11
web.go
|
@ -18,11 +18,10 @@ import (
|
||||||
|
|
||||||
"github.com/gogits/gogs/modules/auth"
|
"github.com/gogits/gogs/modules/auth"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
|
"github.com/gogits/gogs/modules/log"
|
||||||
"github.com/gogits/gogs/routers"
|
"github.com/gogits/gogs/routers"
|
||||||
"github.com/gogits/gogs/routers/repo"
|
"github.com/gogits/gogs/routers/repo"
|
||||||
"github.com/gogits/gogs/routers/user"
|
"github.com/gogits/gogs/routers/user"
|
||||||
"github.com/gogits/gogs/utils"
|
|
||||||
"github.com/gogits/gogs/utils/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var CmdWeb = cli.Command{
|
var CmdWeb = cli.Command{
|
||||||
|
@ -39,7 +38,7 @@ gogs web`,
|
||||||
|
|
||||||
var AppHelpers template.FuncMap = map[string]interface{}{
|
var AppHelpers template.FuncMap = map[string]interface{}{
|
||||||
"AppName": func() string {
|
"AppName": func() string {
|
||||||
return utils.Cfg.MustValue("", "APP_NAME")
|
return base.Cfg.MustValue("", "APP_NAME")
|
||||||
},
|
},
|
||||||
"AppVer": func() string {
|
"AppVer": func() string {
|
||||||
return APP_VER
|
return APP_VER
|
||||||
|
@ -47,7 +46,7 @@ var AppHelpers template.FuncMap = map[string]interface{}{
|
||||||
}
|
}
|
||||||
|
|
||||||
func runWeb(*cli.Context) {
|
func runWeb(*cli.Context) {
|
||||||
log.Info("%s %s", utils.Cfg.MustValue("", "APP_NAME"), APP_VER)
|
log.Info("%s %s", base.Cfg.MustValue("", "APP_NAME"), APP_VER)
|
||||||
|
|
||||||
m := martini.Classic()
|
m := martini.Classic()
|
||||||
|
|
||||||
|
@ -75,8 +74,8 @@ func runWeb(*cli.Context) {
|
||||||
m.Any("/repo/list", auth.SignInRequire(false), repo.List)
|
m.Any("/repo/list", auth.SignInRequire(false), repo.List)
|
||||||
|
|
||||||
listenAddr := fmt.Sprintf("%s:%s",
|
listenAddr := fmt.Sprintf("%s:%s",
|
||||||
utils.Cfg.MustValue("server", "HTTP_ADDR"),
|
base.Cfg.MustValue("server", "HTTP_ADDR"),
|
||||||
utils.Cfg.MustValue("server", "HTTP_PORT", "3000"))
|
base.Cfg.MustValue("server", "HTTP_PORT", "3000"))
|
||||||
log.Info("Listen: %s", listenAddr)
|
log.Info("Listen: %s", listenAddr)
|
||||||
http.ListenAndServe(listenAddr, m)
|
http.ListenAndServe(listenAddr, m)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue