# 为远程主题显示 GitHub 链接

**URL:** https://meta.discourse.org/t/display-link-to-github-for-remote-themes/99490
**Category:** UX
**Created:** [2018 年10 月 14 日 22:11 UTC](https://meta.discourse.org/t/display-link-to-github-for-remote-themes/99490 "2018-10-14T22:11:57Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![danekhollas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danekhollas/32/79637_2.png) [@danekhollas](https://meta.discourse.org/u/danekhollas)
#### Post date: [2018 年10 月 14 日 22:11 UTC](https://meta.discourse.org/t/display-link-to-github-for-remote-themes/99490/1 "2018-10-14T22:11:57Z")

</div>

Hi folks,

it would be nice if a remote theme page contained a direct link to the respective Github repo.  
There is a link “About theme” which typically leads to a topic here on meta (where the link to github can be found) and the _License_ link would typically link to the github repo. However, both of these are useless if you happen to fork a theme and make local modifications.

Maybe something like this could work?

 ![image](https://global.discourse-cdn.com/meta/original/3X/0/4/0422a84c60b7b351da65915fd87b757b0e6b8738.png)

Alternatively, the link could be below the _Check updates_ button.

Also, now that we can import from specific branches, the branch itself should be displayed as well or at least the link to Github should go to that branch.

If this sounds reasonable, would you accept a PR?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2018 年10 月 16 日 10:42 UTC](https://meta.discourse.org/t/display-link-to-github-for-remote-themes/99490/2 "2018-10-16T10:42:12Z")

</div>

> [@danekhollas](#):
>
> If this sounds reasonable, would you accept a PR?

Definitely would!

Be sure to include before/after screenshots as well 😉

---

<div class="post-metadata">

### Author: ![danekhollas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danekhollas/32/79637_2.png) [@danekhollas](https://meta.discourse.org/u/danekhollas)
#### Post date: [2018 年10 月 21 日 19:46 UTC](https://meta.discourse.org/t/display-link-to-github-for-remote-themes/99490/3 "2018-10-21T19:46:14Z")

</div>

Hmm, I started working on this [here](https://github.com/danielhollas/discourse/commit/b177079813d3d2d16b84850977695c92e2b81e57), but am having two problems (I am Handlebars noob so they are probably trivial):

1. In [app/assets/javascripts/admin/templates/customize-themes-show.hbs](https://github.com/danielhollas/discourse/commit/b177079813d3d2d16b84850977695c92e2b81e57#diff-93a808890360ff444d1146c0d7b4def0R24), I would expect variable `model.remote_theme.branch` to work, but it doesn’t i.e it does not return the non-default branch that I imported.

2. I will probably need a Handlebars helper to create a proper Github link for non-default branch, but I do not know where to put the code. I will need something like this:

```js
Handlebars.registerHelper('getGithubUrl', function(baseUrl, branch) {
   if (! branch) { 
     return baseUrl;
   } else {
     // strip '.git' from the end, it is added there automatically in GitImporter
     var url = str.substring( 0, str.indexOf( ".git" ) );;
     return url + '/tree/' + branch;
   }
});

```

Sorry for noob questions, any pointers will be highly appreciated. 😊

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2018 年10 月 22 日 03:57 UTC](https://meta.discourse.org/t/display-link-to-github-for-remote-themes/99490/4 "2018-10-22T03:57:28Z")

</div>

One quick note here, I am not too easy baking “GitHub” into our UIs here, we want to allow diversity here, if people want to use bitbucket or gitlab for themes it is A-OK.

---

<div class="post-metadata">

### Author: ![danekhollas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danekhollas/32/79637_2.png) [@danekhollas](https://meta.discourse.org/u/danekhollas)
#### Post date: [2018 年10 月 22 日 05:23 UTC](https://meta.discourse.org/t/display-link-to-github-for-remote-themes/99490/5 "2018-10-22T05:23:54Z")

</div>

Thank you! I wasn’t sure others are supported, will change it.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2018 年11 月 8 日 19:25 UTC](https://meta.discourse.org/t/display-link-to-github-for-remote-themes/99490/6 "2018-11-08T19:25:55Z")

</div>

We should own this feature and not outsource it @sam

---

<div class="post-metadata">

### Author: ![danekhollas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/danekhollas/32/79637_2.png) [@danekhollas](https://meta.discourse.org/u/danekhollas)
#### Post date: [2020 年3 月 12 日 00:26 UTC](https://meta.discourse.org/t/display-link-to-github-for-remote-themes/99490/7 "2020-03-12T00:26:39Z")

</div>

现在远程主题有一个很棒的“源代码”链接！👏

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/1/1139bdb7076091c0e856476c26bb8575721c7775.png)

不过如果能有一个小改进就更好了。该链接始终指向默认分支，即使主题是从自定义分支导入的。

我笨拙地尝试修复这个问题，但没能完全成功。我已提交了一个草稿 PR，如果有人愿意帮忙或接手，请随时联系。谢谢！

> <https://github.com/discourse/discourse/pull/9184>
>
> I am trying to improve the remote theme "Source" link in Admin-\>Customize-\>Theme…s so that it points to the branch that was selected during import (if it was non-default). Without this, admins have no good way of knowing which branch was used in the initial import.
> 
> !\[image\](https://user-images.githubusercontent.com/9539441/76475453-3417b280-63ff-11ea-8830-7d4418cc9f20.png)
> 
> Nevertheless, my code does not work for me. :sob: I am unable to access the \`model.remote\_theme.branch\`, neither from the template nor in the controller.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2020 年3 月 12 日 01:06 UTC](https://meta.discourse.org/t/display-link-to-github-for-remote-themes/99490/8 "2020-03-12T01:06:43Z")

</div>

修复得很棒，@vinothkannans 能否帮忙审查一下，并加一个简单的 JS 测试？

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [2020 年3 月 17 日 22:31 UTC](https://meta.discourse.org/t/display-link-to-github-for-remote-themes/99490/10 "2020-03-17T22:31:23Z")

</div>

> <https://github.com/discourse/discourse/commit/48d690ae01e6a65c2c5ac7995b7e0b8a741599c2>

现已合并至上述提交。
