Пример #1
0
func (this *ManageController) Get() {
	wp := models.NewWebPage("博客")
	wp.IncrViewCount()

	// this.Data["OneBlog"] = ms.ToMap()

	s := this.Ctx.Input.Param(":key")
	if _, err := strconv.Atoi(s); err != nil {
		this.checkError()
		return
	}
	b, _ := models.GetBlogById(1)
	if nil == b.ReadBlogByID(s) {
		this.Data["ArticleTitle"] = b.Title
		this.Data["ArticleContent"] = b.Content

	} else {
		this.checkError()
		return
	}
	this.Data["PageTitle"] = wp.GetPageTitle()
	this.Data["ImgHost"] = wp.GetImgHost()
	this.Data["StaticHost"] = wp.GetStaticHost()

	this.TplNames = "manage.tpl"
}
Пример #2
0
func (this *ManageController) checkError() {
	wp := models.NewWebPage("博客-Error")

	// this.Data["OneBlog"] = ms.ToMap()

	wp.IncrViewCount()
	this.Data["PageTitle"] = wp.GetPageTitle()
	this.Data["ImgHost"] = wp.GetImgHost()
	this.Data["StaticHost"] = wp.GetStaticHost()

	this.TplNames = "blog.tpl"
}
Пример #3
0
func (this *MatrixController) Post() {
	// log.Println("is https: ", this.Ctx.Input.IsSecure())
	wp := models.NewWebPage("首页Matrix")
	wp.IncrViewCount()

	resmag := &models.MatrixUpJson{}
	if err := this.ParseForm(resmag); err != nil {
		this.Ctx.WriteString(`{"code":-1,"data":"` + err.Error() + `"}`)
		return
	}

	switch resmag.Code {
	case 1:
		vals, err := models.GetAllMatrix()
		if err != nil {
			this.Ctx.WriteString(`{"code":-2,"data":"models.GetAllMatrix"}`)
			return
		}
		jsonstr := vals.ToJson()
		this.Ctx.WriteString(`{"code":1,"data":` + jsonstr + `}`)
	case 2:
		resmag.H, _ = strconv.Atoi(this.GetString("h"))
		resmag.W, _ = strconv.Atoi(this.GetString("w"))
		resmag.Col, _ = strconv.Atoi(this.GetString("val"))

		b, e := models.UpdateMatrix(resmag.H, resmag.W)
		if e != nil {
			log.Error(e.Error())
			this.Ctx.WriteString(`{"code":-3,"data":"up error"}`)
		} else if b {
			this.Ctx.WriteString(`{"code":0,"data":"up false"}`)
		} else {
			this.Ctx.WriteString(`{"code":0,"data":"up success"}`)
		}
	default:
		this.Ctx.WriteString(`{"code":-1,"data":"none"}`)
	}
}
Пример #4
0
// @router /v1/blog [get]
func (this *BlogController) ShowList() {
	log.Debug("// @router /v1/blog [get]")
	wp := models.NewWebPage("博客")
	wp.IncrViewCount()
	this.Ctx.WriteString("// @router /v1/blog [get]")
}