diff options
author | jakeburden <jburden@gitlab.com> | 2019-08-31 01:16:39 +0300 |
---|---|---|
committer | jakeburden <jburden@gitlab.com> | 2019-09-03 23:40:38 +0300 |
commit | 90dc19e9f0be8ac530b5e5e042791143ce0ba0ce (patch) | |
tree | d29578ef53dea5faefb39eaddf7157d6a664e417 /app | |
parent | 5c25a757dcdeb9aae38744ed8b43832ff51e3dcb (diff) |
Create and use external_link helper
Creates a helper method that takes body text and a url.
The output is a external link with icon.
It contains the noopenner noreferrer attributes for security.
Usage: external_link(domain.title, domain.url)
Add rspec test for ExternalLinkHelper
Add changelog for MR 32130
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/external_link_helper.rb | 9 | ||||
-rw-r--r-- | app/views/projects/pages/_access.html.haml | 8 | ||||
-rw-r--r-- | app/views/projects/pages/_list.html.haml | 4 | ||||
-rw-r--r-- | app/views/projects/pages_domains/show.html.haml | 4 |
4 files changed, 13 insertions, 12 deletions
diff --git a/app/helpers/external_link_helper.rb b/app/helpers/external_link_helper.rb new file mode 100644 index 00000000000..fe908b3ae1c --- /dev/null +++ b/app/helpers/external_link_helper.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module ExternalLinkHelper + def external_link(body, url) + link_to url, target: '_blank', rel: 'noopener noreferrer' do + "#{body} #{icon('external-link')}".html_safe + end + end +end diff --git a/app/views/projects/pages/_access.html.haml b/app/views/projects/pages/_access.html.haml index a5ea15b2934..7b6d46964a2 100644 --- a/app/views/projects/pages/_access.html.haml +++ b/app/views/projects/pages/_access.html.haml @@ -8,14 +8,10 @@ = _("Your pages are served under:") %p - = link_to @project.pages_url, target: '_blank', rel: 'noopener noreferrer' do - = @project.pages_url - = icon('external-link') + = external_link(@project.pages_url, @project.pages_url) - @project.pages_domains.each do |domain| %p - = link_to domain.url, target: '_blank', rel: 'noopener noreferrer' do - = domain.url - = icon('external-link') + = external_link(domain.url, domain.url) .card-footer.alert-primary = _("It may take up to 30 minutes before the site is available after the first deployment.") diff --git a/app/views/projects/pages/_list.html.haml b/app/views/projects/pages/_list.html.haml index 4f16110c5c9..c4285e7f3d2 100644 --- a/app/views/projects/pages/_list.html.haml +++ b/app/views/projects/pages/_list.html.haml @@ -12,9 +12,7 @@ .domain-status.ci-status-icon.has-tooltip{ class: "ci-status-icon-#{status}", title: tooltip } = sprite_icon("status_#{status}", size: 16 ) .domain-name - = link_to domain.url, target: '_blank', rel: 'noopener noreferrer' do - = domain.url - = icon('external-link') + = external_link(domain.url, domain.url) - if domain.subject %div %span.badge.badge-gray Certificate: #{domain.subject} diff --git a/app/views/projects/pages_domains/show.html.haml b/app/views/projects/pages_domains/show.html.haml index 3351da7f81f..33837e21c8d 100644 --- a/app/views/projects/pages_domains/show.html.haml +++ b/app/views/projects/pages_domains/show.html.haml @@ -21,9 +21,7 @@ %td = _("Domain") %td - = link_to @domain.url, target: :_blank, rel: 'noopener noreferrer' do - = @domain.url - = icon('external-link') + = external_link(@domain.url, @domain.url) %tr %td = _("DNS") |