I've created a WordpressComment class that checks if the comment is referencing another comment. If it does it adds a reference in the same pattern as the UI
def body(lookup)
quoted = nil
parent = nil
if parent_import_id != nil then
parent_id = lookup::post_id_from_imported_post_id(parent_import_id)
parent = Post.where(id:parent_id).first
if parent != nil then
user = User.where(id:parent.user_id).first
@parent_user_name = user.username_lower
quoted = "[quoted=\"#{parent_user_name}, post:#{parent.post_number}, topic:#{parent.topic_id}\"]<br/><br/>#{parent.cooked}<br/>[/quote]<br/>"
end
end
return "#{quoted}#{content}<p /><p />#{author}<p />#{author_url}".gsub(/\\n/,'<br/>').strip[0...32000]
end
It inserts the right link .. but it's not rendering correctly.
It looks something like this
[quote="{username}, post:{post_id}, topic:topic_id"] ... quoted text ... [/quote]
I researched search?q=quoting another post #dev
Interestingly I found a few posts with the same quoting issue.
How do you add a quote from another post in post.raw so that it gets rendered?
Cheers and thanks, to Florian at meta.discousre.org
The issue was I had quoted instead of quote, and there has to be a line break at the end of the quote block.
Fixing the typo and inserting the line break worked!
def body(lookup)
quoted = nil
parent = nil
if parent_import_id != nil then
parent_id = lookup::post_id_from_imported_post_id(parent_import_id)
parent = Post.where(id:parent_id).first
if parent != nil then
user = User.where(id:parent.user_id).first
@parent_user_name = user.username_lower
quoted = "[quote=\"#{parent_user_name}, post:#{parent.post_number}, topic:#{parent.topic_id}\"]<br/><br/>#{parent.cooked}<br/>[/quote]\n<br/>"
end
end
return "#{quoted}#{content}<p /><p />#{author}<p />#{author_url}".gsub(/\\n/,'<br/>').strip[0...32000]
end