예제 #1
0
파일: add.go 프로젝트: astaxie/beepkg
func (this *AddController) Post() {
	//数据处理
	this.Ctx.Request.ParseForm()
	pkgname := this.Ctx.Request.Form.Get("pkgname")
	content := this.Ctx.Request.Form.Get("content")
	beego.Info(this.Ctx.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.Ctx.Redirect(302, "/admin/index")
}
예제 #2
0
파일: default.go 프로젝트: astaxie/beepkg
func (this *MainController) Get() {
	crupkg := models.GetCruPkg(this.Ctx.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.Ctx.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"
}