diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2017-05-08 15:23:22 +0200 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2017-05-08 15:23:22 +0200 |
commit | d6697e0b4d5d9c1437b57b2307464c93d3c66c66 (patch) | |
tree | 211684e2fc8d5c6b4a134414350836cbdab41bf9 | |
parent | d5049022a77a84bbe2db28cfb5c5180de3cf045e (diff) | |
download | gitlab-ce-d6697e0b4d5d9c1437b57b2307464c93d3c66c66.tar.gz |
Created Application Helpers based on suggestion for easier parsing
-rw-r--r-- | app/helpers/application_helper.rb | 19 | ||||
-rw-r--r-- | app/views/users/show.html.haml | 4 |
2 files changed, 21 insertions, 2 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6d6bcbaf88a..03bc773fa2a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -278,4 +278,23 @@ 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\/(.*)\z} + name + else + "https://www.linkedin.com/in/#{name}" + end + end + + def twitter_url(user) + name = user.twitter + if name =~ %r{\Ahttps?:\/\/(www\.)?twitter\.com\/(.*)\z} + name + else + "https://www.twitter.com/#{name}" + end + end + end diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 8f67c1d8f5f..8e8b84e0408 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -56,11 +56,11 @@ = icon('skype') - unless @user.linkedin.blank? .profile-link-holder.middle-dot-divider - = link_to "https://www.linkedin.com/in/#{@user.linkedin.gsub(/https:\/\/www.linkedin.com\/in\//i,'')}", title: "LinkedIn" do + = link_to linkedin_url(@user), title: "LinkedIn" do = icon('linkedin-square') - unless @user.twitter.blank? .profile-link-holder.middle-dot-divider - = link_to "https://twitter.com/#{@user.twitter.gsub(/https:\/\/twitter.com\//i,'')}", title: "Twitter" do + = link_to twitter_url(@user), title: "Twitter" do = icon('twitter-square') - unless @user.website_url.blank? .profile-link-holder.middle-dot-divider |