Example #1
0
func (this *DelBlogController) Get() {
	this.Layout = "admin/layout.html"
	this.TplNames = "admin/delblog.tpl"
	this.Ctx.Request.ParseForm()
	id, _ := strconv.Atoi(this.Ctx.Request.Form.Get(":id"))
	blogInfo := models.GetBlogInfoById(id)
	models.DelBlogById(blogInfo)
	this.Ctx.Redirect(302, "/admin/index")
}
Example #2
0
func (this *EditBlogController) Get() {
	this.Layout = "admin/layout.html"
	this.TplNames = "admin/editblog.tpl"
	this.Ctx.Request.ParseForm()
	id, _ := strconv.Atoi(this.Ctx.Request.Form.Get(":id"))
	blogInfo := models.GetBlogInfoById(id)
	this.Data["Id"] = blogInfo.Id
	this.Data["Content"] = blogInfo.Content
	this.Data["Title"] = blogInfo.Title
}
Example #3
0
func (this *EditBlogController) Post() {
	this.Ctx.Request.ParseForm()
	id_str := this.Ctx.Request.Form.Get("id")
	id, _ := strconv.Atoi(id_str)
	blogInfo := models.GetBlogInfoById(id)
	title := this.Ctx.Request.Form.Get("title")
	content := this.Ctx.Request.Form.Get("content")
	blogInfo.Title = title
	blogInfo.Content = content
	//打印生成日志
	defer utils.Info("editBlog: ", "id:"+id_str, "title:"+title, "content:"+content)
	//获取系统当前时间
	now := time.Now().Format("2006-01-02 15:04:05")
	blogInfo.Created = now
	models.UpdateBlogInfo(blogInfo)
	this.Ctx.Redirect(302, "/admin/index")
}
Example #4
0
func (this *MainController) Get() {
	this.Ctx.Request.ParseForm()
	id, _ := strconv.Atoi(this.Ctx.Request.Form.Get(":id"))
	if id == 0 {
		id = 1
	}
	blogInfo := models.GetBlogInfoById(id)
	this.Data["BlogInfo"] = blogInfo
	bloglist := models.GetAllBlogList()
	pm := make([]map[string]interface{}, len(bloglist))
	for k, pk := range bloglist {
		m := make(map[string]interface{}, 2)
		m["Blog"] = pk
		if this.Ctx.Request.Form.Get(":title") == pk.Title {
			//if this.Ctx.Params[":title"] == pk.Title {
			m["Cru"] = true
		} else {
			m["Cru"] = false
		}
		pm[k] = m
	}
	this.Data["BlogList"] = pm
	if blogInfo.Id == 0 {
		this.Data["Content"] = welcome
	} else {
		this.Data["Content"] = blogInfo.Content
	}

	this.Data["Username"] = ""
	sess := globalSessions.SessionStart(this.Ctx.ResponseWriter, this.Ctx.Request)
	username := sess.Get("uname")
	if username != nil {
		this.Data["Username"] = username
	}

	this.TplNames = "index.tpl"
}