Class: WorkActivity::BaseMessage
- Defined in:
- app/models/work_activity.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Renderer
Renderer::DATE_FORMAT, Renderer::DATE_TIME_FORMAT, Renderer::SORTABLE_DATE_TIME_FORMAT, Renderer::UNKNOWN_USER
Instance Method Summary collapse
Methods inherited from Renderer
#created_by_user_html, #created_sortable_html, #created_updated_html, #initialize, #title_html, #to_html
Constructor Details
This class inherits a constructor from WorkActivity::Renderer
Instance Method Details
#body_html ⇒ Object
265 266 267 268 |
# File 'app/models/work_activity.rb', line 265 def body_html text = user_refernces(@work_activity.) mark_down_to_html(text) end |
#mark_down_to_html(text_in) ⇒ Object
270 271 272 273 274 |
# File 'app/models/work_activity.rb', line 270 def mark_down_to_html(text_in) # allow ``` for code blocks (Kramdown only supports ~~~) text = text_in.gsub("```", "~~~") Kramdown::Document.new(text).to_html end |
#user_refernces(text_in) ⇒ Object
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'app/models/work_activity.rb', line 276 def user_refernces(text_in) # convert user references to user links text_in.gsub(USER_REFERENCE) do |at_uid| uid = at_uid[1..-1] if uid group = Group.find_by(code: uid) if group "<a class='message-user-link' title='#{group.title}' href='#{@work_activity.group_path(group)}'>#{group.title}</a>" else user = User.find_by(uid:) user_info = if user user.given_name_safe else uid end "<a class='message-user-link' title='#{user_info}' href='#{@work_activity.users_path}/#{uid}'>#{at_uid}</a>" end else Rails.logger.warn("Failed to extract the user ID from #{uid}") UNKNOWN_USER end end end |