[nodebb-plugin-ns-custom-fields] NS Custom Fields
-
Small suggestion, check if Custom Field value is url and replace it with link.
filters.js
:4: var urlRegex = /(((https?:\/\/)|(www\.))[^\s]+)/i; .. .. 26: if (result.data) { var i = 0, len = result.fields.length, fieldMeta, customFields = params.userData.customFields || []; for (i; i < len; ++i) { fieldMeta = result.fields[i]; var value = result.data[fieldMeta.key]; if (value) { customFields.push({ name : fieldMeta.name, value: value.match(urlRegex)? urlify(value) : value }); } } params.userData.customFields = customFields; 39: } .. .. 53: function urlify(text) { return text.replace(urlRegex, function(url,b,c) { var url2 = (c == 'www.') ? 'http://' +url : url; return '<a href="' +url2+ '" target="_blank">' + url + '</a>'; }) 58: }
-
Critical fixes are made, also plugin is published to Node Package Manager.
First post is updated, same as documentation on GitHub. -
Nice
I'm sure there is a way we can add something to core without having you required to edit the theme manually. What if it was a widget area in the profile page? I'd accept that PR if you were willing to change how this works
-
New version
1.1.0
has been released.
Now you have ability to populate Topic View with custom fields. Also this feature is optional, so Settings was introduced also.@psychobunny I'm not familiar with widgets in NodeBB. Can you collaborate and give me some example? (link on repo, benefits, etc.)
-
@psychobunny Also I'm going to create another plugin, and I need this space in user's profile. Do you have any suggestions how I can reach it without manual editing also?
-
For example, render numeric values under avatar as
metrics
oraccountStats
<div class="text-center account-stats"> <div class="inline-block text-center"> <span class="human-readable-number" title="{reputation}">{reputation}</span> <span class="account-bio-label">[[global:reputation]]</span> </div> <div class="inline-block text-center"> <span class="human-readable-number" title="{postcount}">{postcount}</span> <span class="account-bio-label">[[global:posts]]</span> </div> <div class="inline-block text-center"> <span class="human-readable-number" title="{profileviews}">{profileviews}</span> <span class="account-bio-label">[[user:profile_views]]</span> </div> </div>
Change on:
<!-- BEGIN metrics --> <div class="inline-block text-center"> <span class="human-readable-number" title="{metrics.value}">{metrics.value}</span> <span class="account-bio-label">{metrics.label}</span> </div> <!-- END metrics -->
-
@Nicolas said:
@psychobunny Also I'm going to create another plugin, and I need this space in user's profile. Do you have any suggestions how I can reach it without manual editing also?
Looks like it's the same problem, that part is tied to the theme, so it would need a widget area or a filter from core.
I can probably help with the widget areas if needed.
-
Warning in console:
25/4 11:57 [28225] - warn: [plugins] Callback timed out, hook 'static:app.load' in plugin 'nodebb-plugin-ns-custom-fields'
I found another problem: Try to edit any user's profile as admin and you will see custom fields populated with admin's data.
-
I'm still learning NodeBB architecture.
Seems,socket.uid
was a mistake to use as an User Reference.
I will find another approach to get uid of user profile