Add Medium URL to User's Profile (#943)
This commit is contained in:
parent
7bf9a8ce89
commit
95b2e181ff
8 changed files with 43 additions and 7 deletions
3
app/assets/images/medium_icon.svg
Normal file
3
app/assets/images/medium_icon.svg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
|
||||
<path d="M0 32v448h448V32H0zm372.2 106.1l-24 23c-2.1 1.6-3.1 4.2-2.7 6.7v169.3c-.4 2.6.6 5.2 2.7 6.7l23.5 23v5.1h-118V367l24.3-23.6c2.4-2.4 2.4-3.1 2.4-6.7V199.8l-67.6 171.6h-9.1L125 199.8v115c-.7 4.8 1 9.7 4.4 13.2l31.6 38.3v5.1H71.2v-5.1l31.6-38.3c3.4-3.5 4.9-8.4 4.1-13.2v-133c.4-3.7-1-7.3-3.8-9.8L75 138.1V133h87.3l67.4 148L289 133.1h83.2v5z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 421 B |
|
|
@ -122,6 +122,7 @@ class Internal::UsersController < Internal::ApplicationController
|
|||
user.email_public = false
|
||||
user.facebook_url = nil
|
||||
user.dribbble_url = nil
|
||||
user.medium_url = nil
|
||||
user.stackoverflow_url = nil
|
||||
user.behance_url = nil
|
||||
user.linkedin_url = nil
|
||||
|
|
|
|||
|
|
@ -83,6 +83,9 @@ class User < ApplicationRecord
|
|||
validates :dribbble_url,
|
||||
allow_blank: true,
|
||||
format: /\Ahttps:\/\/(www.dribbble.com|dribbble.com)\/([a-zA-Z0-9\-\_]{2,20})\/?\Z/
|
||||
validates :medium_url,
|
||||
allow_blank: true,
|
||||
format: /\Ahttps:\/\/(www.medium.com|medium.com)\/([a-zA-Z0-9\-\_\@\.]{2,32})\/?\Z/
|
||||
# rubocop:enable Metrics/LineLength
|
||||
validates :employer_url, url: { allow_blank: true, no_local: true, schemes: ["https", "http"] }
|
||||
validates :shirt_gender,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<meta property="og:image" content="<%= GeneratedImage.new(@user).social_image %>" >
|
||||
<meta property="og:description" content="<%= @user.summary %>" />
|
||||
<meta property="og:site_name" content="The DEV Community" />
|
||||
|
||||
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:site" content="@ThePracticalDev">
|
||||
<meta name="twitter:creator" content="@<%=@user.twitter_username %>">
|
||||
|
|
@ -159,6 +159,11 @@
|
|||
<%= inline_svg("dribbble_icon.svg", class:"icon-img") %>
|
||||
</a>
|
||||
<% end %>
|
||||
<% if @user.medium_url.present? %>
|
||||
<a href="<%= @user.medium_url %>" target="_blank" rel="noopener nofollow">
|
||||
<%= inline_svg("medium_icon.svg", class:"icon-img") %>
|
||||
</a>
|
||||
<% end %>
|
||||
<% if @user.website_url.present? %>
|
||||
<a href="<%= @user.website_url %>" target="_blank" rel="noopener nofollow">
|
||||
<%= inline_svg("external-link-logo.svg", class:"icon-img") %>
|
||||
|
|
@ -177,14 +182,14 @@
|
|||
border: 2px solid <%= HexComparer.new([@tag_model.bg_color_hex || "#0000000",@tag_model.text_color_hex || "#ffffff"]).brightness(0.88) %>;
|
||||
box-shadow: 5px 6px 0px <%= HexComparer.new([@tag_model.bg_color_hex || "#0000000",@tag_model.text_color_hex || "#ffffff"]).brightness(0.88) %>;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
<div class="user-profile-header tag-header">
|
||||
<div class="tag-or-query-header-container">
|
||||
<h1>
|
||||
<% if @tag_model && @tag_model.pretty_name.present? %>
|
||||
<%= @tag_model.pretty_name %>
|
||||
<% else %>
|
||||
<%= @tag %>
|
||||
<%= @tag %>
|
||||
<% end %>
|
||||
<% if @tag_model %>
|
||||
<span class="user-profile-follow-button-wrapper">
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<h4>
|
||||
<a href="https://dev.to/<%= current_user.username %>"><img src="https://d2fltix0v2e0sb.cloudfront.net/dev-badge.svg" height="28" width="28"style="vertical-align:-7px;margin-right:4px;"/></a>
|
||||
<a href="https://dev.to/<%= current_user.username %>"><img src="https://d2fltix0v2e0sb.cloudfront.net/dev-badge.svg" height="28" width="28"style="vertical-align:-7px;margin-right:4px;"/></a>
|
||||
Add the DEV badge to your personal site. <a href="/p/badges">Click here for the code</a>
|
||||
</h4>
|
||||
<%= form_for(@user) do |f| %>
|
||||
|
|
@ -125,7 +125,7 @@
|
|||
<div class="field">
|
||||
<%= f.label :linkedin_url %>
|
||||
<%= f.url_field :linkedin_url %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :behance_url %>
|
||||
<%= f.url_field :behance_url %>
|
||||
|
|
@ -133,7 +133,11 @@
|
|||
<div class="field">
|
||||
<%= f.label :dribbble_url %>
|
||||
<%= f.url_field :dribbble_url %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :medium_url %>
|
||||
<%= f.url_field :medium_url %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label></label>
|
||||
<%= f.hidden_field :tab, value: @tab %>
|
||||
|
|
|
|||
5
db/migrate/20181016181008_add_medium_url_to_users.rb
Normal file
5
db/migrate/20181016181008_add_medium_url_to_users.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class AddMediumUrlToUsers < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :users, :medium_url, :string
|
||||
end
|
||||
end
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
|
|
@ -10,7 +12,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20181008174839) do
|
||||
ActiveRecord::Schema.define(version: 20181016181008) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
|
@ -693,6 +695,7 @@ ActiveRecord::Schema.define(version: 20181008174839) do
|
|||
t.string "location"
|
||||
t.boolean "looking_for_work", default: false
|
||||
t.boolean "looking_for_work_publicly", default: false
|
||||
t.string "medium_url"
|
||||
t.datetime "membership_started_at"
|
||||
t.text "mentee_description"
|
||||
t.datetime "mentee_form_updated_at"
|
||||
|
|
|
|||
|
|
@ -142,6 +142,18 @@ RSpec.describe User, type: :model do
|
|||
expect(user).not_to be_valid
|
||||
end
|
||||
|
||||
it "accepts valid https medium url" do
|
||||
%w(jess jess/ je-ss je_ss).each do |username|
|
||||
user.medium_url = "https://medium.com/#{username}"
|
||||
expect(user).to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
it "does not accept invalid medium url" do
|
||||
user.medium_url = "ben.com"
|
||||
expect(user).not_to be_valid
|
||||
end
|
||||
|
||||
it "changes old_username if old_old_username properly if username changes" do
|
||||
old_username = user.username
|
||||
random_new_username = "username_#{rand(100000000)}"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue