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.
첫 번째 작은 플러그인을 만들기 시작했어요 몇 가지 질문이 있는데, 누가 도와줄 수 있을까요…
첫 번째 질문은 이 가이드에 있는 것을 사용해도 되는지, 아니면 정말로 플러그인 생성기를 사용해야 하는지 여부입니다.
이 가이드에서는 다루지 않았지만, plugin.rb 파일에서 데이터를 템플릿에 어떻게 사용할 수 있게 할 수 있을까요?
예를 들어, 누군가가 토픽을 방문할 때마다 topic-above-posts 플러그인 아웃렛에 랜덤한 환영 메시지를 표시하고 싶다고 가정해 보겠습니다. 이 메시지는 plugin.rb에 있는 배열에서 랜덤으로 선택됩니다… 그렇다면 이 데이터를 템플릿으로 어떻게 전송해야 할까요? 그리고 이 템플릿도 아마 여기에 있어야 할 것 같습니다:
plugins/my_new_plugin/assets/javascripts/discourse/templates/connectors/topic-above-posts/my_new_plugin.hbs (이 위치가 맞나요?)
플러그인 생성기를 사용하는 것은 시작하는 데 일반적으로 좋은 방법이며, 플러그인이 어떻게 구조화되어야 하는지 살펴볼 수 있습니다. 이를 권장합니다.
자바 코드를 프론트 엔드에 포함하는 방법에 대해 말씀드리자면, 이는 두 개의 다른 애플리케이션입니다. 프론트 엔드 애플리케이션(Ember)은 서버(Rails)에서 이를 요청해야 합니다. 일반적으로 AJAX 호출을 통해 이렇게 하지만, SiteSerializer에 추가하여 포럼 데이터의 일부로 자동으로 전송되도록 하는 것과 같은 다른 방법도 사용할 수 있습니다.
그렇지 않다면, rails에서 라우트/컨트롤러를 추가하는 방법과 메시지를 JSON으로 전송하는 방법을 찾아봐야 합니다.
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를 설정해야 합니다(이메일과 이름을 필요에 맞게 변경하십시오):