add contentformatterservice

This commit is contained in:
Andrew Brown 2019-03-18 19:09:28 -05:00
parent 11e82ebf95
commit cde5e34c23
2 changed files with 19 additions and 16 deletions

View File

@ -20,7 +20,7 @@ class ContentFormatterService < Service
def self.show(text:, viewing_user: User.new)
# We want to evaluate markdown first, because the markdown engine also happens
# to strip out HTML tags. So: markdown, _then_ insert content links.
formatted_text = markdown.render(text).html_safe
formatted_text = markdown.render(text || '').html_safe
substitute_content_links(formatted_text, viewing_user).html_safe
end

View File

@ -20,7 +20,7 @@
<% if content.is_a?(Document) %>
<%= content.reading_estimate %>
<% else %>
<%= content.description %>
<%= ContentFormatterService.show(text: content.description, viewing_user: current_user) %>
<% end %>
</p>
</div>
@ -71,19 +71,22 @@
</div>
<% end %>
<div class="col s12 m4 l4">
<%= link_to new_polymorphic_path(content_type), class: 'white-text' do %>
<div class="card <%= content_type.color %> lighten-1" style="height: 440px;">
<div class="card-content fixed-card-content centered-card-content">
<strong class="card-title">
New<br />
<%= content_type.name %>
</strong>
<p>
<i class="material-icons large">add</i>
</p>
<% if current_user.can_create?(content_type) %>
<div class="col s12 m4 l4">
<%# TODO: We really need to fix up the new document path so we don't have weird overrides like this %>
<%= link_to content_type == Document ? edit_document_path(:new) : new_polymorphic_path(content_type), class: 'white-text' do %>
<div class="card <%= content_type.color %> lighten-1" style="height: 440px;">
<div class="card-content fixed-card-content centered-card-content">
<strong class="card-title">
New<br />
<%= content_type.name %>
</strong>
<p>
<i class="material-icons large">add</i>
</p>
</div>
</div>
</div>
<% end %>
</div>
<% end %>
</div>
<% end %>
</div>