gon_helper.rb 952 字节
Newer Older
1 2 3
module Gitlab
  module GonHelper
    def add_gon_variables
4
      gon.api_version            = 'v3' # v4 Is not officially released yet, therefore can't be considered as "frozen"
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 7
      gon.max_file_size          = current_application_settings.max_attachment_size
      gon.relative_url_root      = Gitlab.config.gitlab.relative_url_root
8
      gon.shortcuts_path         = help_page_path('shortcuts')
9
      gon.user_color_scheme      = Gitlab::ColorSchemes.for_user(current_user).css_class
10 11
      gon.katex_css_url          = ActionController::Base.helpers.asset_path('katex.css')
      gon.katex_js_url           = ActionController::Base.helpers.asset_path('katex.js')
12 13 14

      if current_user
        gon.current_user_id = current_user.id
C
Clement Ho 已提交
15
        gon.current_username = current_user.username
16 17 18 19
      end
    end
  end
end