I think soo too
But since it will make our life even better I’m going for it.
What about a opt-in for spaces in mentions?
It would add spaces here:
I think soo too
But since it will make our life even better I’m going for it.
What about a opt-in for spaces in mentions?
It would add spaces here:
Nope, we are not ever adding spaces to matches for mentions. Sorry. That’s never gonna happen on my watch.
I really like the way this is styled, in communities where people know each other by name and not username would be really useful. You would type @username the same way but final style would be different.
Our inspiration here is Twitter, so… no. Not opposed to a different baked style though, just space matching would be massively dangerous.
Haha I was expecting this
So can someone point me how to overload the function to add spaces in my plugin?
Our company is in the same situation. Probably not so uncommon for enterprises. Our synthetic usernames look completely out of place within posts, but thankfully, @ mention searches work with full names and for post authors, there’s already the setting to enable display of full name. So we’re almost there except for the @ mentions display approach.
I agree completely with this. Inline usernames are a barrier to adoption in enterprise environments, especially those with a bunch of (often older) employees that don’t transition well between technologies.
Just FYI I was toying with this and made the autocomplete function return an object with fullname and username, and choose to display the fullname. It works, but breaks a lot of other things, since discourse sorta expects the username at some places and tests.
Still, this ins’t a top priority, but I think it would be a nice option for /r/outside communities.
I wonder if this can be done completely using JS/CSS customizations:
a.mention::before {
content: "First Last";
visibility: visible;
font-size: 12px;
letter-spacing: normal;
background: #f4f4f4;
border-radius: 8px;
padding: 2px 4px;
}
a.mention, a.mention-group {
padding: 0px;
font-size: 0px;
letter-spacing: -1px;
visibility: collapse;
}
Not sure what the best way would be to properly insert the right value for “First Last” though…
Hey! That’s a very good idea!
The problem is that I don’t have where to save the name, since we have just markdown text. But the xrh and the result object have all the values.
One way to approach that is to update the mention markup to include a data-fullname attribute that contains the fullname, then you can use CSS to make it show next to the mention.
Similar to (for putting the post number on each post next to the timestamp)
a.post-date:after {
content: "#"attr(data-post-number);
}
Not sure if the Discourse team would be opposed to adding such a data attribute to mentions, but if they aren’t, it makes this solvable for the Enterprise scenario pretty quickly.
Sounds good to me! If it is easy markup I am all for it!
Would we need to go after each fullname on the cooking phase right?
And we need to do this on the server-side cook and the client-side preview?
Yeah, that seems to be the problem with that approach, as I just realized I made a few assumptions (incorrectly) based on what I was reading or thought I was reading above.
The issue is we’d have to do a user/group lookup when the post gets cooked for each mention in that given post (groups may be doing this to some extent with its ability to validate mentionableGroups).
Not sure Discourse will be a fan of that, as that could add cost. The current mention_dialect and link-mentions do not do that and only use what comes after @
to determine it is a mention
As you need that fullname property from the username object.
Alternatively, it may be possible to do this via a plugin. The plugin would be a regex replacement, searching for the mention syntax (and then grabbing the user details), and replacing it to contain the full name (you wouldn’t need to use a data attribute for that approach).
So that is two methods, that latter one will need to be done cautiously as you don’t want to disrupt how the usercard determines what user is being clicked on (not sure if it goes on href or the mention text). But I think you can do it without breaking the actual mention and its related tests, if we use one of these approaches.
I was sort of hoping the user data would have been there (was secretly hoping it was somehow using parts of it to help aid the usercard popup), but that doesn’t seem to be the case. If we can make that only apply to the cooking process (and maybe the client side preview), that might be okay.
Yes that’s pretty much the problem.
My first approach was re-using the data from the autocomplete, so we wouldn’t put any new pressure on the servers, the data is already there! The problem: where we store this data? It’s just plain old markdown.
The second approach is doing this on the cook method, just adding a data- attribute with the fullname. It’s a user table index seach but I don’t think this will be too much pressure since we have user mention limits in place. The problem: Post will flash after posting when the cooked version comes from server. I could live with that, but Discourse quality bar is higher than mine .
Perhaps the affiliate plugin may be a good point of reference?
https://meta.discourse.org/t/discourse-affiliate-insert-affiliate-code-amazon-automatically-to-links/19585?u=mcwumbly
If you did the Autocomplete route, could you simply put it in parenthesizes after the mention, @cpradio (Full name)? or would you want it clickable?
I still sort of like the data attribute path personally.
I think full name mention is better in many cases and near essential in some scenarios.
Hey all, sorry to bump this one back up again - Did there end up being a solution to replace the @username mention displayed in a post with a users Full Name?
The @ mention search works great finding both usernames and full names, but would be awesome to have an option to replace the @username in a post with the ‘Full Name’ on display. Would love to hear if anyone found a clean way to do this!