func (this *AddController) Post() { //数据处理 this.Ct.Request.ParseForm() pkgname := this.Ct.Request.Form.Get("pkgname") content := this.Ct.Request.Form.Get("content") beego.Info(this.Ct.Request.Form) pk := models.GetCruPkg(pkgname) if pk.Id == 0 { var pp models.PkgEntity pp.Pid = 0 pp.Pathname = pkgname pp.Intro = pkgname models.InsertPkg(pp) pk = models.GetCruPkg(pkgname) } var at models.Article at.Pkgid = pk.Id at.Content = content models.InsertArticle(at) this.Ct.Redirect(302, "/admin/index") }
func (this *MainController) Get() { crupkg := models.GetCruPkg(this.Ct.Params[":pkg"]) this.Data["CruPkg"] = crupkg pkglist := models.GetAllPkg() pm := make([]map[string]interface{}, len(pkglist)) for _, pk := range pkglist { m := make(map[string]interface{}, 2) m["PKG"] = pk if this.Ct.Params[":pkg"] == pk.Pathname { m["Cru"] = true } else { m["Cru"] = false } pm = append(pm, m) } this.Data["PkgList"] = pm if crupkg.Id == 0 { this.Data["Content"] = welcome //template.HTML(string(blackfriday.MarkdownCommon([]byte(welcome)))) } else { at := models.GetArticle(crupkg.Id) this.Data["Content"] = at.Content //template.HTML(string(blackfriday.MarkdownCommon([]byte(at.Content)))) } this.TplNames = "index.tpl" }