BigW Consortium Gitlab

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

3 4
module Gitlab
  module GonHelper
5 6
    include WebpackHelper

7
    def add_gon_variables
8
      gon.api_version            = 'v4'
9
      gon.default_avatar_url     = URI.join(Gitlab.config.gitlab.url, ActionController::Base.helpers.image_path('no_avatar.png')).to_s
10
      gon.max_file_size          = Gitlab::CurrentSettings.max_attachment_size
11
      gon.asset_host             = ActionController::Base.asset_host
12
      gon.webpack_public_path    = webpack_public_path
13
      gon.relative_url_root      = Gitlab.config.gitlab.relative_url_root
14
      gon.shortcuts_path         = help_page_path('shortcuts')
15
      gon.user_color_scheme      = Gitlab::ColorSchemes.for_user(current_user).css_class
16 17
      gon.katex_css_url          = ActionController::Base.helpers.asset_path('katex.css')
      gon.katex_js_url           = ActionController::Base.helpers.asset_path('katex.js')
18
      gon.sentry_dsn             = Gitlab::CurrentSettings.clientside_sentry_dsn if Gitlab::CurrentSettings.clientside_sentry_enabled
19
      gon.gitlab_url             = Gitlab.config.gitlab.url
20
      gon.revision               = Gitlab::REVISION
21
      gon.gitlab_logo            = ActionController::Base.helpers.asset_path('gitlab_logo.png')
22
      gon.sprite_icons           = IconsHelper.sprite_icon_path
23
      gon.sprite_file_icons      = IconsHelper.sprite_file_icons_path
24 25 26

      if current_user
        gon.current_user_id = current_user.id
Clement Ho committed
27
        gon.current_username = current_user.username
28
        gon.current_user_fullname = current_user.name
29
        gon.current_user_avatar_url = current_user.avatar_url
30 31 32 33
      end
    end
  end
end