all text markdown with redcarpet
This commit is contained in:
parent
308b9e1d2e
commit
c669cf5cfe
@ -5,6 +5,7 @@ PATH
|
|||||||
git
|
git
|
||||||
haml-rails
|
haml-rails
|
||||||
rails (>= 7.0.4)
|
rails (>= 7.0.4)
|
||||||
|
redcarpet
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
@ -194,6 +195,7 @@ GEM
|
|||||||
rb-inotify (0.10.1)
|
rb-inotify (0.10.1)
|
||||||
ffi (~> 1.0)
|
ffi (~> 1.0)
|
||||||
rchardet (1.8.0)
|
rchardet (1.8.0)
|
||||||
|
redcarpet (3.5.1)
|
||||||
regexp_parser (2.6.1)
|
regexp_parser (2.6.1)
|
||||||
rspec (3.12.0)
|
rspec (3.12.0)
|
||||||
rspec-core (~> 3.12.0)
|
rspec-core (~> 3.12.0)
|
||||||
|
@ -11,7 +11,7 @@ module Merged
|
|||||||
@images = Image.all
|
@images = Image.all
|
||||||
end
|
end
|
||||||
def select_template
|
def select_template
|
||||||
@sections = Style.sections
|
@sections = SectionStyle.sections
|
||||||
end
|
end
|
||||||
def select_card_template
|
def select_card_template
|
||||||
@cards = Style.cards
|
@cards = Style.cards
|
||||||
|
@ -1,5 +1,23 @@
|
|||||||
|
require "redcarpet"
|
||||||
|
|
||||||
module Merged
|
module Merged
|
||||||
module MergedHelper
|
module MergedHelper
|
||||||
|
@@renderer = nil
|
||||||
|
|
||||||
|
def renderer
|
||||||
|
return @@renderer unless @@renderer.nil?
|
||||||
|
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)
|
||||||
|
@@renderer = Redcarpet::Markdown.new(html, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
def markdown(text)
|
||||||
|
text = text.text unless text.is_a?(String)
|
||||||
|
return "" if text.blank?
|
||||||
|
renderer.render(text).html_safe
|
||||||
|
end
|
||||||
def blue_button( text, url)
|
def blue_button( text, url)
|
||||||
button( text , url , "bg-blue-500" )
|
button( text , url , "bg-blue-500" )
|
||||||
end
|
end
|
||||||
|
@ -147,7 +147,7 @@ module Merged
|
|||||||
|
|
||||||
def self.build_data(template)
|
def self.build_data(template)
|
||||||
data = { "template" => template , "id" => SecureRandom.hex(10) }
|
data = { "template" => template , "id" => SecureRandom.hex(10) }
|
||||||
style = Style.sections[ template ]
|
style = SectionStyle.sections[ template ]
|
||||||
style.fields.each do |key|
|
style.fields.each do |key|
|
||||||
data[key] = key.upcase
|
data[key] = key.upcase
|
||||||
end unless style.fields.blank?
|
end unless style.fields.blank?
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
%h1.text-2xl.font-bold.tracking-tight.sm:text-4xl
|
%h1.text-2xl.font-bold.tracking-tight.sm:text-4xl
|
||||||
= section.header
|
= section.header
|
||||||
%p.mt-4.text-lg.pt-10
|
%p.mt-4.text-lg.pt-10
|
||||||
= section.text
|
= markdown(section)
|
||||||
- template = "merged/view/cards/" + section.card_template
|
- template = "merged/view/cards/" + section.card_template
|
||||||
.grid{ column_option(section)}
|
.grid{ column_option(section)}
|
||||||
- section.cards.each do |card|
|
- section.cards.each do |card|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
%h2.text-2xl.font-bold.md:text-5xl
|
%h2.text-2xl.font-bold.md:text-5xl
|
||||||
= section.header
|
= section.header
|
||||||
%p.hidden.sm:mt-4.sm:block.text-2xl
|
%p.hidden.sm:mt-4.sm:block.text-2xl
|
||||||
= section.text
|
= markdown(section)
|
||||||
.mt-4.md:mt-8
|
.mt-4.md:mt-8
|
||||||
-if section.has_option?("button_text")
|
-if section.has_option?("button_text")
|
||||||
= render 'merged/view/elements/button' , section: section
|
= render 'merged/view/elements/button' , section: section
|
||||||
|
@ -7,4 +7,4 @@
|
|||||||
%h4.text-xl.mt-10.md:text-2xl
|
%h4.text-xl.mt-10.md:text-2xl
|
||||||
= section.option("subheader")
|
= section.option("subheader")
|
||||||
%p.mt-4.text-lg.pt-10
|
%p.mt-4.text-lg.pt-10
|
||||||
= section.text.html_safe
|
= markdown(section)
|
||||||
|
@ -9,6 +9,4 @@
|
|||||||
.lg:py-16
|
.lg:py-16
|
||||||
%article.space-y-4.text-gray-600
|
%article.space-y-4.text-gray-600
|
||||||
%p
|
%p
|
||||||
= section.text
|
= markdown(section)
|
||||||
%p
|
|
||||||
= section.text
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
%h4.text-xl.mt-10.md:text-2xl
|
%h4.text-xl.mt-10.md:text-2xl
|
||||||
= section.option("subheader")
|
= section.option("subheader")
|
||||||
%p.mt-8.md:block
|
%p.mt-8.md:block
|
||||||
= section.text
|
= markdown(section)
|
||||||
-if section.has_option?("text")
|
-if section.has_option?("text")
|
||||||
%p.mt-8.md:block
|
%p.mt-8.md:block
|
||||||
= section.option("text")
|
= section.option("text")
|
||||||
|
@ -8,4 +8,4 @@
|
|||||||
-if section.has_option?("subheader")
|
-if section.has_option?("subheader")
|
||||||
%h4.text-xl.mt-10.md:text-2xl
|
%h4.text-xl.mt-10.md:text-2xl
|
||||||
= section.option("subheader")
|
= section.option("subheader")
|
||||||
%p.mt-3= section.text
|
%p.mt-3= markdown(section)
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
%h3.text-lg
|
%h3.text-lg
|
||||||
= card.header
|
= card.header
|
||||||
%p.mt-1.text-xs.font-medium
|
%p.mt-1.text-xs.font-medium
|
||||||
= card.text
|
= markdown(card)
|
||||||
|
@ -5,4 +5,4 @@
|
|||||||
%h3.p-4.mt-10.text-3xl.font-bold= card.header
|
%h3.p-4.mt-10.text-3xl.font-bold= card.header
|
||||||
-if card.has_option?("subheader")
|
-if card.has_option?("subheader")
|
||||||
%h4.p-4.text-xl= card.option("subheader")
|
%h4.p-4.text-xl= card.option("subheader")
|
||||||
%p.m-10= card.text
|
%p.m-10= markdown(card)
|
||||||
|
@ -4,4 +4,4 @@
|
|||||||
%h3.p-4.text-2xl.font-bold= card.header
|
%h3.p-4.text-2xl.font-bold= card.header
|
||||||
-if card.has_option?("subheader")
|
-if card.has_option?("subheader")
|
||||||
%h4.p-4.text-xl= card.option("subheader")
|
%h4.p-4.text-xl= card.option("subheader")
|
||||||
%p.mt-2.p-4= card.text
|
%p.mt-2.p-4= markdown(card)
|
||||||
|
@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
|
|||||||
spec.add_dependency "rails", ">= 7.0.4"
|
spec.add_dependency "rails", ">= 7.0.4"
|
||||||
spec.add_dependency "haml-rails"
|
spec.add_dependency "haml-rails"
|
||||||
spec.add_dependency "git"
|
spec.add_dependency "git"
|
||||||
|
spec.add_dependency "redcarpet"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user