Commit 13fec18ac9cbdecdef3b0e5fb7dd7480e9d7cbbf

Authored by Dmitriy Zaporozhets
1 parent c9f741bb

Truncate some text from dashboard events

app/helpers/application_helper.rb
@@ -235,4 +235,11 @@ module ApplicationHelper @@ -235,4 +235,11 @@ module ApplicationHelper
235 "Search" 235 "Search"
236 end 236 end
237 end 237 end
  238 +
  239 + def first_line(str)
  240 + lines = str.split("\n")
  241 + line = lines.first
  242 + line += "..." if lines.size > 1
  243 + line
  244 + end
238 end 245 end
app/helpers/events_helper.rb
@@ -123,6 +123,8 @@ module EventsHelper @@ -123,6 +123,8 @@ module EventsHelper
123 end 123 end
124 124
125 def event_note(text) 125 def event_note(text)
126 - sanitize(markdown(truncate(text, length: 150)), tags: %w(a img b pre p)) 126 + text = first_line(text)
  127 + text = truncate(text, length: 150)
  128 + sanitize(markdown(text), tags: %w(a img b pre p))
127 end 129 end
128 end 130 end
app/views/events/event/_push.html.haml
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 %strong= event.ref_name 5 %strong= event.ref_name
6 - else 6 - else
7 = link_to project_commits_path(event.project, event.ref_name) do 7 = link_to project_commits_path(event.project, event.ref_name) do
8 - %strong= event.ref_name 8 + %strong= truncate(event.ref_name, length: 30)
9 at 9 at
10 %strong= link_to_project event.project 10 %strong= link_to_project event.project
11 11