used shared helper code

This commit is contained in:
Torsten 2023-01-15 21:24:05 +02:00
parent d017502f18
commit d815488b92

View File

@ -1,32 +1,12 @@
require "redcarpet"
module ApplicationHelper
def renderer
options = {hard_wrap: true , autolink: true, no_intra_emphasis: true ,
safe_links_only: true, no_styles: true ,
link_attributes: { target: '_blank' }}
html = Redcarpet::Render::HTML.new(options)
Redcarpet::Markdown.new(html, options)
end
include Merged::SharedHelper
def shorten(text , to = 100)
return "" if text.blank?
"#{text[0..to]} . . . ".html_safe
end
def prose_classes
classes = "prose lg:prose-lg "
classes += "prose-headings:text-inherit "
{ class: classes }
end
def markdown(text)
return "" if text.blank?
text = text.text unless text.is_a?(String)
return "" if text.blank?
self.renderer.render(text).html_safe
end
def main_app
Rails.application.routes.url_helpers