diff --git a/app/assets/stylesheets/profiles.sass b/app/assets/stylesheets/profiles.sass
index d4dfb779..831724ad 100644
--- a/app/assets/stylesheets/profiles.sass
+++ b/app/assets/stylesheets/profiles.sass
@@ -11,6 +11,19 @@ a .profile
color: black
.social-links
+ width: 100%
+ text-align: center
+ position: relative
+ background: #40a10b
+ background: linear-gradient(90deg, #e1b02777 0%, rgba(0,0,0,0) 88%)
+ > a
+ padding: 0 1em
.x-logo
- width: 1.6rem
+ width: 1.2em
vertical-align: middle
+ .controls
+ position: absolute
+ top: -1em
+ margin-left: 0.8em
+ a
+ font-size: 0.6em
diff --git a/app/controllers/social_links_controller.rb b/app/controllers/social_links_controller.rb
index fe908052..78030e96 100644
--- a/app/controllers/social_links_controller.rb
+++ b/app/controllers/social_links_controller.rb
@@ -55,6 +55,7 @@ class SocialLinksController < ApplicationController
# DELETE /social_links/1 or /social_links/1.json
def destroy
+ authorize @social_link
@social_link.destroy
respond_to do |format|
diff --git a/app/models/social_link.rb b/app/models/social_link.rb
index 62a2f562..eee1c935 100644
--- a/app/models/social_link.rb
+++ b/app/models/social_link.rb
@@ -1,3 +1,21 @@
class SocialLink < ActiveRecord::Base
belongs_to :profile
+ has_one :user, through: :profile
+
+ def to_icon
+ case self.url
+ when /twitter\.com/, /x\.com/
+ social_icon = ""
+ else
+ social_icon = "🌐"
+ end
+ end
+
+ def to_url
+ if self.url.scan(/https?:\/\//).empty?
+ "https://#{self.url}"
+ else
+ self.url
+ end
+ end
end
diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml
index 3c7e1e70..be533fd4 100644
--- a/app/views/profiles/show.html.haml
+++ b/app/views/profiles/show.html.haml
@@ -12,16 +12,15 @@
.social-links
-# = "".html_safe
- %p
- - @profile.social_links.each do |social_link|
- - case social_link.url
- - when /twitter\.com/, /x\.com/
- - social_icon = ""
- -# = link_to "#{social_icon} #{social_link.url}".html_safe, "https://#{social_link.url}"
- = link_to "https://#{social_link.url}" do
- #{social_icon.try("html_safe") || "🌐"}
- - if policy(@profile).edit?
- %br= link_to '+ Add Social Link', new_social_link_path(profile_id: @profile.id)
+ - @profile.social_links.each do |social_link|
+ -# = link_to "#{social_icon} #{social_link.url}".html_safe, "https://#{social_link.url}"
+ - if policy(social_link).destroy?
+ %span.controls
+ = link_to '📝', edit_social_link_path(social_link)
+ = link_to '❌', social_link, method: :delete, data: { confirm: 'Are you sure?' }
+ = link_to social_link.to_icon.html_safe, social_link.to_url
+ - if policy(@profile).edit?
+ %br= link_to '+ Add Social Link', new_social_link_path(profile_id: @profile.id)
%h2 About #{@profile.name}
diff --git a/app/views/social_links/edit.html.haml b/app/views/social_links/edit.html.haml
index 186cd599..8899e005 100644
--- a/app/views/social_links/edit.html.haml
+++ b/app/views/social_links/edit.html.haml
@@ -1,7 +1,3 @@
%h1 Editing social_link
= render 'form'
-
-= link_to 'Show', @social_link
-\|
-= link_to 'Back', social_links_path