class Revelry::Content::Configuration def js_export @js_export || false end def js_export? js_export end def js_export=(v) @js_export = v end def user_for_content(&block) if block_given? @user_finder = block end @user_finder || default_user_finder end def default_user_finder ->(controller) { controller.current_user } end def authorization_policy(&block) if block_given? @authorization_policy = block end @authorization_policy || default_authorization_policy end def default_authorization_policy ->(user) do if user.present? if user.respond_to?(:has_role?) return user.has_role? :admin else return user.admin? end end false end end def authorize(controller) user = user_for_content.call(controller) authorization_policy.call(user) end def markdown_renderer @markdown_renderer || default_markdown_renderer end def markdown_renderer=(klass) @markdown_renderer = klass end def default_markdown_renderer Redcarpet::Render::HTML end def sanitizer=(klass) @sanitizer = klass end def sanitizer @sanitizer || default_sanitizer end def default_sanitizer ->(rendered_content) { Sanitize.fragment(rendered_content, Sanitize::Config::BASIC.merge(remove_contents: true)) } end end