From caeddb79a339d8eaff78ac0212ac2959700d77de Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Mon, 14 Apr 2014 21:07:21 -0400 Subject: [PATCH 1/2] update SetEngine for postgresql #76 --- models/models.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/models/models.go b/models/models.go index cd9dc38ac1..fe17229cc3 100644 --- a/models/models.go +++ b/models/models.go @@ -89,8 +89,16 @@ func SetEngine() (err error) { orm, err = xorm.NewEngine("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8", DbCfg.User, DbCfg.Pwd, DbCfg.Host, DbCfg.Name)) case "postgres": - orm, err = xorm.NewEngine("postgres", fmt.Sprintf("user=%s password=%s dbname=%s sslmode=%s", - DbCfg.User, DbCfg.Pwd, DbCfg.Name, DbCfg.SslMode)) + var host, port = "127.0.0.1", "5432" + fields := strings.Split(DbCfg.Host, ":") + if len(fields) > 0 { + host = fields[0] + } + if len(fields) > 1 { + port = fields[1] + } + orm, err = xorm.NewEngine("postgres", fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s", + DbCfg.User, DbCfg.Pwd, host, port, DbCfg.Name, DbCfg.SslMode)) case "sqlite3": os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm) orm, err = xorm.NewEngine("sqlite3", DbCfg.Path) From b9a1d13c29c3a1dcebc5b34914a29efbafd374f5 Mon Sep 17 00:00:00 2001 From: Christopher Brickley Date: Mon, 14 Apr 2014 22:01:24 -0400 Subject: [PATCH 2/2] change gravatar image to match URL scheme --- models/user.go | 2 +- modules/base/tool.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/models/user.go b/models/user.go index ffee2dd9e5..ab43df7a1e 100644 --- a/models/user.go +++ b/models/user.go @@ -76,7 +76,7 @@ func (user *User) AvatarLink() string { if base.Service.EnableCacheAvatar { return "/avatar/" + user.Avatar } - return "http://1.gravatar.com/avatar/" + user.Avatar + return "//1.gravatar.com/avatar/" + user.Avatar } // NewGitSig generates and returns the signature of given user. diff --git a/modules/base/tool.go b/modules/base/tool.go index 082c039250..9b165b979b 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -143,7 +143,7 @@ func AvatarLink(email string) string { if Service.EnableCacheAvatar { return "/avatar/" + EncodeMd5(email) } - return "http://1.gravatar.com/avatar/" + EncodeMd5(email) + return "//1.gravatar.com/avatar/" + EncodeMd5(email) } // Seconds-based time units