Add Instagram URL to profile links (#3307)
This commit is contained in:
parent
a30e06d673
commit
b52d8e931d
11 changed files with 41 additions and 2 deletions
|
|
@ -50,6 +50,7 @@ module Admin
|
|||
gitlab_url
|
||||
linkedin_url
|
||||
twitch_url
|
||||
instagram_url
|
||||
]
|
||||
accessible << %i[password password_confirmation] if params[:user][:password].present?
|
||||
verify_usernames params.require(:user).permit(accessible)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class UserDashboard < Administrate::BaseDashboard
|
|||
dribbble_url: Field::String,
|
||||
medium_url: Field::String,
|
||||
gitlab_url: Field::String,
|
||||
instagram_url: Field::String,
|
||||
linkedin_url: Field::String,
|
||||
twitch_url: Field::String,
|
||||
feed_admin_publish_permission: Field::Boolean,
|
||||
|
|
@ -83,6 +84,7 @@ class UserDashboard < Administrate::BaseDashboard
|
|||
dribbble_url
|
||||
medium_url
|
||||
gitlab_url
|
||||
instagram_url
|
||||
linkedin_url
|
||||
twitch_url
|
||||
bg_color_hex
|
||||
|
|
|
|||
|
|
@ -91,6 +91,9 @@ class User < ApplicationRecord
|
|||
validates :gitlab_url,
|
||||
allow_blank: true,
|
||||
format: /\A(http(s)?:\/\/)?(www.gitlab.com|gitlab.com)\/.*\Z/
|
||||
validates :instagram_url,
|
||||
allow_blank: true,
|
||||
format: /\A(http(s)?:\/\/)?(www.instagram.com|instagram.com)\/[a-z\d_]{1,30}\Z/
|
||||
validates :twitch_url,
|
||||
allow_blank: true,
|
||||
format: /\A(http(s)?:\/\/)?(www.twitch.tv|twitch.tv)\/.*\Z/
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ class UserPolicy < ApplicationPolicy
|
|||
feed_url
|
||||
gitlab_url
|
||||
inbox_guidelines
|
||||
instagram_url
|
||||
linkedin_url
|
||||
location
|
||||
looking_for_work
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ module Moderator
|
|||
location: "", education: "", employer_name: "", employer_url: "", employment_title: "",
|
||||
mostly_work_with: "", currently_learning: "", currently_hacking_on: "", available_for: "",
|
||||
email_public: false, facebook_url: nil, dribbble_url: nil, medium_url: nil, stackoverflow_url: nil,
|
||||
behance_url: nil, linkedin_url: nil, gitlab_url: nil, mastodon_url: nil, twitch_url: nil
|
||||
behance_url: nil, linkedin_url: nil, gitlab_url: nil, instagram_url: nil, mastodon_url: nil, twitch_url: nil
|
||||
)
|
||||
|
||||
user.update_columns(profile_image: "https://thepracticaldev.s3.amazonaws.com/i/99mvlsfu5tfj9m7ku25d.png")
|
||||
|
|
|
|||
|
|
@ -147,6 +147,10 @@
|
|||
<%= f.label :gitlab_url, "GitLab URL" %>
|
||||
<%= f.url_field :gitlab_url %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :instagram_url, "Instagram URL" %>
|
||||
<%= f.url_field :instagram_url %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :mastodon_url, "Mastodon URL" %>
|
||||
<%= f.url_field :mastodon_url %>
|
||||
|
|
|
|||
|
|
@ -82,6 +82,11 @@
|
|||
<a href="<%= @user.gitlab_url %>" target="_blank" rel="noopener nofollow me">
|
||||
<%= inline_svg("gitlab.svg", class: "icon-img", aria: true, title: "GitLab logo") %>
|
||||
</a>
|
||||
<% end %>
|
||||
<% if @user.instagram_url.present? %>
|
||||
<a href="<%= @user.instagram_url %>" target="_blank" rel="noopener nofollow me">
|
||||
<%= inline_svg("instagram-logo.svg", class: "icon-img", aria: true, title: "Instagram logo") %>
|
||||
</a>
|
||||
<% end %>
|
||||
<% if @user.twitch_url.present? %>
|
||||
<a href="<%= @user.twitch_url %>" target="_blank" rel="noopener nofollow me">
|
||||
|
|
|
|||
|
|
@ -105,6 +105,11 @@
|
|||
<%= inline_svg("gitlab.svg", class: "icon-img", aria: true, title: "GitLab logo") %>
|
||||
</a>
|
||||
<% end %>
|
||||
<% if @user.instagram_url? %>
|
||||
<a href="<%= @user.instagram_url %>" target="_blank" rel="noopener nofollow me">
|
||||
<%= inline_svg("instagram-logo.svg", class: "icon-img", aria: true, title: "Instagram logo") %>
|
||||
</a>
|
||||
<% end %>
|
||||
<% if @user.twitch_username? %>
|
||||
<%= link_to twitch_live_stream_path(username: @user.username) do %>
|
||||
<%= inline_svg("twitch-logo.svg", class: "icon-img", id: "icon-twitch", aria: true, title: "Twitch logo") %>
|
||||
|
|
|
|||
5
db/migrate/20190626022355_add_instagram_url_to_users.rb
Normal file
5
db/migrate/20190626022355_add_instagram_url_to_users.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class AddInstagramUrlToUsers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :users, :instagram_url, :string
|
||||
end
|
||||
end
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2019_06_25_143841) do
|
||||
ActiveRecord::Schema.define(version: 2019_06_26_022355) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
|
@ -952,6 +952,7 @@ ActiveRecord::Schema.define(version: 2019_06_25_143841) do
|
|||
t.string "gitlab_url"
|
||||
t.string "inbox_guidelines"
|
||||
t.string "inbox_type", default: "private"
|
||||
t.string "instagram_url"
|
||||
t.jsonb "language_settings", default: {}, null: false
|
||||
t.datetime "last_article_at", default: "2017-01-01 05:00:00"
|
||||
t.datetime "last_comment_at", default: "2017-01-01 05:00:00"
|
||||
|
|
|
|||
|
|
@ -257,6 +257,18 @@ RSpec.describe User, type: :model do
|
|||
expect(user).not_to be_valid
|
||||
end
|
||||
|
||||
it "does not accept invalid instagram url" do
|
||||
user.instagram_url = "ben.com"
|
||||
expect(user).not_to be_valid
|
||||
end
|
||||
|
||||
it "accepts valid instagram url" do
|
||||
%w[jess je_ss].each do |username|
|
||||
user.instagram_url = "https://instagram.com/#{username}"
|
||||
expect(user).to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
it "accepts valid https gitlab url" do
|
||||
%w[jess jess/ je-ss je_ss].each do |username|
|
||||
user.gitlab_url = "https://gitlab.com/#{username}"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue