Esempio n. 1
0
// print success message
func printSuccessPage(app core.Application, w http.ResponseWriter, r *http.Request, msg string) {
	buildPage := core.GetBuildCube(app, r)
	buildPage["PageCube"]["Msg"] = msg
	buildPage["PageCube"]["MsgType"] = "success"
	app.ForwardByWaitress(sharedMsgWaitress, w, r)
	return
}
Esempio n. 2
0
// get function
func (self *ManageArticleWaitress) Get(w http.ResponseWriter, r *http.Request, c appengine.Context) {
	// get all articles
	articles, err := ds.GetAllArticles(c)
	oops(err, w)
	// setup build cube
	buildCube := core.GetBuildCube(self.GetApp(), r)
	buildCube["PageCube"]["Articles"] = articles

	sharedTempler.BuildPage(c, w, buildCube, "baseTpl", "manageArtTpl")
	return
}
Esempio n. 3
0
// get function
func (self *EditArticleWaitress) Get(w http.ResponseWriter, r *http.Request, c appengine.Context) {
	// get id
	r.ParseForm()
	articleId := r.Form.Get("id")
	// get article
	article, err := ds.GetArticleById(articleId, c)
	oops(err, w)
	// setup build cube
	buildCube := core.GetBuildCube(self.GetApp(), r)
	buildCube["PageCube"]["Article"] = article
	// build page
	sharedTempler.BuildPage(c, w, buildCube, "baseTpl", "editArtTpl")
}
Esempio n. 4
0
func (self *MsgWaitress) Get(w http.ResponseWriter, r *http.Request, c appengine.Context) {
	// setup build cube
	buildCube := core.GetBuildCube(self.GetApp(), r)
	// buildCube["PageCube"]["Articles"] = articles
	pageCube := buildCube["PageCube"]

	if pageCube["MsgType"] == "warning" {
		sharedTempler.BuildPage(c, w, buildCube, "baseTpl", "warningTpl")
	} else if pageCube["MsgType"] == "success" {
		sharedTempler.BuildPage(c, w, buildCube, "baseTpl", "successTpl")
	}

}
Esempio n. 5
0
// over write "Get" method
func (self *HomeWaitress) Get(w http.ResponseWriter, r *http.Request, c appengine.Context) {
	// get all articles
	articles, err := ds.GetAllArticles(c)
	oops(err, w)
	aFloats, err := ds.GetAllAFloat(c)
	oops(err, w)
	// setup
	buildCube := core.GetBuildCube(self.GetApp(), r)
	buildCube["PageCube"]["Articles"] = articles
	buildCube["PageCube"]["AFloats"] = aFloats
	// build page
	err = sharedTempler.BuildPage(c, w, buildCube, "baseTpl", "homeTpl")
	oops(err, w)
}
Esempio n. 6
0
// over write
func (self *AddAdminWaitress) Get(w http.ResponseWriter, r *http.Request, c appengine.Context) {
	// * check if has a admin
	// get the admin info
	keysCount, err := ds.AdminCount(c)
	oops(err, w)
	// check the count of keys
	if keysCount > 0 {
		// warning that admin has been exist
		printWarningPage(self.GetApp(), w, r, "管理员已经存在!")
		return
	}

	// * set the admin
	// build a form
	buildCube := core.GetBuildCube(self.GetApp(), r)
	err = sharedTempler.BuildPage(c, w, buildCube, "baseTpl", "addAdminTpl")
	oops(err, w)
	return
}
Esempio n. 7
0
// get function
func (self *AddAFloatWaitress) Get(w http.ResponseWriter, r *http.Request, c appengine.Context) {
	// build page
	buildCube := core.GetBuildCube(self.GetApp(), r)
	sharedTempler.BuildPage(c, w, buildCube, "baseTpl", "addAFTpl")
}