Class: PreviewMarkdownService

Inherits:
BaseContainerService show all
Defined in:
app/services/preview_markdown_service.rb

Overview

Extracts any quick actions from the text, find any users or suggestions. If a block is provided, then it should return rendered HTML from the Banzai pipeline. If there is no block, then the act of finding users will cause the the pipeline to be invoked.

Instance Attribute Summary

Attributes inherited from BaseContainerService

#container, #current_user, #group, #params, #project

Instance Method Summary collapse

Methods inherited from BaseContainerService

#group_container?, #initialize, #namespace_container?, #project_container?, #project_group, #root_ancestor

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

This class inherits a constructor from BaseContainerService

Instance Method Details

#execute(&block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/preview_markdown_service.rb', line 8

def execute(&block)
  text, commands = explain_quick_actions(params[:text])
  @rendered_html = yield(text) if block
  users = find_user_references(text)
  suggestions = find_suggestions(text)

  success(
    text: text,
    rendered_html: @rendered_html,
    users: users,
    suggestions: suggestions,
    commands: commands.join('<br>')
  )
end