Beispiel #1
0
func (p *IndexAction) Execute() error {
	p.DenyIfNotLogin()

	view := p.Sapi.Plugin("view").(*view.View)

	view.Assign("title", "首页")

	links := []map[string]string{
		map[string]string{"name": "walu's wiki", "href": "http://www.walu.cc"},
		map[string]string{"name": "golang", "href": "http://golang.org"},
	}
	view.Assign("links", links)
	view.Display("index.tpl")
	return nil
}
Beispiel #2
0
func (p *LoginAction) DoGet() error {
	pHttpparam := p.Sapi.Plugin("httpparam").(*httpparam.Param)
	uname := pHttpparam.Get.Get("uname")

	pRouter := p.Sapi.Plugin("router").(*router.Router)
	if "" != uname {
		pSession := p.Sapi.Plugin("session").(*session.Session)
		pSession.Set("uname", uname)

		pHeader := p.Sapi.Plugin("header").(*header.Header)
		pHeader.Redirect(pRouter.Url("index", nil))
		return nil
	}

	view := p.Sapi.Plugin("view").(*view.View)
	view.Assign("title", "登录")
	view.Assign("urlLogin", pRouter.Url("login", nil))
	view.Display("login.tpl")
	return nil
}