Template:Github url
Jump to navigation
Jump to search
The following template description is not displayed when the template is inserted in an article.
Goal
This template will return the URL of directory in GitHub, and optionally a file in that directory.
Usage
{{github url|project|path|l=|r=}}
All parameters are optional.
- project
- The name of the project, which is comes between
https://github.com/
and/blob/...
in the URL. If empty, the link will point to https://github.com.
- path
- What follows after
/blob/<branch>/
in the URL. Can be the path to a file or a directory. If empty, the link will point to the root of the project.
- l
- A line number. This could just be a single number, or, when linking to a range of lines, two line numbers separated by a slash (/), for example
l=1/5
.
- r
- A commit reference. Usually the SHA-1 commit ID (which can be abbreviated), but it can also be a tag or a branch name. If empty, the link will point to the master branch.
Examples
No parameters given
{{github url}}
Project given
{{github url|ruby/ruby}}
Project and path given
{{github url|NikolaiVChr/flightgear-saab-ja-37-viggen|Aircraft/JA37/readme.txt}}
https://github.com/NikolaiVChr/flightgear-saab-ja-37-viggen/blob/master/Aircraft/JA37/readme.txt
Project, path and a commit reference given
{{github url|NikolaiVChr/flightgear-saab-ja-37-viggen|index.html|r=gh-pages}}
https://github.com/NikolaiVChr/flightgear-saab-ja-37-viggen/blob/gh-pages/index.html
{{github url|NikolaiVChr/flightgear-saab-ja-37-viggen|Aircraft/JA37|r=FG-v3.4}}
https://github.com/NikolaiVChr/flightgear-saab-ja-37-viggen/blob/FG-v3.4/Aircraft/JA37
{{github url|NikolaiVChr/flightgear-saab-ja-37-viggen|Aircraft/JA37/readme.txt|r=79282e8}}
https://github.com/NikolaiVChr/flightgear-saab-ja-37-viggen/blob/79282e8/Aircraft/JA37/readme.txt
{{github url|NikolaiVChr/flightgear-saab-ja-37-viggen|Aircraft/JA37/readme.txt|r=79282e899712784c4bb21c04cc7482eca3908f71}}
Line parameter given
{{github url|NikolaiVChr/flightgear-saab-ja-37-viggen|Aircraft/JA37/Nasal/radar.nas|l=2}}
Mulitple lines given
{{github url|NikolaiVChr/flightgear-saab-ja-37-viggen|Aircraft/JA37/Nasal/radar.nas|l=17/22}}
Usage in a wiki URL
[{{github url|NikolaiVChr/flightgear-saab-ja-37-viggen|Aircraft/JA37/changelog.txt}} See the JA 37's changelog]
Related templates
Source link templates
- {{fgaddon url}}
- {{fgdata file}}
- {{simgear file}}
- {{flightgear file}}
- {{repo link}} — Should be considered decrepitated, replaced by the above
Commit link templates
- {{fgaddon revision}}
- {{fgdata commit}}
- {{simgear commit}}
- {{flightgear commit}}
Other
- {{gitlab url}}