about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2020-02-22 01:05:20 -0600
committermultiple creatures <dev@multiple-creature.party>2020-02-22 01:05:20 -0600
commite51cf7e2b9eb8ef1ee9ac2da08442a513696b3eb (patch)
treeeff7180a1a8f544f311cac9467212d7eaa8874bc /app
parentc32c3f70cdf4e9f113d24e2d9b875fe7052bc839 (diff)
treat profile metadata fields with a `badge` label as custom profile badges
Diffstat (limited to 'app')
-rw-r--r--app/helpers/statuses_helper.rb9
-rw-r--r--app/javascript/flavours/glitch/features/account/components/header.js19
2 files changed, 26 insertions, 2 deletions
diff --git a/app/helpers/statuses_helper.rb b/app/helpers/statuses_helper.rb
index 574b3ad5c..66f17d939 100644
--- a/app/helpers/statuses_helper.rb
+++ b/app/helpers/statuses_helper.rb
@@ -56,6 +56,15 @@ module StatusesHelper
       roles << content_tag(:div, t('accounts.roles.gently'), class: 'account-role gently') if account.gently?
       roles << content_tag(:div, t('accounts.roles.kobold'), class: 'account-role kobold') if account.kobold?
 
+      user_badges = account.fields
+        .select { |field| field.name == 'badge' && !field.value&.strip.blank? }
+        .map { |field| field.value.strip }
+        .uniq
+
+      roles |= user_badges.map do |field|
+        content_tag(:div, badge_text, class: 'account-role custom')
+      end
+
       if (Setting.show_staff_badge && account.user_can_moderate?) || all
         if all && !account.user_staff?
           roles << content_tag(:div, t('admin.accounts.roles.user'), class: 'account-role')
diff --git a/app/javascript/flavours/glitch/features/account/components/header.js b/app/javascript/flavours/glitch/features/account/components/header.js
index 553302cbc..8314ce109 100644
--- a/app/javascript/flavours/glitch/features/account/components/header.js
+++ b/app/javascript/flavours/glitch/features/account/components/header.js
@@ -226,7 +226,22 @@ class Header extends ImmutablePureComponent {
             <h1>
               <span dangerouslySetInnerHTML={displayNameHtml} />
               <small>@{acct}</small>
-              <div className='roles'>{badge_admin}{badge_mod}{badge_halfmod}{badge_froze}{badge_locked}{badge_limited}{badge_ac}{badge_bot}{badge_gently}{badge_kobold}</div>
+              <div className='roles'>
+                {badge_admin}
+                {badge_mod}
+                {badge_halfmod}
+                {badge_froze}
+                {badge_locked}
+                {badge_limited}
+                {badge_ac}
+                {badge_bot}
+                {badge_gently}
+                {badge_kobold}
+
+                {fields.filter(pair => pair.get('name') === 'badge').map((pair, i) => (
+                  <div key={50+i} className='account-role custom'><span dangerouslySetInnerHTML={{ __html: pair.get('value_emojified') }} /></div>)
+                )}
+              </div>
             </h1>
           </div>
 
@@ -246,7 +261,7 @@ class Header extends ImmutablePureComponent {
                       </dd>
                     </dl>
                   ))}
-                  {fields.map((pair, i) => (
+                  {fields.filter(pair => pair.get('name') !== 'badge').map((pair, i) => (
                     <dl key={i}>
                       <dt dangerouslySetInnerHTML={{ __html: pair.get('name_emojified') }} title={pair.get('name')} />