Discourseテンプレート

|||
|—|—|—|
|:discourse2: | 概要 | Discourse Templates は、コンテンツテンプレートを作成して繰り返し使用できるようにする機能です。テンプレートは特別なカテゴリのトピックとして保存され、必要に応じて編集および議論できます。|
|:open_book: | インストールガイド | このプラグインは Discourse のコアに含まれています。プラグインを個別にインストールする必要はありません。

:information_source: このプラグインは、Discourse Canned Replies の新しいバージョンにほぼ相当しますが、より柔軟で、テンプレートの保存方法が異なります。

特徴

このプラグインは、テンプレートを保存するために 1 つ以上のカテゴリを使用します。これらのカテゴリ内の各トピックの最初の投稿が、返信のテンプレートとして使用されます。

このアプローチにより、discourse-canned-replies で利用可能だったよりもはるかに多くの機能が提供されます。各テンプレートには編集履歴があり、関連付けられたタグを持つことができ、必要に応じて後続の投稿をテンプレートの内容の議論に使用できます。

表示されているトピックのみがテンプレートとして使用されるため、リストにないトピックやアーカイブされたトピックはリストに表示されません。

プラグインは、カテゴリのセキュリティ設定を活用して、どのユーザーがテンプレートを使用できるかを確認します。ユーザーがカテゴリ内のトピックを読み取ることができる場合、「テンプレートの挿入」オプションがコンポーザーで使用可能になります。ユーザーは、アクセス権のあるカテゴリ内のテンプレート/トピックのみを表示できます。

複数の親カテゴリやサブカテゴリを使用して、異なるユーザーグループに異なるテンプレートセットを提供し、テンプレートを整理できます。

プライベートテンプレート

プラグインはプライベートテンプレートもサポートしています。プライベートテンプレートは、テンプレートとしてタグ付けされたプライベートメッセージです。これらのメッセージは、メッセージの作成者 のみ がテンプレートとして利用できます。

アーカイブされたメッセージはテンプレートとしてリストされません。

:bulb: すべてのプライベートテンプレートは、次の場所で見つけることができます。
/u/{ユーザー名}/messages/tags/{プライベートテンプレートタグ}

設定:

  • discourse templates enabled: プラグインをアクティブにします。
  • discourse templates categories: テンプレートを保存するために使用されるカテゴリ。これらのカテゴリとそのサブカテゴリ内の各トピックはテンプレートとして使用され、元のカテゴリでそれらを見ることができるユーザーが利用できます。
  • discourse templates enable private templates: プライベートテンプレートの使用を有効にします。
  • discourse templates groups allowed private templates: プライベートテンプレートの使用が許可されているユーザーグループ。

:warning: スタッフメンバーは常に許可されます。

  • discourse templates private templates tags: プライベートメッセージをテンプレートとしてマークするために使用されるタグ。

使用方法

プラグインをインストールしたら、テンプレートを保存するためのカテゴリを少なくとも 1 つ作成する必要があります。

このカテゴリ内のトピックを読む権限を持つすべてのユーザーが、コンポーザーでプラグイン機能を使用できることに注意してください。

:bulb: プロのヒント: カテゴリ内のテンプレートを編集できるユーザーは、カテゴリ設定で「新しいトピックをデフォルトでウィキにする」を有効にした場合と同じ設定が適用されます。

その後、プラグイン設定でカテゴリを指定します。

これで完了です。指定されたカテゴリにいくつかのトピックを作成すると、テンプレートとして利用できるようになります。

必要に応じて、テンプレートをより整理したり、複数のユーザーグループに異なる返信セットを提供したりするためにサブカテゴリを作成できます。

テンプレートを挿入するには、まず返信コンポーザーを開き、追加ボタンをクリックして、「テンプレートの挿入」オプションを選択する必要があります。

目的のテンプレートを選択します。テキストまたはタグで検索し、「貼り付け」アイコンをクリックできます。

キーボードショートカット
PC では Ctrl+Shift+I、Mac では +Shift+I を使用してテンプレートを挿入できます。

:bulb: キーボードショートカットは、Discourse の任意のテキストエリアで機能します。

プライベートテンプレート

:warning: プライベートテンプレートは、プライベートメッセージとタグの両方が有効になっているインスタンスでのみ機能します。

機能が動作するようにするには、次の Discourse 設定を構成する必要があります。

  • tagging enabled: 有効にする必要があります。
  • enable personal messages: 非スタッフユーザーが機能を利用できるようにしたい場合は有効にする必要があります。
  • pm tags allowed for groups: プライベートメッセージにタグを付けることを許可するグループを許可する必要があります。

プライベートテンプレートを使用するには、まず設定で有効にし、使用できるユーザーグループを割り当て、PM をテンプレートとしてマークするための少なくとも 1 つのタグを割り当てる必要があります。

個人用テンプレートを作成するには、ユーザーは次の手順を実行する必要があります。

  • プラグイン設定で構成されたタグのいずれかでタグ付けされた、自分自身への暗号化されていない個人用メッセージを送信します。メッセージの作成者のみ がそれをプライベートテンプレートとして表示できます。

: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 タスクがあります。

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

Meta で 47 件の定型返信を移行するのに数秒しかかからなかったので、大量の定型返信がない限り、安全に使用できるはずです。

TODO

  • コンポーザー以外の場所でも機能を利用できるように拡張する :white_check_mark:
  • 複数の親カテゴリをテンプレートソースとして使用できるようにする :white_check_mark:

変更履歴

「いいね!」 44
Canned Replies by Group
Discobot Type Message Automation
Canned respones location
It would be helpful to be able to use the To: username (in PMs) for Templates
Option to allow Category Moderators to use canned-replies?
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
Add the option to insert the component's 'Reply Template' code to the composer's toolbar
Exploring Discourse as a Learning Management System
Template Button Relocation
Enforce discourse template by category and /or tag
Discourse Category Lockdown
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?
Advice on a support forum
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
Plugin causing errors during rebuild
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
Plugin causing errors during rebuild