summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorVinnie Okada <vokada@mrvinn.com>2015-02-19 20:53:05 -0700
committerVinnie Okada <vokada@mrvinn.com>2015-02-19 20:53:05 -0700
commit9e9ce95d62ec4feb76c3ec238dd3189c781f40ce (patch)
tree28939e566ce29a278cd7ae15e37266aa6a16a17c /app/helpers
parent76aad9b76ed756ca9ba2cbcdb399c815e542b3ae (diff)
parentde040ffaaef4ad5ebd93b3f7a237add438dbddd5 (diff)
downloadgitlab-ce-9e9ce95d62ec4feb76c3ec238dd3189c781f40ce.tar.gz
Merge branch 'master' into rails-4.1.9
Conflicts: app/views/dashboard/_project.html.haml app/views/events/event/_common.html.haml app/views/explore/projects/_project.html.haml app/views/groups/_projects.html.haml app/views/projects/_home_panel.html.haml app/views/projects/_issues_nav.html.haml app/views/projects/issues/_discussion.html.haml app/views/projects/issues/_issues.html.haml app/views/projects/issues/show.html.haml app/views/projects/merge_requests/_discussion.html.haml app/views/projects/merge_requests/_show.html.haml app/views/projects/milestones/index.html.haml app/views/projects/notes/_edit_form.html.haml app/views/shared/_issuable_filter.html.haml
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb8
-rw-r--r--app/helpers/application_settings_helper.rb4
-rw-r--r--app/helpers/blob_helper.rb2
-rw-r--r--app/helpers/events_helper.rb53
-rw-r--r--app/helpers/gitlab_markdown_helper.rb9
5 files changed, 49 insertions, 27 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index c3c77d9880f..365de3595cd 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -51,7 +51,13 @@ module ApplicationHelper
end
def project_icon(project_id, options = {})
- project = Project.find_with_namespace(project_id)
+ project =
+ if project_id.is_a?(Project)
+ project = project_id
+ else
+ Project.find_with_namespace(project_id)
+ end
+
if project.avatar.present?
image_tag project.avatar.url, options
elsif project.avatar_in_git
diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb
index 04299316102..1ee086da997 100644
--- a/app/helpers/application_settings_helper.rb
+++ b/app/helpers/application_settings_helper.rb
@@ -3,6 +3,10 @@ module ApplicationSettingsHelper
current_application_settings.gravatar_enabled?
end
+ def twitter_sharing_enabled?
+ current_application_settings.twitter_sharing_enabled?
+ end
+
def signup_enabled?
current_application_settings.signup_enabled?
end
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index f5f27223d5b..798d62b3a09 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -17,7 +17,7 @@ module BlobHelper
end
def no_highlight_files
- %w(credits changelog copying copyright license authors)
+ %w(credits changelog news copying copyright license authors)
end
def edit_blob_link(project, ref, path, options = {})
diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb
index 6e7aa521302..063916a8df8 100644
--- a/app/helpers/events_helper.rb
+++ b/app/helpers/events_helper.rb
@@ -10,11 +10,15 @@ module EventsHelper
end
def event_action_name(event)
- target = if event.target_type
- event.target_type.titleize.downcase
- else
- 'project'
- end
+ target = if event.target_type
+ if event.note?
+ event.note_target_type
+ else
+ event.target_type.titleize.downcase
+ end
+ else
+ 'project'
+ end
[event.action_name, target].join(" ")
end
@@ -42,21 +46,30 @@ module EventsHelper
end
def event_feed_title(event)
- if event.issue?
- "#{event.author_name} #{event.action_name} issue ##{event.target_iid}: #{event.issue_title} at #{event.project_name}"
- elsif event.merge_request?
- "#{event.author_name} #{event.action_name} MR ##{event.target_iid}: #{event.merge_request_title} at #{event.project_name}"
- elsif event.push?
- "#{event.author_name} #{event.push_action_name} #{event.ref_type} #{event.ref_name} at #{event.project_name}"
- elsif event.membership_changed?
- "#{event.author_name} #{event.action_name} #{event.project_name}"
- elsif event.note? && event.note_commit?
- "#{event.author_name} commented on #{event.note_target_type} #{event.note_short_commit_id} at #{event.project_name}"
- elsif event.note?
- "#{event.author_name} commented on #{event.note_target_type} ##{truncate event.note_target_iid} at #{event.project_name}"
- else
- ""
+ words = []
+ words << event.author_name
+ words << event_action_name(event)
+
+ if event.push?
+ words << event.ref_type
+ words << event.ref_name
+ words << "at"
+ elsif event.commented?
+ if event.note_commit?
+ words << event.note_short_commit_id
+ else
+ words << "##{truncate event.note_target_iid}"
+ end
+ words << "at"
+ elsif event.target
+ words << "##{event.target_iid}:"
+ words << event.target.title if event.target.respond_to?(:title)
+ words << "at"
end
+
+ words << event.project_name
+
+ words.join(" ")
end
def event_feed_url(event)
@@ -106,8 +119,6 @@ module EventsHelper
render "events/event_push", event: event
elsif event.merge_request?
render "events/event_merge_request", merge_request: event.merge_request
- elsif event.push?
- render "events/event_push", event: event
elsif event.note?
render "events/event_note", note: event.note
end
diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb
index 800cacdc2c2..ab30f498c01 100644
--- a/app/helpers/gitlab_markdown_helper.rb
+++ b/app/helpers/gitlab_markdown_helper.rb
@@ -110,7 +110,7 @@ module GitlabMarkdownHelper
end
def link_to_ignore?(link)
- if link =~ /\#\w+/
+ if link =~ /\A\#\w+/
# ignore anchors like <a href="#my-header">
true
else
@@ -122,10 +122,11 @@ module GitlabMarkdownHelper
["http://","https://", "ftp://", "mailto:"]
end
- def rebuild_path(path)
- path.gsub!(/(#.*)/, "")
+ def rebuild_path(file_path)
+ file_path = file_path.dup
+ file_path.gsub!(/(#.*)/, "")
id = $1 || ""
- file_path = relative_file_path(path)
+ file_path = relative_file_path(file_path)
file_path = sanitize_slashes(file_path)
[