Exemple #1
0
//request-bootstrap操作
func appRequestInit(sapi *sapi.Sapi, plugin interface{}) error {
	sess := sapi.Plugin("session").(*session.Session)
	sess.Start()
	uname := sess.Get("uname").(string)

	view := sapi.Plugin("view").(*view.View)
	view.Assign("siteName", "wgf Demo")
	view.Assign("sessionUname", uname)
	view.Assign("urlLogout", sapi.Plugin("router").(*router.Router).Url("logout", nil))
	return nil
}
Exemple #2
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
}
Exemple #3
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
}