A discussion was started by danekhollas about adding a direct link to a theme’s Github repository on its page. The current links to “About theme” and the license are not helpful when a theme is forked and modified locally. danekhollas suggested adding a link below the “Check updates” button and including the branch name if the theme was imported from a specific branch.
zogstrip agreed with the idea and encouraged danekhollas to submit a pull request (PR) with before/after screenshots. danekhollas started working on the feature but encountered issues with Handlebars, including accessing the remote theme’s branch and creating a proper Github link for non-default branches.
sam pointed out that the feature should not be specific to Github, as other platforms like Bitbucket and Gitlab are also supported. danekhollas acknowledged this and changed the feature to be more general.
After some iterations, danekhollas submitted a draft PR with a “Source” link for remote themes, but it still had a minor issue with the link always going to the default branch. sam asked vinothkannans to review the PR and add a small JavaScript test. The feature was eventually merged into the commit 48d690ae01e6a65c2c5ac7995b7e0b8a741599c2.
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.
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.
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:
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.
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.