Allow override of default GitHub buttons
bkimminich opened this issue · 5 comments
Right now each page shows the "Likes" and "Followers" of the website repository, e.g. for Juice Shop that of https://github.com/OWASP/www-project-juice-shop:
It would be better to introduce a new optional Jekyll variable like github
which can be set to the project/chapter main repository URL. For Juice Shop that would be https://github.com/bkimminich/juice-shop and yield a much more impressive:
The GitHub buttons should use this URL and fall back to the website repo if github
is not specified.
How can we help make this happen?
I'm not good with the inner workings of Jekyll, but it should be nothing more than:
- Introduce a page (or better: site) variable like
githubCodeRepo
- Change
www--site-theme/_layouts/col-sidebar.html
Lines 34 to 35 in f96e48e
githubCodeRepo
is used when it exists... - ...but otherwise the page repo is used
@hblankenship could we do it like this? (If so I'll open a PR)
<div class="github-buttons">
<iframe src="https://ghbtns.com/github-btn.html?user=owasp&repo={{ site.github.code_repo | default: site.github.repository_name }}&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe>
<iframe src="https://ghbtns.com/github-btn.html?user=owasp&repo={{ site.github.code_repo | default: site.github.repository_name }}&type=watch&count=true&v=2" frameborder="0" scrolling="0" width="170px" height="20px"></iframe>
</div>
Edit: I guess we would also have to provide the option to override and default user, since not all code repos are within owasp. But that'd be handled the same way, so let me know.
This ended up being implemented as
www--site-theme/_layouts/col-sidebar.html
Lines 34 to 35 in cb69932
The _config.yml
change needed for each project would be like https://github.com/OWASP/www-project-zap/blob/381b3432e3722fc49b330edad16a4af37e83e539/_config.yml#L3-L5:
#override default star and watch buttons
code_user: zaproxy
code_repo: zaproxy