Beispiel #1
0
func (m *Notification) GetContentCache() string {
	if setting.RealtimeRenderMD {
		return utils.RenderMarkdown(m.Content)
	} else {
		return m.ContentCache
	}
}
Beispiel #2
0
func (form *PostForm) UpdatePost(post *models.Post, user *models.User) error {
	changes := utils.FormChanges(post, form)
	if len(changes) == 0 {
		return nil
	}
	utils.SetFormValues(form, post)
	post.CategoryId = form.Category
	post.TopicId = form.Topic
	for _, c := range changes {
		if c == "Content" {
			post.ContentCache = utils.RenderMarkdown(form.Content)
			changes = append(changes, "ContentCache")
		}
	}

	// update last edit author
	if post.LastAuthorId != user.Id {
		post.LastAuthorId = user.Id
		changes = append(changes, "LastAuthor")
	}

	changes = append(changes, "Updated")

	return models.UpdateById(post.Id, post, models.Obj2Table(changes)...)
}
Beispiel #3
0
func (m *Comment) GetMessageCache() string {
	if setting.RealtimeRenderMD {
		return utils.RenderMarkdown(m.Message)
	} else {
		return m.MessageCache
	}
}
Beispiel #4
0
func (form *CommentAdminForm) SetToComment(comment *models.Comment) {
	utils.SetFormValues(form, comment)

	comment.UserId = int64(form.User)
	comment.PostId = int64(form.Post)
	comment.MessageCache = utils.RenderMarkdown(comment.Message)
}
Beispiel #5
0
func (form *PageAdminForm) SetToPage(page *models.Page) {
	utils.SetFormValues(form, page)

	page.UserId = int64(form.User)
	page.LastAuthorId = int64(form.LastAuthor)

	page.ContentCache = utils.RenderMarkdown(page.Content)
}
Beispiel #6
0
func (form *PostAdminForm) SetToPost(post *models.Post) {
	utils.SetFormValues(form, post)

	post.UserId = form.User
	post.LastReplyId = form.LastReply
	post.LastAuthorId = form.LastAuthor
	post.TopicId = form.Topic
	//get category
	if topic, err := models.GetTopicById(form.Topic); err == nil {
		post.CategoryId = topic.CategoryId
	}
	post.ContentCache = utils.RenderMarkdown(post.Content)
}
Beispiel #7
0
func (form *PostForm) SavePost(post *models.Post, user *models.User) error {
	utils.SetFormValues(form, post)
	post.CategoryId = form.Category
	post.TopicId = form.Topic
	post.UserId = user.Id
	post.LastReplyId = user.Id
	post.LastAuthorId = user.Id
	post.CanEdit = true
	post.ContentCache = utils.RenderMarkdown(form.Content)

	// mentioned follow users
	FilterMentions(user, post.ContentCache)

	return post.Insert()
}
Beispiel #8
0
func (form *CommentForm) SaveComment(comment *models.Comment, user *models.User, post *models.Post) error {
	comment.Message = form.Message
	comment.MessageCache = utils.RenderMarkdown(form.Message)
	comment.UserId = user.Id
	comment.PostId = post.Id
	if err := models.InsertComment(comment); err == nil {
		post.LastReplyId = user.Id
		models.UpdateById(post.Id, post, "last_reply_id", "last_replied")

		cnt, _ := models.CountCommentsLTEId(comment.Id)
		comment.Floor = int(cnt)
		return models.UpdateById(comment.Id, comment, "floor")
	} else {
		return err
	}
}
Beispiel #9
0
func (this *Markdown) Post() {
	if this.CheckActiveRedirect() {
		return
	}

	if this.IsAjax() {
		result := map[string]interface{}{
			"success": false,
		}
		action := this.GetString("action")
		switch action {
		case "preview":
			content := this.GetString("content")
			result["preview"] = utils.RenderMarkdown(content)
			result["success"] = true
		}
		this.Data["json"] = result
		this.ServeJson(this.Data)
	}
}