diff options
author | Phil Hughes <me@iamphill.com> | 2017-05-25 11:17:31 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-05-25 11:17:31 +0100 |
commit | f452cb7733c1659c5c8de7f2b9fa7bc2bf077db7 (patch) | |
tree | 871761544b2c753075a0fb064579b4710eebd8ed /app/helpers | |
parent | 2ef6172db03343772ba56558f695750d25ddc562 (diff) | |
parent | 6ece9792666d5ac8670b4c275c42c6ec8998322d (diff) | |
download | gitlab-ce-f452cb7733c1659c5c8de7f2b9fa7bc2bf077db7.tar.gz |
Merge branch 'master' into issue-edit-inline
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/application_helper.rb | 18 | ||||
-rw-r--r-- | app/helpers/blob_helper.rb | 23 | ||||
-rw-r--r-- | app/helpers/commits_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/icons_helper.rb | 7 | ||||
-rw-r--r-- | app/helpers/markup_helper.rb | 3 | ||||
-rw-r--r-- | app/helpers/preferences_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/rss_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/system_note_helper.rb | 3 |
8 files changed, 50 insertions, 10 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 97cf4863ddc..e5e64650708 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -278,4 +278,22 @@ module ApplicationHelper def show_user_callout? cookies[:user_callout_dismissed] == 'true' end + + def linkedin_url(user) + name = user.linkedin + if name =~ %r{\Ahttps?:\/\/(www\.)?linkedin\.com\/in\/} + name + else + "https://www.linkedin.com/in/#{name}" + end + end + + def twitter_url(user) + name = user.twitter + if name =~ %r{\Ahttps?:\/\/(www\.)?twitter\.com\/} + name + else + "https://www.twitter.com/#{name}" + end + end end diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index eb37f2e0267..622e14e21ff 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -226,7 +226,7 @@ module BlobHelper def open_raw_blob_button(blob) return if blob.empty? - + if blob.raw_binary? || blob.stored_externally? icon = icon('download') title = 'Download' @@ -242,9 +242,9 @@ module BlobHelper case viewer.render_error when :too_large max_size = - if viewer.absolutely_too_large? - viewer.absolute_max_size - elsif viewer.too_large? + if viewer.can_override_max_size? + viewer.overridable_max_size + else viewer.max_size end "it is larger than #{number_to_human_size(max_size)}" @@ -278,4 +278,19 @@ module BlobHelper options end + + def contribution_options(project) + options = [] + + if can?(current_user, :create_issue, project) + options << link_to("submit an issue", new_namespace_project_issue_path(project.namespace, project)) + end + + merge_project = can?(current_user, :create_merge_request, project) ? project : (current_user && current_user.fork_of(project)) + if merge_project + options << link_to("create a merge request", new_namespace_project_merge_request_path(project.namespace, project)) + end + + options + end end diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 6d6f1361bf9..d59d51905a6 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -91,7 +91,7 @@ module CommitsHelper end def link_to_browse_code(project, commit) - return unless current_controller?(:projects, :commits) + return unless current_controller?(:commits) if @path.blank? return link_to( diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 55fa81e95ef..f29faeca22d 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -7,9 +7,10 @@ module IconsHelper # font-awesome-rails gem, but should we ever use a different icon pack in the # future we won't have to change hundreds of method calls. def icon(names, options = {}) - if (options.keys & %w[aria-hidden aria-label]).empty? - # Add `aria-hidden` if there are no aria's set + if (options.keys & %w[aria-hidden aria-label data-hidden]).empty? + # Add 'aria-hidden' and 'data-hidden' if they are not set in options. options['aria-hidden'] = true + options['data-hidden'] = true end options.include?(:base) ? fa_stacked_icon(names, options) : fa_icon(names, options) @@ -19,6 +20,8 @@ module IconsHelper case names when "standard" names = "key" + when "two-factor" + names = "key" end options.include?(:base) ? fa_stacked_icon(names, options) : fa_icon(names, options) diff --git a/app/helpers/markup_helper.rb b/app/helpers/markup_helper.rb index 0009cad86c4..941cfce8370 100644 --- a/app/helpers/markup_helper.rb +++ b/app/helpers/markup_helper.rb @@ -1,6 +1,9 @@ require 'nokogiri' module MarkupHelper + include ActionView::Helpers::TagHelper + include ActionView::Context + def plain?(filename) Gitlab::MarkupHelper.plain?(filename) end diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb index de959f13713..d36bb4ab074 100644 --- a/app/helpers/preferences_helper.rb +++ b/app/helpers/preferences_helper.rb @@ -49,7 +49,7 @@ module PreferencesHelper user_view = current_user.project_view - if @project.feature_available?(:repository, current_user) + if can?(current_user, :download_code, @project) user_view elsif user_view == "activity" "activity" diff --git a/app/helpers/rss_helper.rb b/app/helpers/rss_helper.rb index ea5d2932ef4..9ac4df88dc3 100644 --- a/app/helpers/rss_helper.rb +++ b/app/helpers/rss_helper.rb @@ -1,5 +1,5 @@ module RssHelper def rss_url_options - { format: :atom, private_token: current_user.try(:private_token) } + { format: :atom, rss_token: current_user.try(:rss_token) } end end diff --git a/app/helpers/system_note_helper.rb b/app/helpers/system_note_helper.rb index d889d141101..209bd56b78a 100644 --- a/app/helpers/system_note_helper.rb +++ b/app/helpers/system_note_helper.rb @@ -17,7 +17,8 @@ module SystemNoteHelper 'visible' => 'icon_eye', 'milestone' => 'icon_clock_o', 'discussion' => 'icon_comment_o', - 'moved' => 'icon_arrow_circle_o_right' + 'moved' => 'icon_arrow_circle_o_right', + 'outdated' => 'icon_edit' }.freeze def icon_for_system_note(note) |