diff --git a/conf/app.conf.example b/conf/app.conf.example index 786f2fef..c8a11eec 100644 --- a/conf/app.conf.example +++ b/conf/app.conf.example @@ -28,10 +28,9 @@ timezone = Asia/Shanghai #数据库配置 db_host=127.0.0.1 db_port=3306 -db_database=webhook_db +db_database=mindoc_db db_username=root db_password=123456 -db_prefix=md_ #项目默认封面 cover=/static/images/book.jpg diff --git a/conf/editor.json b/conf/editor.json deleted file mode 100644 index 411b4178..00000000 --- a/conf/editor.json +++ /dev/null @@ -1,6 +0,0 @@ -[{ - "name":"Editor.md", - "description" : "", - "style" : "", - "script" : "" -}] \ No newline at end of file diff --git a/controllers/document.go b/controllers/document.go index b78f7571..e6ee92ef 100644 --- a/controllers/document.go +++ b/controllers/document.go @@ -91,6 +91,11 @@ func (c *DocumentController) Index() { if identify == "" { c.Abort("404") } + //如果没有开启你们访问则跳转到登录 + if !c.EnableAnonymous && c.Member == nil { + c.Redirect(beego.URLFor("AccountController.Login"),302) + return + } bookResult := isReadable(identify,token,c) @@ -119,6 +124,13 @@ func (c *DocumentController) Read() { if identify == "" || id == ""{ c.Abort("404") } + + //如果没有开启你们访问则跳转到登录 + if !c.EnableAnonymous && c.Member == nil { + c.Redirect(beego.URLFor("AccountController.Login"),302) + return + } + bookResult := isReadable(identify,token,c) c.TplName = "document/" + bookResult.Theme + "_read.tpl" diff --git a/models/options.go b/models/options.go index eefe648d..9b68ff22 100644 --- a/models/options.go +++ b/models/options.go @@ -33,25 +33,25 @@ func NewOption() *Option { return &Option{} } -func (p *Option) Find(id int) error { +func (p *Option) Find(id int) (*Option,error) { o := orm.NewOrm() p.OptionId = id if err := o.Read(p);err != nil { - return err + return p,err } - return nil + return p,nil } -func (p *Option) FindByKey(key string) error { +func (p *Option) FindByKey(key string) (*Option,error) { o := orm.NewOrm() p.OptionName = key if err := o.Read(p);err != nil { - return err + return p,err } - return nil + return p,nil } func GetOptionValue(key, def string) string { diff --git a/routers/filter.go b/routers/filter.go index 5a61d5cf..24100a76 100644 --- a/routers/filter.go +++ b/routers/filter.go @@ -5,6 +5,7 @@ import ( "github.com/astaxie/beego/context" "github.com/lifei6671/godoc/conf" "github.com/lifei6671/godoc/models" + "strings" ) func init() {