func (this *TopicController) View() { this.Data["IsLogin"] = checkAccount(this.Ctx) this.Data["IsTopic"] = true this.TplNames = "topic_view.html" topic, err := models.GetTopic(this.Ctx.Input.Param("0")) if err != nil { beego.Error(err) this.Redirect("/", 302) return } tid := this.Ctx.Input.Param("0") this.Data["Tid"] = tid this.Data["Tag"] = strings.Split(topic.Tag, ",") topic.Content = string(blackfriday.MarkdownCommon([]byte(topic.Content))) this.Data["Topic"] = topic replies, err := models.GetAllReplies(tid) if err != nil { beego.Error(err) return } for _, reply := range replies { unsafe := blackfriday.MarkdownCommon([]byte(reply.Content)) reply.Content = string(bluemonday.UGCPolicy().SanitizeBytes(unsafe)) } this.Data["Replies"] = replies this.locale() }
func (this *TopicController) Modify() { this.TplNames = "topic_modify.html" this.Data["IsLogin"] = checkAccount(this.Ctx) this.Data["IsTopic"] = true tid := this.Input().Get("tid") topic, err := models.GetTopic(tid) if err != nil { beego.Error(err) this.Redirect("/", 302) return } this.Data["Topic"] = topic this.Data["Tid"] = tid this.locale() }