A platform for community discussion. Free, open, simple.
# frozen_string_literal: true
class LocalizedCookedPostProcessor
include CookedProcessorMixin
def initialize(post_localization, post, opts = {})
@post_localization = post_localization
@post = post
@opts = (opts || {}).merge(locale: post_localization.locale)
@doc = Loofah.html5_fragment(@post_localization.cooked)
@cooking_options = @post.cooking_options || {}
@cooking_options[:topic_id] = @post.topic_id
@cooking_options = @cooking_options.symbolize_keys
@model = @post
@category_id = @post&.topic&.category_id
@omit_nofollow = @post.omit_nofollow?
end
def post_process
post_process_oneboxes
post_process_images
DiscourseEvent.trigger(:post_process_localized_cooked, @doc, @post, @post_localization)
@post_localization.link_post_uploads(fragments: @doc)
end
def html
@doc.try(:to_html)
end
end