This commit is contained in:
deepzz0
2016-11-15 01:51:23 +08:00
parent d84abc2719
commit a6d2f7796e
10 changed files with 128 additions and 43 deletions

View File

@@ -3,8 +3,6 @@ package setting
import (
"io/ioutil"
"os"
"path"
"github.com/eiblog/utils/logd"
"gopkg.in/yaml.v2"
@@ -16,7 +14,6 @@ const (
)
var (
wd, _ = os.Getwd()
Conf = new(Config)
BlackIP = make(map[string]bool)
)
@@ -32,9 +29,7 @@ type Config struct {
Identifier string // 截取标示
Favicon string // icon地址
StartID int32 // 文章起始id
Static string // cdn地址
SearchURL string // elasticsearch 地址
Superfeedr string // superfeedr
Disqus struct { // 获取文章数量相关
ShortName string
PublicKey string
@@ -54,8 +49,17 @@ type Config struct {
AccessKey string
SecretKey string
}
Mode RunMode // 运行模式
Twitter string // twitter地址
Mode RunMode // 运行模式
Twitter string // twitter地址
FeedrURL string // superfeedr url
PingRPCs []string // ping rpc 地址
Account struct {
Username string // *
Password string // *
Email string
PhoneNumber string
Address string
}
Blogger struct { // 初始化数据
BlogName string
SubTitle string
@@ -63,13 +67,6 @@ type Config struct {
BTitle string
Copyright string
}
Account struct {
Username string // *
Password string // *
Email string
PhoneNumber string
Address string
}
}
type RunMode struct {
@@ -84,13 +81,12 @@ type RunMode struct {
func init() {
// 初始化配置
dir := wd + "/conf"
data, err := ioutil.ReadFile(path.Join(dir, "app.yml"))
data, err := ioutil.ReadFile("conf/app.yml")
checkError(err)
err = yaml.Unmarshal(data, Conf)
checkError(err)
data, err = ioutil.ReadFile(path.Join(dir, "blackip.yml"))
data, err = ioutil.ReadFile("conf/blackip.yml")
checkError(err)
err = yaml.Unmarshal(data, BlackIP)
checkError(err)