From 02eca79ef1e7925b85e0919cdaab8c85ff8c916a Mon Sep 17 00:00:00 2001 From: uran Date: Fri, 12 Sep 2014 13:45:00 +0300 Subject: [PATCH] Changed activity notes to display first MEANINGFUL line. --- app/helpers/application_helper.rb | 7 ------- app/helpers/events_helper.rb | 2 +- app/helpers/gitlab_markdown_helper.rb | 8 ++++++++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c2c9301cc17..07938b8065d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -187,13 +187,6 @@ module ApplicationHelper end end - def first_line(str) - lines = str.split("\n") - line = lines.first - line += "..." if lines.size > 1 - line - end - def broadcast_message BroadcastMessage.current end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index a4f93689a7b..6f738764b0e 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -136,7 +136,7 @@ module EventsHelper end def event_note(text) - text = first_line(text) + text = first_line_in_markdown(text) text = truncate(text, length: 150) sanitize(markdown(text), tags: %w(a img b pre p)) end diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index e4aa90154fb..d269323542f 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -51,6 +51,14 @@ module GitlabMarkdownHelper @markdown.render(text).html_safe end + def first_line_in_markdown(text) + line = text.split("\n").detect do |i| + i.present? && markdown(i).present? + end + line += '...' unless line.nil? + line + end + def render_wiki_content(wiki_page) if wiki_page.format == :markdown markdown(wiki_page.content)