Hmmmm. That’s a tricky one, because the symlink needed to be deleted, otherwise the Docker mount fails (as it cannot overwrite the existing file).
I had a bit of a google around for solutions, and found an interesting solution which would dereference the symlink and copy the symlink’s target into the specified directory, but couldn’t find anything that would create a Docker volume mount, thus preserving the dynamic link and bi-directional synchronisation. Happy to be steered towards a solution as this would be a neat feature to have.
Dev_Work
(Aleksandr)
2019 年 12 月 26 日午前 8:31
111
Tell me how to add your validation to the app/models /user.rb model?
validates_presence_of :username
validate :username_validator, if: :will_save_change_to_username?
validate :password_validator
validate :name_validator, if: :will_save_change_to_name?
validates :name, user_full_name: true, if: :will_save_change_to_name?, length: { maximum: 255 }
validates :ip_address, allowed_ip_address: { on: :create, message: :signup_not_allowed }
validates :primary_email, presence: true
validates_associated :primary_email, message: -> (_, user_email) { user_email[:value]&.errors[:email]&.first }
after_initialize :add_trust_level
before_validation :set_skip_validate_email
「いいね!」 1
eviltrout
(Robin Ward)
2019 年 12 月 27 日午後 2:15
112
プラグインファイル (plugin.rb) では、通常の Ruby コードを使用してこれを行うことができます。
class ::User < ActiveRecord::Base
validates_presence_of :your_attribute
end
「いいね!」 6
AstonJ
(AstonJ)
2020 年 1 月 29 日午前 3:25
113
初めての小さなプラグイン開発を始めました いくつか質問があるので、誰かお手伝いいただければ幸いです…
eviltrout:
2018 年 8 月更新 、plugins ディレクトリに完全な Discourse プラグインのスケルトンを作成するには、Rails プラグインジェネレーター をご覧ください
最初の質問ですが、このガイドに記載されている方法を使うべきか、それとも本当にプラグインジェネレーターを使うべきでしょうか?
このガイドでは触れられていませんでしたが、plugin.rb ファイルからテンプレートにデータを渡すにはどうすればよいでしょうか?
例えば、プラグインアウトレット topic-above-posts で、誰かがトピックを訪れるたびに、plugin.rb 内の配列からランダムに選ばれた歓迎メッセージを表示したいとします。その場合、そのデータをテンプレートにどのように渡せばよいでしょうか?テンプレートはおそらくここにあると思います:
plugins/my_new_plugin/assets/javascripts/discourse/templates/connectors/topic-above-posts/my_new_plugin.hbs(これで正しいでしょうか?)
何かアドバイスがあれば大変助かります
「いいね!」 2
eviltrout
(Robin Ward)
2020 年 1 月 29 日午後 3:42
114
プラグインジェネレーターを使用することは、プラグインの構造を理解して始めたい場合に非常に有効な方法です。ぜひおすすめします。
さて、Ruby コードをフロントエンドに組み込む方法についてですが、これらは別々のアプリケーションです。フロントエンド(Ember)は、何らかの形でサーバー(Rails)からデータを取得する必要があります。通常は AJAX 呼び出しで行いますが、SiteSerializer に追加して、フォーラムデータの自動送信の一部として含める方法もあります。
それ以外の場合は、Rails でルートやコントローラーを追加する方法を調べ、メッセージを JSON として送信する手順を確認してください。
「いいね!」 8
AstonJ
(AstonJ)
2020 年 1 月 29 日午後 7:24
115
ロビン、ありがとう!
これに関するチュートリアルはありますか?あるいは、方向性を示してくれるシンプルなプラグイン(あるいはダミープラグインでも)をご存知でしょうか?(もしなければ、どこかにすぐに掲載していただけませんか?多くの人にとって役立つと思います )
さらに、本を書くことについてのご意見はありますか?もしご興味があれば、誰かをご紹介できますよ
「いいね!」 1
eviltrout
(Robin Ward)
2020 年 1 月 30 日午後 3:06
116
褒めていただきありがとうございます。でも、本を書くことを考えるには、どうしても忙しすぎます。それに、技術書は需要が非常に限られています。本を書いたことがある人たちは、お金のためではなく、自分自身のために書くものだと言っています
サーバー側から何かを返すシンプルなプラグインは思いつきません。discourse-tooltips はルートを追加し、マウスオーバー時にトピックのプレビューを取得するためにそれを使用しています。これが役立つかもしれません。
「いいね!」 8
neounix
(Dark Matter)
2020 年 3 月 19 日午後 2:37
118
まもなく、プラグイン開発を開始します……
質問:
実際にプラグインを挿入できる「フック」のリストはありますか?
例えば、投稿に表示される前に「調理済み」データを処理するプラグインを作成したい場合、少なくとも開始時と終了時にフックがあることを期待します。例を挙げると:
display_post_start
display_post_complex
すると、私たちのプラグインは上記のフック位置のいずれかにフックできます。
これらの「プラグインフック」のリストと、DiscourseWorld におけるこれらの「プラグインフック」の名称は何ですか?
更新:以下を見つけました:
git grep "plugin-outlet" -- "*.hbs"
しかし、調理済みの投稿コンテンツを変更するための outlet は見当たりませんでした。
例えば、投稿の「調理済み」部分を変更するための outlet を作成する方法を解説したチュートリアルはありますか?
「いいね!」 2
riking
(Kane York)
2020 年 3 月 19 日午後 6:11
119
このガイド、セクション decorateCooked() をお探しですね:
Discourse Themes and Theme Components can be used to customize the look, feel and functionality of Discourse’s frontend. This section of the developer guides aims to provide all the reference materials you need to develop simple themes for a single site, right up to complex open-source theme components.
This introduction aims to provide a map of all the tools and APIs for theme development. If you prefer a step-by-step tutorial for theme development, jump straight to:
Themes vs. Theme Compon…
「いいね!」 5
カスタムプラグインにこのスケルトンを使用しています。今後の Ember 5 への移行にあたり、何か変更する必要はありますか?
Discourse will soon be upgrading our version of the Ember Javascript framework from version 3 to version 5. The vast majority of the preparation work is done, and many sites are already running on Ember 5 (including Meta!).
This upgrade is available behind a feature flag right now! This is the default for self-hosted Discourse installations starting 10th January. Initially, Ember 3 support will remain available via a flag, but will be removed within the first quarter of 2024.
On our ma…
おそらく必要ないですよね?これはリンターにすぎませんが?
{
"name": "discourse-plugin-name",
"version": "0.0.1",
"repository": "TODO",
"author": "Discourse",
"license": "MIT",
"devDependencies": {
"@discourse/lint-configs": "^1.2.0",
"ember-template-lint": "^5.13.0",
"eslint": "^8.54.0",
"prettier": "^2.8.8"
}
}
「いいね!」 1
david
(David Taylor)
2023 年 12 月 8 日午前 10:18
134
スケルトンはEmber 5と互換性があります。ただし、JavaScriptコードやhbsテンプレートを追加した場合は、アナウンスに記載されているように非推奨の項目を確認する必要があります。
AquaL1te:
これはリンターにすぎないのですか?
はい、package.jsonにあるものはリンターに関連するだけで、プラグインの機能や互換性には影響しません。
「いいね!」 3
pfaffman
(Jay Pfaffman)
2024 年 9 月 24 日午後 6:11
136
これに追加してください
rake plugin:create[plugin-name]
今日は Automating Discourse Plugin Setup with `create-discourse-plugin` gem を見つけようとして長時間を費やしました(このrakeタスクの名前を思い出せなかった理由がわかりません! )
「いいね!」 5
Docker セットアップを使用する際に注意点を追記します。上記の手順では、以下のようなエラーが発生して失敗します。
ambientimpact:~/.../Discourse/discourse$ d/rake plugin:create[neurocracy-date-rewrite]
Cloning 'https://github.com/discourse/discourse-plugin-skeleton' to '/src/plugins/neurocracy-date-rewrite'...
Initializing git repository...
Initialized empty Git repository in /src/plugins/neurocracy-date-rewrite/.git/
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <discourse@localhost>) not allowed
rake aborted!
Command failed with exit 128: git
/src/lib/tasks/plugin.rake:354:in `system'
/src/lib/tasks/plugin.rake:354:in `block (2 levels) in <main>'
/src/lib/tasks/plugin.rake:344:in `chdir'
/src/lib/tasks/plugin.rake:344:in `block in <main>'
Tasks: TOP => plugin:create
(See full trace by running task with --trace)
プラグインを作成しようとする前に、まずコンテナ内に .gitconfig をセットアップする必要があります(必要に応じてメールアドレスと名前を変更してください)。
d/exec git config --global user.email "you@example.com"
d/exec git config --global user.name "Your Name"
d/rake plugin:create[plugin-name]
「いいね!」 1