Canapin
(Coin-coin le Canapin)
February 4, 2023, 10:52pm
4
Hi Proje DEV!
Are you using Topic List Excerpts ?
I believe you need a plugin if you want to override it to keep line breaks.
I think his is what would need to be overridden: discourse/topics_controller.rb at main 路 discourse/discourse 路 GitHub
More specifically, this line:
@posts =
Post
.where(hidden: false, deleted_at: nil, topic_id: @topic.id)
.where("posts.id in (?)", post_ids)
.joins("LEFT JOIN users u on u.id = posts.user_id")
.pluck(:id, :cooked, :username, :action_code, :created_at)
.map do |post_id, cooked, username, action_code, created_at|
attrs = {
post_id: post_id,
username: username,
excerpt: PrettyText.excerpt(cooked, 800, keep_emoji_images: true),
}
if action_code
attrs[:action_code] = action_code
attrs[:created_at] = created_at
end
attrs
end
I didn鈥檛 try, but this may be useful for this purpose: Override existing Discourse methods in plugins
I鈥檇 be happy to have a look, but I don鈥檛 have a development install right now (and I鈥檓 bad at coding, so hopefully someone more skilled will have a more suitable answer).
1 Like