diff options
author | Riyad Preukschas <riyad@informatik.uni-bremen.de> | 2012-12-23 04:03:57 +0400 |
---|---|---|
committer | Riyad Preukschas <riyad@informatik.uni-bremen.de> | 2012-12-23 04:03:57 +0400 |
commit | db2c15369c365340aeaf4e431e8838714b40396b (patch) | |
tree | 26ca045a337132370b67cc8f2ed4010e3087dfa5 /app/helpers | |
parent | b47173da6a0fea0982d009f91e2c4d042f9b5c37 (diff) | |
parent | 68c43d59f09a66cca0da1b9a50c11421d52eac9a (diff) |
Merge branch 'master' into discussions
Conflicts:
app/assets/stylesheets/main.scss
app/models/project.rb
app/views/notes/_common_form.html.haml
app/views/notes/_per_line_form.html.haml
lib/gitlab/markdown.rb
spec/models/note_spec.rb
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/application_helper.rb | 14 | ||||
-rw-r--r-- | app/helpers/issues_helper.rb | 32 | ||||
-rw-r--r-- | app/helpers/merge_requests_helper.rb | 26 | ||||
-rw-r--r-- | app/helpers/projects_helper.rb | 42 | ||||
-rw-r--r-- | app/helpers/tab_helper.rb | 2 |
5 files changed, 62 insertions, 54 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a689213bcee..52715a265bd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,4 +1,5 @@ require 'digest/md5' +require 'uri' module ApplicationHelper @@ -30,13 +31,15 @@ module ApplicationHelper args.any? { |v| v.to_s.downcase == action_name } end - def gravatar_icon(user_email = '', size = 40) - if Gitlab.config.disable_gravatar? || user_email.blank? + def gravatar_icon(user_email = '', size = nil) + size = 40 if size.nil? || size <= 0 + + if !Gitlab.config.gravatar.enabled || user_email.blank? 'no_avatar.png' else - gravatar_prefix = request.ssl? ? "https://secure" : "http://www" + gravatar_url = request.ssl? ? Gitlab.config.gravatar.ssl_url : Gitlab.config.gravatar.plain_url user_email.strip! - "#{gravatar_prefix}.gravatar.com/avatar/#{Digest::MD5.hexdigest(user_email.downcase)}?s=#{size}&d=mm" + sprintf(gravatar_url, {:hash => Digest::MD5.hexdigest(user_email.downcase), :email => URI.escape(user_email), :size => size}) end end @@ -45,7 +48,7 @@ module ApplicationHelper end def web_app_url - "#{request_protocol}://#{Gitlab.config.web_host}/" + "#{request_protocol}://#{Gitlab.config.gitlab.host}/" end def last_commit(project) @@ -92,6 +95,7 @@ module ApplicationHelper { label: "API Help", url: help_api_path }, { label: "Markdown Help", url: help_markdown_path }, { label: "SSH Keys Help", url: help_ssh_path }, + { label: "Gitlab Rake Tasks Help", url: help_raketasks_path }, ] project_nav = [] diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 99ea9ef2975..2825787fd2f 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -4,28 +4,6 @@ module IssuesHelper project_issues_path project, params end - def link_to_issue_assignee(issue) - project = issue.project - - tm = project.team_member_by_id(issue.assignee_id) - if tm - link_to issue.assignee_name, project_team_member_path(project, tm), class: "author_link" - else - issue.assignee_name - end - end - - def link_to_issue_author(issue) - project = issue.project - - tm = project.team_member_by_id(issue.author_id) - if tm - link_to issue.author_name, project_team_member_path(project, tm), class: "author_link" - else - issue.author_name - end - end - def issue_css_classes issue classes = "issue" classes << " closed" if issue.closed @@ -52,4 +30,14 @@ module IssuesHelper open: "open" } end + + def labels_autocomplete_source + labels = @project.issues_labels.order('count DESC') + labels = labels.map{ |l| { label: l.name, value: l.name } } + labels.to_json + end + + def issues_active_milestones + @project.milestones.active.order("id desc").all + end end diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index b23c4a8f0df..f48425bd6de 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -1,26 +1,4 @@ module MergeRequestsHelper - def link_to_merge_request_assignee(merge_request) - project = merge_request.project - - tm = project.team_member_by_id(merge_request.assignee_id) - if tm - link_to merge_request.assignee_name, project_team_member_path(project, tm), class: "author_link" - else - merge_request.assignee_name - end - end - - def link_to_merge_request_author(merge_request) - project = merge_request.project - - tm = project.team_member_by_id(merge_request.author_id) - if tm - link_to merge_request.author_name, project_team_member_path(project, tm), class: "author_link" - else - merge_request.author_name - end - end - def new_mr_path_from_push_event(event) new_project_merge_request_path( event.project, @@ -39,7 +17,7 @@ module MergeRequestsHelper classes end - def ci_status_path - @project.gitlab_ci_service.commit_badge_path(@merge_request.last_commit.sha) + def ci_build_details_path merge_request + merge_request.project.gitlab_ci_service.build_page(merge_request.last_commit.sha) end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 7c302ef4176..425dd471b36 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -8,11 +8,49 @@ module ProjectsHelper end def link_to_project project - link_to project.name, project + link_to project do + title = content_tag(:strong, project.name) + + if project.namespace + namespace = content_tag(:span, "#{project.namespace.human_name} / ", class: 'tiny') + title = namespace + title + end + + title + end + end + + def link_to_member(project, author) + return "(deleted)" unless author + + # Build avatar image tag + avatar = image_tag(gravatar_icon(author.try(:email)), width: 16, class: "lil_av") + + # Build name strong tag + name = content_tag :strong, author.name, class: 'author' + + author_html = avatar + name + + tm = project.team_member_by_id(author) + + content_tag :span, class: 'member-link' do + if tm + link_to author_html, project_team_member_path(project, tm), class: "author_link" + else + author_html + end + end end def tm_path team_member project_team_member_path(@project, team_member) end -end + def project_title project + if project.group + project.name_with_namespace + else + project.name + end + end +end diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index a4bec87caa7..d52d8af6641 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -72,7 +72,7 @@ module TabHelper return "active" if current_page?(controller: "projects", action: action, id: @project) end - if ['snippets', 'hooks', 'deploy_keys', 'team_members'].include? controller.controller_name + if ['snippets', 'services', 'hooks', 'deploy_keys', 'team_members'].include? controller.controller_name "active" end end |