diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 37bf9a1b5..d368d890b 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -234,6 +234,7 @@ class StoriesController < ApplicationController # - Let's say it's `4`. On mobile it would display two rows: 1st with 3 badges and # 2nd with 1 badge (!) <-- and that would look off. @badges_limit = 6 + @profile = @user.profile.decorate set_surrogate_key_header "articles-user-#{@user.id}" set_user_json_ld diff --git a/app/decorators/profile_decorator.rb b/app/decorators/profile_decorator.rb new file mode 100644 index 000000000..d1bbb5f57 --- /dev/null +++ b/app/decorators/profile_decorator.rb @@ -0,0 +1,14 @@ +class ProfileDecorator < ApplicationDecorator + DEV_HEADER_FIELDS = %w[employment_title employer_name].freeze + + # Return a Hash of the profile fields that should be rendered for a given + # display area, e.g. :left_sidebar + def ui_attributes_for(area:) + names = ProfileField.public_send(area).pluck(:attribute_name) + # Temporary workaround: DEV specific header fields are hardcoded in the view + if SiteConfig.dev_to? + names -= DEV_HEADER_FIELDS + end + data.slice(*names).select { |_, v| v.present? } + end +end diff --git a/app/models/profile.rb b/app/models/profile.rb index b2e817b18..bd7d752ae 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -16,6 +16,7 @@ class Profile < ApplicationRecord brand_color2: :text_color_hex, display_email_on_profile: :email_public, display_looking_for_work_on_profile: :looking_for_work_publicly, + education: :education, git_lab_url: :gitlab_url, linked_in_url: :linkedin_url, recruiters_can_contact_me_about_job_opportunities: :contact_consent, diff --git a/app/views/users/_metadata.html.erb b/app/views/users/_metadata.html.erb index ca95284fd..1533a0493 100644 --- a/app/views/users/_metadata.html.erb +++ b/app/views/users/_metadata.html.erb @@ -1,34 +1,78 @@ -<% if @user.employment_title.present? || (@user.looking_for_work_publicly == true && @user.looking_for_work == true) || @user.education.present? %> -
<%= @user.education %>
-- <%= @user.employment_title %> - <% if @user.employer_name.present? %> - at - <% if @user.employer_url.present? %> - <%= @user.employer_name %> - <% else %> - <%= @user.employer_name %> - <% end %> +<% if FeatureFlag.enabled?(:profile_admin) %> + <% if (header_fields = @profile.ui_attributes_for(area: :header)).present? %> +
+ <%= sanitized_sidebar value %> +
++ <%= @user.employment_title %> + <% if @user.employer_name.present? %> + at + <% if @user.employer_url.present? %> + <%= @user.employer_name %> + <% else %> + <%= @user.employer_name %> + <% end %> + <% end %> +
+I'm looking for work!
+<%= @user.education %>
+I'm looking for work!
-+ <%= @user.employment_title %> + <% if @user.employer_name.present? %> + at + <% if @user.employer_url.present? %> + <%= @user.employer_name %> + <% else %> + <%= @user.employer_name %> + <% end %> + <% end %> +
+I'm looking for work!
+