Module: CommitFilter::ApplicationHelper
- Defined in:
- app/helpers/commit_filter/application_helper.rb
Instance Method Summary collapse
- #annotate_file_link(text, rev, path, options = {}) ⇒ Object
- #form_field(*args, &block) ⇒ Object
- #message_with_issue_urls(message) ⇒ Object
- #path_id(path) ⇒ Object
- #version_control_diff_link(path, rev) ⇒ Object
Instance Method Details
#annotate_file_link(text, rev, path, options = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/helpers/commit_filter/application_helper.rb', line 47 def annotate_file_link(text, rev, path, = {}) url = if @filter.repository_provider == 'GitHub' "https://github.com/#{@filter.user_or_organization}/#{@filter.repository}/blame/#{rev}/#{path}" elsif @filter.repository_provider == 'plan.io' "#{@filter.repository_host}/projects/#{@filter.project_slug}/repository/revisions/#{rev}/annotate/#{path}" end text += " (your provider is not supported)" unless url.present? url = '#' unless url.present? link_to text, url, target: '_blank' end |
#form_field(*args, &block) ⇒ Object
3 4 5 |
# File 'app/helpers/commit_filter/application_helper.rb', line 3 def form_field(*args, &block) framework_presenter.form_field *args, &block end |
#message_with_issue_urls(message) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/commit_filter/application_helper.rb', line 11 def () if @filter.repository_provider == 'GitHub' @filter.issue_url = "https://github.com/#{@filter.user_or_organization}/#{@filter.repository}/issues/:id" end if @filter.issue_url.present? .gsub(/#([0-9]+)/) do |s| issue_url = @filter.issue_url.split(':id') s = s.gsub('#', '') issue_url = "#{issue_url[0]}#{s}#{issue_url[1]}" "<a href=\"#{issue_url}\">##{s}</a>" end else end end |
#path_id(path) ⇒ Object
7 8 9 |
# File 'app/helpers/commit_filter/application_helper.rb', line 7 def path_id(path) path.gsub(/\/|\./, '_') end |
#version_control_diff_link(path, rev) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/commit_filter/application_helper.rb', line 28 def version_control_diff_link(path, rev) rev = params['rev'] || rev rev_to = params['rev_to'] || @filter.previous_revision_by_file[path] url = if rev == rev_to nil else "#{new_commit_diff_path}?repository_path=#{@filter.repository_path}&path=#{path}&rev=#{rev}&rev_to=#{rev_to}" end text = t('commit_filter.general.diff') if url.present? link_to text, url, class: 'diff commit_filter_diff_link' else text end end |