Sha256: 21126126d88e7f0405efeeb6829d1f0ddd0d12e56546d325a9e492fc99959de9
Contents?: true
Size: 581 Bytes
Versions: 1
Compression:
Stored size: 581 Bytes
Contents
Monologue::Post.class_eval do before_validation do if self.new_record? self.is_markdown = true end end def is_markdown? self.is_markdown == true end def content if self.is_markdown? && !in_admin?(caller) pipeline = Content::Pipeline.new return pipeline.filter(read_attribute(:content), markdown: { type: :gfm, safe: false }) end read_attribute(:content) end def in_admin? caller caller.each do |c| return true if c.include? "app/controllers/monologue/admin/posts_controller.rb" end return false end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
monologue-markdown-0.3.0 | app/models/monologue/post_decorator.rb |