Merge branch 'first-meaningful-line-in-md' of https://github.com/yglukhov/gitlabhq into 7-4-pre

This commit is contained in:
Dmitriy Zaporozhets 2014-09-17 21:37:34 +03:00
commit 4a21db82ec
3 changed files with 9 additions and 8 deletions

View file

@ -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

View file

@ -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

View file

@ -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)