saquetim
(Sérgio Saquetim)
2022 年1 月 28 日 14:51
1
|||
|-|-|-|
| |Preview | https://theme-creator.discourse.org/theme/megothss/discourse-show-name-mentions |
| : hammer_and_wrench:|Repository | GitHub - megothss/discourse-show-name-mentions: A discourse theme component to display the full name instead of usernames in @mentions |
| : question:|Install Guide |How to install a theme or theme component |
| : open_book:|New to Discourse Themes? | Beginner’s guide to using Discourse Themes
Install this theme component
A theme component to display the full name instead of usernames in @mentions.
This theme component loads the full name of the user and display @fullname instead of @username in mentions.
This component works by simply replacing the username with the name of the user (if available) when displaying the posts. Nothing changes while editing. You still tag @username like always in the composer.
It also adds the class .mention-fullname to the a.mention anchor element if you wish the style full name mentions in a distinct way.
Displaying the card when clicking in the @fullname mentions remains fully functional.
Use case:
Imagine a Discourse instance where every username name follows the pattern X9999999 (one letter and seven numbers). Now imagine there are 100k users registered.
Not very friendly, right? Unfortunately, this is a very real scenario and not an imaginary one. The Discourse instance is bonded to SSO and all usernames follow corporate policy.
It’s much better in this case to read @John Doe instead of @X9999999.
Settings:
show_fullname_in_mentions : If enabled @mentions will show the @fullname instead of the @username
17 个赞
ImaCrea
(ImaCrea)
2022 年12 月 16 日 15:50
3
你好 Sérgio,感谢你的主题组件!
我试了一下,但在试验后发现它在用户体验方面造成了一些不一致。
发生的情况是:我有一个用户,他的用户名是“oli44”,全名是“Henri Oliver”。使用你的主题组件后,它现在显示“Henri Oliver”,这很好,增加了更好的上下文。但是,假设我是另一个不知道“Henri Oliver”的用户名是“oli44”的用户,那么我该如何在帖子中提及他呢?
我将搜索“Henri Oliver”,确实会看到“oli44”,但我怎么知道这是本人呢?
因此,目前我暂时不启用它。你是否知道其他可以解决这个问题的主题组件/插件?我尝试查找过,但找不到。
或者,也许你的主题组件可以显示用户名(例如:“@Henri Oliver (oli44)”),这样当我需要提及该用户时,我就知道要找什么了(?)
无论如何,感谢你这个很棒的补充。
3 个赞
thoka
(Thomas Kalka)
2023 年9 月 9 日 06:14
4
您只需输入“@”后跟“Henri Oliver”。确认后,@+用户名将插入到您的帖子中。
搜索时,用户名和全名都会显示。
问题出在哪里?
您可以在 fork 中轻松自定义渲染:
committed 04:14PM - 08 Sep 23 UTC
1 个赞
thoka
(Thomas Kalka)
2023 年9 月 9 日 06:21
5
我看到了两个问题:
服务器将为每个提及发送一个 ajax 请求。
这是否会导致包含大量用户名的页面(例如用户提供的用户目录)被限流?
缓存的用户名到全名翻译将无法识别全名的更改。此缓存的有效期是多久?
我想知道是否可以通过一个伴随插件来提供所需的信息(用户名 → 全名),这将使这些问题变得无关紧要。
thoka
(Thomas Kalka)
2023 年10 月 1 日 12:21
6
由于我们遇到了预期的问题,我创建了一个插件,该插件提供了完整的姓名以及提及:
Contribute to thoka/discourse-provide-full-name-in-mentions development by creating an account on GitHub.
因此,已从组件中删除了 ajax 请求。
我还添加了一个选项来配置用于渲染提及的模板:
A discourse theme component to display the full name instead of usernames in @mentions
2 个赞
Canapin
(Coin-coin le Canapin)
2023 年10 月 2 日 10:04
7
如果我们想坚持使用主题组件,那么 ajax 请求是强制性的吗?
如果是这样,我邀请您创建一个新的 Plugin 主题,如果您认为您的工作足够可靠,可以供他人使用
thoka
(Thomas Kalka)
2023 年10 月 2 日 11:02
8
我不能写那个类别…
我不知道。由于我只研究插件/组件开发,所以我选择收集这两个技巧来实现期望的行为。
但也许其他人愿意加入来完善它。
1 个赞
Canapin
(Coin-coin le Canapin)
2023 年10 月 2 日 11:24
10
1 个赞
你刚发了这些,我刚在你发帖时安装了原作者的插件。问题是,我注意到原作者的插件不支持群组的全名。但是,你好像添加了群组。如果是这样,恭喜你!鉴于你实现的功能,你的插件值得拥有自己的帖子!
也许我没有做对,但我启用了您的主题组件和插件,并且不再看到提及中的全名。
谢谢!我现在做到了。搜索群组是否也可能?我有一个名为 everyone 的 trust_level_0 群组。如果插件也能使用群组名称进行提及,这将是一种很酷的方式,可以让全局 trust_level_0 提及看起来像 everyone 提及。
saquetim
(Sérgio Saquetim)
2023 年10 月 2 日 21:31
17
Thomas Kalka:
你重新烘焙过你的帖子吗?
由于该插件在烘焙帖子时包含信息。请注意,如果用户更新了全名,除非帖子被重新烘焙,否则它不会在帖子中更新。
我需要更新这个主题组件中的一些东西。如果用户状态已启用,现在可以删除 Ajax 调用。
我会尽快尝试。
2 个赞
saquetim
(Sérgio Saquetim)
2023 年10 月 2 日 21:45
19
Thomas Kalka:
注意用户和组名更改并重新烘焙受影响的帖子。
重新烘焙的成本很高。这在某些社区可能会有问题,具体取决于用户更改姓名的频率。
请牢记这一点。
1 个赞
thoka
(Thomas Kalka)
2023 年10 月 2 日 21:50
20
谢谢。在我们更正式的学校社区中,名称不会频繁更改。
原则上,可以在已经烘焙的内容中添加名称。您似乎更倾向于这条路?
大部分情况下都能正常工作。我不确定为什么,尽管我将信任等级 0 重命名为了 everyone,但它没有应用该标签。
非信任等级组都可以正常工作并显示其全名。
编辑:啊,因为 groups 表中的 full_name 列不包含信任等级组的修改后的全名值!检查数据浏览器,它是空的。嗯?
thoka
(Thomas Kalka)
2023 年10 月 3 日 06:07
22
从上面的图片来看,您似乎更改了 trust_level_0 的 i18n 条目。
尝试在 rails 控制台中运行 Group.find(10).update! full_name: "TESTTEST"。
这可能会产生副作用,因为在 UI 中不允许更改内置组的全名。
确实如此。我尝试过这样做,而且在没有造成严重影响的情况下奏效了。有没有办法在不使用插件的情况下,仅使用主题组件来整合群组?对我来说,这实际上是首选,因为如果可以避免的话,我不喜欢费力去做。