gon_helper.rb 1.7 KB
Newer Older
1 2
# rubocop:disable Metrics/AbcSize

3 4
module Gitlab
  module GonHelper
5
    include WebpackHelper
6
    include Gitlab::CurrentSettings
7

8
    def add_gon_variables
S
Sam Rose 已提交
9
      gon.api_version            = 'v4'
D
Douwe Maan 已提交
10
      gon.default_avatar_url     = URI.join(Gitlab.config.gitlab.url, ActionController::Base.helpers.image_path('no_avatar.png')).to_s
11
      gon.max_file_size          = current_application_settings.max_attachment_size
12
      gon.asset_host             = ActionController::Base.asset_host
13
      gon.webpack_public_path    = webpack_public_path
14
      gon.relative_url_root      = Gitlab.config.gitlab.relative_url_root
15
      gon.shortcuts_path         = help_page_path('shortcuts')
16
      gon.user_color_scheme      = Gitlab::ColorSchemes.for_user(current_user).css_class
17 18
      gon.katex_css_url          = ActionController::Base.helpers.asset_path('katex.css')
      gon.katex_js_url           = ActionController::Base.helpers.asset_path('katex.js')
L
Luke "Jared" Bennett 已提交
19
      gon.sentry_dsn             = current_application_settings.clientside_sentry_dsn if current_application_settings.clientside_sentry_enabled
20
      gon.gitlab_url             = Gitlab.config.gitlab.url
21
      gon.revision               = Gitlab::REVISION
22
      gon.gitlab_logo            = ActionController::Base.helpers.asset_path('gitlab_logo.png')
23
      gon.sprite_icons           = IconsHelper.sprite_icon_path
T
Tim Zallmann 已提交
24
      gon.sprite_file_icons      = IconsHelper.sprite_file_icons_path
25 26 27

      if current_user
        gon.current_user_id = current_user.id
C
Clement Ho 已提交
28
        gon.current_username = current_user.username
29
        gon.current_user_fullname = current_user.name
30
        gon.current_user_avatar_url = current_user.avatar_url
31 32 33 34
      end
    end
  end
end