Files
leanote/app/controllers/IndexController.go

45 lines
1.1 KiB
Go
Raw Normal View History

2014-05-07 13:06:24 +08:00
package controllers
import (
"github.com/leanote/leanote/app/info"
2015-11-13 17:58:41 +08:00
"github.com/revel/revel"
// . "github.com/leanote/leanote/app/lea"
2014-05-07 13:06:24 +08:00
)
// 首页
type Index struct {
BaseController
}
2014-11-12 19:08:41 +08:00
func (c Index) Default() revel.Result {
2015-11-13 17:58:41 +08:00
if configService.HomePageIsAdminsBlog() {
2014-11-12 17:32:03 +08:00
blog := Blog{c.BaseController}
2015-11-13 17:58:41 +08:00
return blog.Index(configService.GetAdminUsername())
2014-11-12 17:32:03 +08:00
}
2014-11-12 19:08:41 +08:00
return c.Index()
}
2015-11-13 17:58:41 +08:00
2014-11-12 19:08:41 +08:00
// leanote展示页, 没有登录的, 或已登录明确要进该页的
func (c Index) Index() revel.Result {
2014-05-07 20:31:30 +08:00
c.SetUserInfo()
c.ViewArgs["title"] = "leanote"
c.ViewArgs["openRegister"] = configService.GlobalStringConfigs["openRegister"]
2015-10-10 17:23:27 +08:00
c.SetLocale()
2015-11-13 17:58:41 +08:00
return c.RenderTemplate("home/index.html")
2014-05-07 13:06:24 +08:00
}
// 建议
func (c Index) Suggestion(addr, suggestion string) revel.Result {
re := info.NewRe()
re.Ok = suggestionService.AddSuggestion(info.Suggestion{Addr: addr, UserId: c.GetObjectUserId(), Suggestion: suggestion})
2015-11-13 17:58:41 +08:00
2014-05-07 13:06:24 +08:00
// 发给我
go func() {
2015-11-13 17:58:41 +08:00
emailService.SendEmail("leanote@leanote.com", "建议", "UserId: "+c.GetUserId()+" <br /> Suggestions: "+suggestion)
}()
return c.RenderJSON(re)
2015-11-13 17:58:41 +08:00
}