大家好
我刚读了这篇帖子 How to display full name in comments embeds
我运行了这些命令。
cd /var/discourse
./launcher enter app
检测到 x86_64 架构。
root@discourse-app:/var/www/discourse# cd app/views/embed/
root@discourse-app:/var/www/discourse/app/views/embed# nano comments.html.erb
Nano 未安装,所以我安装了它并编辑了 comments.html.erb,替换了所引用帖子中提到的行。
然后我退出了启动器并运行了
./launcher rebuild app
重建后没有任何区别,我仍然在嵌入式内容中看到用户名而不是全名。
我哪里做错了?
谢谢
2 个赞
Canapin
(Coin-coin le Canapin)
2023 年2 月 16 日 10:59
2
欢迎您,Mark!
重新构建应用程序会重新下载 Discourse,并会覆盖您在容器内所做的任何更改。
如果您想对 Discourse 进行修改,以这种方式编辑这些文件不是正确的方法。
自定义 Discourse 的功能通常通过主题组件实现:
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…
或插件:
如果您具备一些编码知识,我建议您查看这些链接。
这个链接可能特别有趣:
乍一看,它似乎正是您想要的。它只是针对同一个父文件夹中的另一个文件。
1 个赞
@Canapin 感谢您的建议。
我创建了这个仓库 https://github.com/OptDev/optuma-discourse-custom-embed
但进展不大。
我运行了这个命令,它构建时没有报错
./launcher enter app
但我似乎没有看到我期望在嵌入中看到的更改。我添加了几个自定义的 CSS 类名,并将 <%= post.user.username %> 改为了 <%= post.user.name %>。如果能给我一些关于如何让它工作的进一步指导,我将不胜感激。我无法想象从另一个插件覆盖一个插件的模板文件会太复杂。
我能够做的是进入应用程序并手动将我的插件版本的模板复制到 /var/www/discourse/app/views/embed/,然后我重新启动应用程序,就能看到我想要的结果。
我只需要在插件加载时自动完成这个过程,而这正是我卡住的地方。
为什么这没有用我的插件中的文件覆盖 /app/views/embed/comments.html.erb 文件?
after_initialize do
::EmbedController.prepend_view_path File.expand_path("../embed", __FILE__)
end
好的,我之前是对的,只是路径有问题。
现在我只需要弄清楚如何从私有的 git 仓库拉取。
1 个赞
@merefield 这在 app.yml 文件中看起来会是怎样的?
没关系,我在这里找到了。Install plugins on a self-hosted site
有一点需要注意,文档中说要使用“token”…
git clone https://<token>@github.com/owner/repo.git
我发现我需要使用你的 github 用户名和 token
git clone https://<github-username>:<token>@github.com/owner/repo.git
1 个赞
Mark_Wass
(Mark Wass)
2023 年2 月 21 日 11:01
10
@Canapin 是的!全部搞定了。这是最终的 plugin.rb 文件。原来只是我放置自定义文件路径时出了问题。
我最终把它放在了一个文件夹 /custom_views/embed/comments.html.erb 中。
# frozen_string_literal: true
# name: optuma_discourse_custom_embed
# about: A simple plugin to used to customise the template in the forum embeds
# version: 1.0.0
# authors: Optuma Pty Ltd
# url: https://github.com/OptDev/optuma-discourse-custom-embed
# required_version: 2.7.0
after_initialize do
::EmbedController.prepend_view_path File.expand_path("../custom_views", __FILE__)
end
1 个赞
system
(system)
关闭
2023 年3 月 23 日 11:02
11
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.