在规范中添加主题依赖项

As a Discourse theme author, I want to be able to specify child/component themes that are required for my theme to work correctly, so the user (Discourse site admin) doesn’t have to manually go out and add/configure it.

We are working on a downstream theme to work alongside the Mozilla theme (thanks @LeoMcA!) but it’d be nice if we didn’t have to manually specify import their theme and manually link them. Could such a relationship be added to the about.json file?

11 个赞

An aside, this would also benefit developers who build themes for clients. It’s becoming a more appealing setup to use a public theme and then tweak it for the client site. But more and more often, they want their customized theme in GitHub for pulling updates and allowing multiple people to work on them. It’d be great to embed the dependency somehow.

11 个赞

Asking for advanced features like this makes me :blush:, means the system is being used

Not against building this but needs very careful testing

6 个赞

I imagine it’d also be useful for you to be able to specify a particular version/commit that the theme depends on - that way, if we completely change something you’re depending on, it won’t all suddenly break on your end.

4 个赞

Yes, good point … although makes it a bit more complex. :slight_smile:

Maybe. If you can add the dependency as a GitHub link of sorts that allows a specific commit, branch, or tag, it gets easier. But that doesn’t mean the whole feature is easy.

5 个赞

Or any non-GH Git repository :wink:

1 个赞

@vinothkannans 刚刚添加了对依赖主题组件初始列表的支持,这样安装捆绑包会容易得多。

他将在此发布更多详情!

1 个赞

现在,顶级主题可以在 about.json 文件中指定子主题组件列表。例如:

{
  "name": "Material Design Theme",
  "about_url": "https://meta.discourse.org/t/material-design-stock-theme/47142",
  "license_url": "https://github.com/discourse/material-design-stock-theme/blob/master/LICENSE.txt",
  "components": ["https://github.com/discourse/discourse-brand-header", "https://github.com/Chaboi45/Take-a-break-component"]
  .
  .
  .
}

目前存在以下限制:

  1. 所有子主题组件仅在首次安装时安装。
  2. 如果之后在 about.json 中移除了组件,已安装的子主题组件不会被卸载。
  3. 如果手动删除了已安装的主题组件,系统将不会重新安装它。
  4. 无法为另一个主题组件指定子主题组件。
5 个赞

我在想,是否可以考虑允许为捆绑的主题组件设置默认配置。

例如,修改 Discourse Button Stylessettings.yml 的默认值,使其匹配顶级主题的具体数值。

(目前我认为您可能需要分叉该主题组件才能实现这一点。)