mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Extensibility points for poster name
This commit is contained in:
parent
e6fd7eb464
commit
645c32758a
1 changed files with 15 additions and 2 deletions
|
@ -10,6 +10,11 @@ function sanitizeName(name){
|
||||||
export default createWidget('poster-name', {
|
export default createWidget('poster-name', {
|
||||||
tagName: 'div.names.trigger-user-card',
|
tagName: 'div.names.trigger-user-card',
|
||||||
|
|
||||||
|
settings: {
|
||||||
|
showNameAndGroup: true,
|
||||||
|
showGlyph: true
|
||||||
|
},
|
||||||
|
|
||||||
// TODO: Allow extensibility
|
// TODO: Allow extensibility
|
||||||
posterGlyph(attrs) {
|
posterGlyph(attrs) {
|
||||||
if (attrs.moderator) {
|
if (attrs.moderator) {
|
||||||
|
@ -41,10 +46,18 @@ export default createWidget('poster-name', {
|
||||||
classNames.push(primaryGroupName);
|
classNames.push(primaryGroupName);
|
||||||
}
|
}
|
||||||
const nameContents = [ this.userLink(attrs, nameFirst ? name : username) ];
|
const nameContents = [ this.userLink(attrs, nameFirst ? name : username) ];
|
||||||
const glyph = this.posterGlyph(attrs);
|
|
||||||
if (glyph) { nameContents.push(glyph); }
|
if (this.settings.showGlyph) {
|
||||||
|
const glyph = this.posterGlyph(attrs);
|
||||||
|
if (glyph) { nameContents.push(glyph); }
|
||||||
|
}
|
||||||
|
|
||||||
const contents = [h('span', { className: classNames.join(' ') }, nameContents)];
|
const contents = [h('span', { className: classNames.join(' ') }, nameContents)];
|
||||||
|
|
||||||
|
if (!this.settings.showNameAndGroup) {
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
|
||||||
if (name && this.siteSettings.display_name_on_posts && sanitizeName(name) !== sanitizeName(username)) {
|
if (name && this.siteSettings.display_name_on_posts && sanitizeName(name) !== sanitizeName(username)) {
|
||||||
contents.push(h('span.second.' + (nameFirst ? "username" : "full-name"),
|
contents.push(h('span.second.' + (nameFirst ? "username" : "full-name"),
|
||||||
this.userLink(attrs, nameFirst ? username : name)));
|
this.userLink(attrs, nameFirst ? username : name)));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue