]> source.dussan.org Git - gitea.git/commitdiff
Add some config options
authorUnknown <joe2010xtmf@163.com>
Tue, 18 Mar 2014 05:33:53 +0000 (01:33 -0400)
committerUnknown <joe2010xtmf@163.com>
Tue, 18 Mar 2014 05:33:53 +0000 (01:33 -0400)
conf/app.ini
models/user.go
modules/base/conf.go
web.go

index 1c7021072f6d17d41a26bd7d218ca66e4c8bec56..9d4ee0b594abd140873be4666e51e6cc5f42c73d 100644 (file)
@@ -1,12 +1,14 @@
-# App name that shows on every page title
+; App name that shows on every page title
 APP_NAME = Gogs: Go Git Service
-# !!MUST CHANGE TO YOUR USER NAME!!
+; !!MUST CHANGE TO YOUR USER NAME!!
 RUN_USER = lunny
+; Either "dev", "prod" or "test", based on martini
+RUN_MODE = dev
 
 [repository]
 ROOT = /Users/%(RUN_USER)s/git/gogs-repositories
-LANG_IGNS=Google Go|C|Python|Ruby|C Sharp
-LICENSES=Apache v2 License|GPL v2|MIT License|Affero GPL|BSD (3-Clause) License
+LANG_IGNS = Google Go|C|Python|Ruby|C Sharp
+LICENSES = Apache v2 License|GPL v2|MIT License|Affero GPL|BSD (3-Clause) License
 
 [server]
 DOMAIN = gogits.org
@@ -14,15 +16,25 @@ HTTP_ADDR =
 HTTP_PORT = 3000
 
 [database]
-# Either "mysql" or "postgres", it's your choice
+; Either "mysql" or "postgres", it's your choice
 DB_TYPE = mysql
 HOST = 
 NAME = gogs
 USER = root
 PASSWD =
-# For "postgres" only, either "disable" or "verify-full"
+; For "postgres" only, either "disable", "require" or "verify-full"
 SSL_MODE = disable
 
 [security]
-# !!CHANGE THIS TO KEEP YOUR USER DATA SAFE!!
+; !!CHANGE THIS TO KEEP YOUR USER DATA SAFE!!
 USER_PASSWD_SALT = !#@FDEWREWR&*(
+
+[mailer]
+ENABLED = true
+; Name displayed in mail title
+NAME = %(APP_NAME)s
+; Mail server
+HOST = 
+; Mailer user name and password
+USER = 
+PASSWD = 
\ No newline at end of file
index 87c644b2b6919b0fabd8c648b6069fac46d2021b..80af9bd4ba861bee15d6360607f791d81e4fad42 100644 (file)
@@ -252,7 +252,7 @@ func LoginUserPlain(name, passwd string) (*User, error) {
        } else if !has {
                err = ErrUserNotExist
        }
-       return &user, nil
+       return &user, err
 }
 
 // FollowUser marks someone be another's follower.
index 9ed5545e8afc439a139eb7bb6cefd3b183b75c47..83c7f8872d7f5ff01a16828cc9ec12cc8e16d70c 100644 (file)
@@ -13,13 +13,23 @@ import (
 
        "github.com/Unknwon/com"
        "github.com/Unknwon/goconfig"
+
+       "github.com/gogits/gogs/modules/log"
 )
 
+// Mailer represents a mail service.
+type Mailer struct {
+       Name         string
+       Host         string
+       User, Passwd string
+}
+
 var (
-       AppVer  string
-       AppName string
-       Domain  string
-       Cfg     *goconfig.ConfigFile
+       AppVer      string
+       AppName     string
+       Domain      string
+       Cfg         *goconfig.ConfigFile
+       MailService *Mailer
 )
 
 func exeDir() (string, error) {
@@ -59,6 +69,17 @@ func init() {
        }
        Cfg.BlockMode = false
 
-       AppName = Cfg.MustValue("", "APP_NAME")
+       AppName = Cfg.MustValue("", "APP_NAME", "Gogs: Go Git Service")
        Domain = Cfg.MustValue("server", "DOMAIN")
+
+       // Check mailer setting.
+       if Cfg.MustBool("mailer", "ENABLED") {
+               MailService = &Mailer{
+                       Name:   Cfg.MustValue("mailer", "NAME", AppName),
+                       Host:   Cfg.MustValue("mailer", "HOST", "127.0.0.1:25"),
+                       User:   Cfg.MustValue("mailer", "USER", "example@example.com"),
+                       Passwd: Cfg.MustValue("mailer", "PASSWD", "******"),
+               }
+               log.Info("Mail Service Enabled")
+       }
 }
diff --git a/web.go b/web.go
index ca504ea56013d72959fc2af9db2480c2aefa2eab..cc20097907dda59d77d669d3f1839a18adea7a8b 100644 (file)
--- a/web.go
+++ b/web.go
@@ -8,6 +8,7 @@ import (
        "fmt"
        "html/template"
        "net/http"
+       "strings"
 
        "github.com/codegangsta/cli"
        "github.com/codegangsta/martini"
@@ -34,8 +35,20 @@ gogs web`,
        Flags:  []cli.Flag{},
 }
 
+// Check run mode(Default of martini is Dev).
+func checkRunMode() {
+       switch base.Cfg.MustValue("", "RUN_MODE") {
+       case "prod":
+               martini.Env = martini.Prod
+       case "test":
+               martini.Env = martini.Test
+       }
+       log.Info("Run Mode: %s", strings.Title(martini.Env))
+}
+
 func runWeb(*cli.Context) {
        log.Info("%s %s", base.AppName, base.AppVer)
+       checkRunMode()
 
        m := martini.Classic()