From cde5e34c233c046dd2f452cc948f736d694ffbf2 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 18 Mar 2019 19:09:28 -0500 Subject: [PATCH] add contentformatterservice --- app/services/content_formatter_service.rb | 2 +- app/views/content/list/_cards.html.erb | 33 ++++++++++++----------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/services/content_formatter_service.rb b/app/services/content_formatter_service.rb index 32a79399..5c20cd97 100644 --- a/app/services/content_formatter_service.rb +++ b/app/services/content_formatter_service.rb @@ -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 diff --git a/app/views/content/list/_cards.html.erb b/app/views/content/list/_cards.html.erb index f63962b4..e419e584 100644 --- a/app/views/content/list/_cards.html.erb +++ b/app/views/content/list/_cards.html.erb @@ -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 %>

@@ -71,19 +71,22 @@ <% end %> -
- <%= link_to new_polymorphic_path(content_type), class: 'white-text' do %> -
-
- - New
- <%= content_type.name %> -
-

- add -

+ <% if current_user.can_create?(content_type) %> +
+ <%# 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 %> +
+
+ + New
+ <%= content_type.name %> +
+

+ add +

+
-
- <% end %> -
+ <% end %> +
+ <% end %>