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
239 240 241 242 |
# File 'app/models/work_activity.rb', line 239 def body_html text = user_refernces(@work_activity.) mark_down_to_html(text) end |
#mark_down_to_html(text_in) ⇒ Object
244 245 246 247 248 |
# File 'app/models/work_activity.rb', line 244 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
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'app/models/work_activity.rb', line 250 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 |