"controllers": "routers",
"models": "",
"others": [
- "utils", "modules",
+ "modules",
"$GOPATH/src/github.com/gogits/binding"
]
},
"runtime"
"github.com/codegangsta/cli"
- "github.com/gogits/gogs/utils"
+ "github.com/gogits/gogs/modules/base"
)
// +build go1.1
// TODO: log
return false
}
- return user.Username == utils.Cfg.MustValue("", "RUN_USER")
+ return user.Username == base.Cfg.MustValue("", "RUN_USER")
}
func main() {
/*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
}*/
_ "github.com/go-sql-driver/mysql"
"github.com/lunny/xorm"
- "github.com/gogits/gogs/utils"
+ "github.com/gogits/gogs/modules/base"
)
var (
}
func setEngine() {
- dbType := utils.Cfg.MustValue("database", "DB_TYPE")
- dbHost := utils.Cfg.MustValue("database", "HOST")
- dbName := utils.Cfg.MustValue("database", "NAME")
- dbUser := utils.Cfg.MustValue("database", "USER")
- dbPwd := utils.Cfg.MustValue("database", "PASSWD")
+ dbType := base.Cfg.MustValue("database", "DB_TYPE")
+ dbHost := base.Cfg.MustValue("database", "HOST")
+ dbName := base.Cfg.MustValue("database", "NAME")
+ dbUser := base.Cfg.MustValue("database", "USER")
+ dbPwd := base.Cfg.MustValue("database", "PASSWD")
uname, err := user.Current()
if err != nil {
}
if uname.Username == "jiahuachen" {
- dbPwd = utils.Cfg.MustValue("database", "PASSWD_jiahua")
+ dbPwd = base.Cfg.MustValue("database", "PASSWD_jiahua")
}
switch dbType {
//log.Trace("Initialized database -> %s", dbName)
- RepoRootPath = utils.Cfg.MustValue("repository", "ROOT")
+ RepoRootPath = base.Cfg.MustValue("repository", "ROOT")
if uname.Username == "jiahuachen" {
- RepoRootPath = utils.Cfg.MustValue("repository", "ROOT_jiahuachen")
+ RepoRootPath = base.Cfg.MustValue("repository", "ROOT_jiahuachen")
}
}
"strings"
"time"
- "github.com/gogits/gogs/utils/log"
git "github.com/libgit2/git2go"
+
+ "github.com/gogits/gogs/modules/log"
)
type Repo struct {
"github.com/dchest/scrypt"
- "github.com/gogits/gogs/utils"
+ "github.com/gogits/gogs/modules/base"
)
var UserPasswdSalt string
func init() {
- UserPasswdSalt = utils.Cfg.MustValue("security", "USER_PASSWD_SALT")
+ UserPasswdSalt = base.Cfg.MustValue("security", "USER_PASSWD_SALT")
}
// User types.
}
user.LowerName = strings.ToLower(user.Name)
- user.Avatar = utils.EncodeMd5(user.Email)
+ user.Avatar = base.EncodeMd5(user.Email)
if err = user.EncodePasswd(); err != nil {
return err
}
"github.com/gogits/binding"
"github.com/gogits/gogs/modules/base"
- "github.com/gogits/gogs/utils/log"
+ "github.com/gogits/gogs/modules/log"
)
type Form interface {
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
- "github.com/gogits/gogs/utils/log"
+ "github.com/gogits/gogs/modules/log"
)
func SignedInId(session sessions.Session) int64 {
--- /dev/null
+// Copyright 2014 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package base
+
+import (
+ "fmt"
+ "os"
+ "os/exec"
+ "path"
+ "path/filepath"
+
+ "github.com/Unknwon/goconfig"
+)
+
+var Cfg *goconfig.ConfigFile
+
+func exeDir() (string, error) {
+ file, err := exec.LookPath(os.Args[0])
+ if err != nil {
+ return "", err
+ }
+ p, err := filepath.Abs(file)
+ if err != nil {
+ return "", err
+ }
+ return path.Dir(p), nil
+}
+
+func init() {
+ var err error
+ workDir, err := exeDir()
+ if err != nil {
+ fmt.Printf("Fail to get work directory: %s\n", err)
+ os.Exit(2)
+ }
+
+ cfgPath := filepath.Join(workDir, "conf", "app.ini")
+ Cfg, err = goconfig.LoadConfigFile(cfgPath)
+ if err != nil {
+ fmt.Printf("Cannot load config file '%s'\n", cfgPath)
+ os.Exit(2)
+ }
+ Cfg.BlockMode = false
+}
--- /dev/null
+// Copyright 2014 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package base
+
+import (
+ "crypto/md5"
+ "encoding/hex"
+)
+
+// Encode string to md5 hex value
+func EncodeMd5(str string) string {
+ m := md5.New()
+ m.Write([]byte(str))
+ return hex.EncodeToString(m.Sum(nil))
+}
--- /dev/null
+// Copyright 2014 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+// Package log is a wrapper of logs for short calling name.
+package log
+
+import (
+ "github.com/gogits/logs"
+)
+
+var logger *logs.BeeLogger
+
+func init() {
+ logger = logs.NewLogger(10000)
+ logger.SetLogger("console", "")
+}
+
+func Trace(format string, v ...interface{}) {
+ logger.Trace(format, v...)
+}
+
+func Info(format string, v ...interface{}) {
+ logger.Info(format, v...)
+}
+
+func Error(format string, v ...interface{}) {
+ logger.Error(format, v...)
+}
+
+func Warn(format string, v ...interface{}) {
+ logger.Warn(format, v...)
+}
+
+func Critical(format string, v ...interface{}) {
+ logger.Critical(format, v...)
+}
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
"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) {
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
"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) {
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
"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) {
+++ /dev/null
-// Copyright 2014 The Gogs Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-package utils
-
-import (
- "fmt"
- "os"
- "os/exec"
- "path"
- "path/filepath"
-
- "github.com/Unknwon/goconfig"
-)
-
-var Cfg *goconfig.ConfigFile
-
-func exeDir() (string, error) {
- file, err := exec.LookPath(os.Args[0])
- if err != nil {
- return "", err
- }
- p, err := filepath.Abs(file)
- if err != nil {
- return "", err
- }
- return path.Dir(p), nil
-}
-
-func init() {
- var err error
- workDir, err := exeDir()
- if err != nil {
- fmt.Printf("Fail to get work directory: %s\n", err)
- os.Exit(2)
- }
-
- cfgPath := filepath.Join(workDir, "conf", "app.ini")
- Cfg, err = goconfig.LoadConfigFile(cfgPath)
- if err != nil {
- fmt.Printf("Cannot load config file '%s'\n", cfgPath)
- os.Exit(2)
- }
- Cfg.BlockMode = false
-}
+++ /dev/null
-// Copyright 2014 The Gogs Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-// Package log is a wrapper of logs for short calling name.
-package log
-
-import (
- "github.com/gogits/logs"
-)
-
-var logger *logs.BeeLogger
-
-func init() {
- logger = logs.NewLogger(10000)
- logger.SetLogger("console", "")
-}
-
-func Trace(format string, v ...interface{}) {
- logger.Trace(format, v...)
-}
-
-func Info(format string, v ...interface{}) {
- logger.Info(format, v...)
-}
-
-func Error(format string, v ...interface{}) {
- logger.Error(format, v...)
-}
-
-func Warn(format string, v ...interface{}) {
- logger.Warn(format, v...)
-}
-
-func Critical(format string, v ...interface{}) {
- logger.Critical(format, v...)
-}
+++ /dev/null
-// Copyright 2014 The Gogs Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-package utils
-
-import (
- "crypto/md5"
- "encoding/hex"
-)
-
-// Encode string to md5 hex value
-func EncodeMd5(str string) string {
- m := md5.New()
- m.Write([]byte(str))
- return hex.EncodeToString(m.Sum(nil))
-}
"github.com/gogits/gogs/modules/auth"
"github.com/gogits/gogs/modules/base"
+ "github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/routers"
"github.com/gogits/gogs/routers/repo"
"github.com/gogits/gogs/routers/user"
- "github.com/gogits/gogs/utils"
- "github.com/gogits/gogs/utils/log"
)
var CmdWeb = cli.Command{
var AppHelpers template.FuncMap = map[string]interface{}{
"AppName": func() string {
- return utils.Cfg.MustValue("", "APP_NAME")
+ return base.Cfg.MustValue("", "APP_NAME")
},
"AppVer": func() string {
return APP_VER
}
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.Any("/repo/list", auth.SignInRequire(false), repo.List)
listenAddr := fmt.Sprintf("%s:%s",
- utils.Cfg.MustValue("server", "HTTP_ADDR"),
- utils.Cfg.MustValue("server", "HTTP_PORT", "3000"))
+ base.Cfg.MustValue("server", "HTTP_ADDR"),
+ base.Cfg.MustValue("server", "HTTP_PORT", "3000"))
log.Info("Listen: %s", listenAddr)
http.ListenAndServe(listenAddr, m)
}