gon_helper.rb 1.2 KB
Newer Older
1 2 3
module Gitlab
  module GonHelper
    def add_gon_variables
S
Sam Rose 已提交
4
      gon.api_version            = 'v4'
D
Douwe Maan 已提交
5
      gon.default_avatar_url     = URI.join(Gitlab.config.gitlab.url, ActionController::Base.helpers.image_path('no_avatar.png')).to_s
6
      gon.max_file_size          = current_application_settings.max_attachment_size
7
      gon.asset_host             = ActionController::Base.asset_host
8
      gon.relative_url_root      = Gitlab.config.gitlab.relative_url_root
9
      gon.shortcuts_path         = help_page_path('shortcuts')
10
      gon.user_color_scheme      = Gitlab::ColorSchemes.for_user(current_user).css_class
11 12
      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 已提交
13
      gon.sentry_dsn             = current_application_settings.clientside_sentry_dsn if current_application_settings.clientside_sentry_enabled
14
      gon.gitlab_url             = Gitlab.config.gitlab.url
15 16 17

      if current_user
        gon.current_user_id = current_user.id
C
Clement Ho 已提交
18
        gon.current_username = current_user.username
19
        gon.current_user_fullname = current_user.name
20 21 22 23
      end
    end
  end
end