Compare commits
1 commit
d2d7d0c4f9
...
1419827f66
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1419827f66 |
7 changed files with 27 additions and 10 deletions
2
Gemfile
2
Gemfile
|
|
@ -128,4 +128,4 @@ group :test do
|
|||
gem 'hashie', '~> 3.4.6', require: false # https://github.com/westfieldlabs/apivore/issues/114
|
||||
end
|
||||
|
||||
gem "redcarpet", "~> 3.6"
|
||||
gem "redcarpet"
|
||||
|
|
|
|||
|
|
@ -653,7 +653,7 @@ DEPENDENCIES
|
|||
rails_tokeninput
|
||||
ransack
|
||||
recurring_select!
|
||||
redcarpet (~> 3.6)
|
||||
redcarpet
|
||||
resque
|
||||
roo
|
||||
roo-xls
|
||||
|
|
|
|||
|
|
@ -263,4 +263,26 @@ module ApplicationHelper
|
|||
stylesheet_link_tag foodcoop_css_path, media: 'all'
|
||||
end
|
||||
end
|
||||
|
||||
# renders html from markdown input
|
||||
def markdown(text)
|
||||
options = {
|
||||
filter_html: true,
|
||||
hard_wrap: true,
|
||||
link_attributes: { rel: 'nofollow', target: "_blank" },
|
||||
fenced_code_blocks: true
|
||||
}
|
||||
extensions = {
|
||||
autolink: true,
|
||||
superscript: true,
|
||||
disable_indented_code_blocks: true,
|
||||
tables: true,
|
||||
strikethrough: true,
|
||||
footnotes: true
|
||||
}
|
||||
|
||||
renderer = ::Redcarpet::Render::HTML.new(options)
|
||||
markdown = ::Redcarpet::Markdown.new(renderer, extensions)
|
||||
markdown.render(text).html_safe
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -132,11 +132,6 @@ class Message < ApplicationRecord
|
|||
user.role_admin?
|
||||
end
|
||||
|
||||
def render_markdown
|
||||
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true, strikethrough: true, footnotes: true)
|
||||
return markdown.render(body)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_salt
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
- if @message.can_toggle_private?(current_user)
|
||||
= link_to t('.change_visibility'), toggle_private_message_path(@message), method: :post, class: 'btn btn-mini'
|
||||
%hr/
|
||||
= raw @message.render_markdown
|
||||
= markdown(@message.body)
|
||||
%hr/
|
||||
%p
|
||||
= link_to t('.reply'), new_message_path(:message => {:reply_to => @message.id}), class: 'btn'
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
.panel-heading
|
||||
%b= h(message.sender_name)
|
||||
= format_time(message.created_at)
|
||||
.panel-body= simple_format(h(message.body))
|
||||
.panel-body= markdown(message.body)
|
||||
|
||||
%p
|
||||
= link_to t('.reply'), new_message_path(:message => {:reply_to => thread_message.id}), class: 'btn'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
= raw @message.render_markdown
|
||||
= markdown(@message.body)
|
||||
%hr/
|
||||
%pre
|
||||
- if @message.group
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue