prepare post history
This commit is contained in:
parent
3dde2ba49a
commit
738b4163a8
@ -62,5 +62,10 @@ return {
|
|||||||
[8] = function ()
|
[8] = function ()
|
||||||
schema.add_column("topics", "sort_order", types.integer{default = 0})
|
schema.add_column("topics", "sort_order", types.integer{default = 0})
|
||||||
db.query("UPDATE topics SET sort_order = (SELECT COUNT(*) FROM topics t2 WHERE t2.ROWID <= topics.ROWID)")
|
db.query("UPDATE topics SET sort_order = (SELECT COUNT(*) FROM topics t2 WHERE t2.ROWID <= topics.ROWID)")
|
||||||
end
|
end,
|
||||||
|
|
||||||
|
[9] = function ()
|
||||||
|
schema.add_column("post_history", "original_markup", types.text{null = false})
|
||||||
|
schema.add_column("post_history", "markup_language", types.text{default = "babycode"})
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
12
util.lua
12
util.lua
@ -214,7 +214,8 @@ function util.destroy_avatar(avatar_id)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function util.create_post(thread_id, user_id, content)
|
function util.create_post(thread_id, user_id, content, markup_language)
|
||||||
|
markup_language = markup_language or "babycode"
|
||||||
db.query("BEGIN")
|
db.query("BEGIN")
|
||||||
local post = Posts:create({
|
local post = Posts:create({
|
||||||
thread_id = thread_id,
|
thread_id = thread_id,
|
||||||
@ -222,12 +223,17 @@ function util.create_post(thread_id, user_id, content)
|
|||||||
current_revision_id = db.NULL,
|
current_revision_id = db.NULL,
|
||||||
})
|
})
|
||||||
|
|
||||||
local bb_content = babycode.to_html(content, html_escape)
|
local parsed_content = ""
|
||||||
|
if markup_language == "babycode" then
|
||||||
|
parsed_content = babycode.to_html(content, html_escape)
|
||||||
|
end
|
||||||
|
|
||||||
local revision = PostHistory:create({
|
local revision = PostHistory:create({
|
||||||
post_id = post.id,
|
post_id = post.id,
|
||||||
content = bb_content,
|
content = parsed_content,
|
||||||
is_initial_revision = true,
|
is_initial_revision = true,
|
||||||
|
original_markup = content,
|
||||||
|
markup_language = "babycode",
|
||||||
})
|
})
|
||||||
|
|
||||||
post:update({current_revision_id = revision.id})
|
post:update({current_revision_id = revision.id})
|
||||||
|
Loading…
Reference in New Issue
Block a user