Discourse 模板

:discourse2: 摘要 Discourse Templates 允许创建内容模板以供重复使用。这些模板作为主题存储在特殊类别中,可以根据需要进行编辑和讨论。
:open_book: 安装指南 该插件已捆绑在 Discourse 核心中。无需单独安装该插件。

:information_source: 该插件基本上是 Discourse Canned Replies 的新版本,但它更灵活,并以不同的方式存储模板。

功能

此插件使用一个或多个类别来存储模板以便稍后使用。这些类别中每个主题的第一篇文章将用作回复的模板。

这种方法提供了比之前 discourse-canned-replies 更多的功能,因为每个模板都会有编辑历史记录,可以关联标签,并且后续帖子可用于讨论模板内容(如果需要)。

只有可见的主题将用作模板,因此未列出和归档的主题将不会列出。

该插件还利用类别的安全设置来检查哪些用户可以使用模板。如果用户可以阅读类别中的主题,则编辑器中将提供“插入模板”选项。用户只能看到他们有权限访问的类别中的模板/主题。

可以使用多个父类别和/或子类别来为不同的用户组提供不同的模板集,并组织模板。

私有模板

该插件还支持私有模板。私有模板是标记为模板的私信。这些消息将对消息的作者作为模板可用。

归档的消息将不会列为模板。

:bulb: 您可以在以下位置找到所有私有模板:
/u/{USER-NAME}/messages/tags/{PRIVATE-TEMPLATE-TAG}

设置:

  • discourse templates enabled: 激活插件
  • discourse templates categories: 用于存储模板的类别。这些类别及其子类别中的每个主题将用作模板,并对在其原始类别中可以看到它们的用户可用。
  • discourse templates enable private templates: 启用私有模板的使用。
  • discourse templates groups allowed private templates: 允许使用私有模板的用户组。

:warning: 工作人员始终被允许。

  • discourse templates private templates tags: 将用于标记私信为模板的标签。

如何使用

安装插件后,您需要创建至少一个类别来存储模板。

请注意,任何有权读取此类别中主题的用户都将能够在编辑器中使用插件功能。

:bulb: 技巧: 编辑主题的相同设置将应用于“模板”主题。如果您希望任何具有类别写入权限的人都能编辑现有模板,您应该在类别设置中激活 默认使新主题成为维基

之后,在插件设置中指定类别。

就是这样。现在您只需在指定类别中创建一些主题,它们就可以作为模板使用。

如果您愿意,可以创建子类别以更好地组织模板,或为多个用户组提供不同的回复集。

要插入模板,您必须首先打开回复编辑器,然后点击附加按钮,然后选择“插入模板”选项。

选择所需的模板,您可以按文本或标签搜索,然后点击“粘贴”图标。

键盘快捷键
您可以在 PC 上使用 Ctrl+Shift+I 或在 Mac 上使用 +Shift+I 来插入模板。

:bulb: 键盘快捷键将在 Discourse 中的任何文本区域中工作

私有模板

:warning: 私有模板仅在同时启用私信和标签的实例中有效。

您需要配置以下 Discourse 设置才能使其工作:

  • tagging enabled: 必须启用。
  • enable personal messages: 如果您希望为非工作人员用户启用此功能,应启用此选项。
  • pm tags allowed for groups: 您需要允许将使用私有模板的组对私信进行标记。

要使用私有模板,您必须首先在设置中启用它,分配可以使用它的用户组,并至少分配一个标签来将 PM 标记为模板。

要创建个人模板,用户必须:

  • 向自己发送未加密的个人消息,并使用插件设置中配置的一个标签标记。只有消息的作者会将其视为私有模板。

:bulb: 发送给其他用户的私信也可以标记,但只有消息的作者才能将其用作模板。

预填充变量

该插件支持模板中的以下变量:

  • my_username
  • my_name
  • topic_title
  • topic_url
  • original_poster_username
  • original_poster_name
  • reply_to_username
  • reply_to_name
  • last_poster_username
  • reply_to_or_last_poster_username

以上所有变量都支持回退文本,如果未指定回退且无法替换变量,则会将变量剥离。

标题和正文都支持变量替换。

示例:

Hi %{reply_to_username,fallback:there},

...

Regards,
%{my_name}

如果 reply_to_username 不可用,模板将是:

Hi there,

...

Regards,
Arpit Jalan

discourse-canned-replies 迁移

有一个 rake 任务可以将现有的 canned replies 迁移到模板:

rake "discourse-templates:migrate-from-canned-replies"

在 Meta 上迁移 47 个 canned replies 仅花费了几秒钟,因此除非您有大量的 canned replies,否则使用应该是安全的。

TODO

  • 扩展功能以涵盖编辑器以外的其他位置 :white_check_mark:
  • 允许使用多个父类别作为模板源 :white_check_mark:

更新日志

44 个赞
Canned Replies by Group
Discobot Type Message Automation
Canned respones location
Option to allow Category Moderators to use canned-replies?
It would be helpful to be able to use the To: username (in PMs) for Templates
Plugin causing errors during rebuild
Canned reply hotkeys?
Poll-restriction
Is it possible to block a category from Upcoming Events?
I'm working to build a "marketplace" on top of Discourse. Would love some suggestions/feedback
Balancing Costs and Functionality in AI-Powered Forums
Canned Replies without extra lines
Canned Replies without extra lines
Exploring Discourse as a Learning Management System
Template Button Relocation
Enforce discourse template by category and /or tag
Give me some control of how the form template post is styled
Can I customize the welcome message shown when creating a new topic based on the chosen tag or category?
Plugin causing errors during rebuild
More efficient (inline) template usage
Will uninstalling a plugin leave any residual debris files in the database?
Build Poll not showing under Post Settings
Feedback on Our Community
How are we all feeling about ChatGPT and other LLMs and how they'll impact forums?
Daily Summary (5am UTC)
General Question About Saved Replies
Using template with a [wrap] code while in Rich Text Editor not working
Bundling more popular plugins with Discourse core
Discourse Category Lockdown
Advice on a support forum
Add the option to insert the component's 'Reply Template' code to the composer's toolbar
Using topic templates for categories
Speak with the Discourse product team about moderation
Templates for Staff Notices
Check boxes and Mandatory fields in Topic templates?
Time tracking using Discourse?
Send a message to an inactive group
Canned Replies without extra lines
Discourse template plugin added itself to my discourse?
Community Guide: Activating Lurkers
Ability to Create Private Templates
Ability to Create Private Templates