used shared helper code
This commit is contained in:
@ -1,32 +1,12 @@
|
|||||||
require "redcarpet"
|
|
||||||
|
|
||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
|
include Merged::SharedHelper
|
||||||
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
|
|
||||||
|
|
||||||
def shorten(text , to = 100)
|
def shorten(text , to = 100)
|
||||||
return "" if text.blank?
|
return "" if text.blank?
|
||||||
"#{text[0..to]} . . . ".html_safe
|
"#{text[0..to]} . . . ".html_safe
|
||||||
end
|
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
|
def main_app
|
||||||
Rails.application.routes.url_helpers
|
Rails.application.routes.url_helpers
|
||||||
|
Reference in New Issue
Block a user