Template:Github url
Goal
This template is for creating direct URLs for the content of the version control repositories of the GitHub open source infrastructure. This is equivalent to the {{github source}} template with the full parameter set to 1. It is a subtemplate of the master {{repo link}} template designed to be specific for the GitHub repositories.
Usage
{{github url | cmd = | opt = | type = | user = | proj = | repo = | branch = | tag = | commit = | path = | line = | post = | view = }}
Either the user or proj parameter, as well as the repo parameter, must be supplied. All other parameters are optional.
Parameter | Description | Abbreviated parameter |
Numbered parameter |
Status |
---|---|---|---|---|
cmd | An optional command line tool name + options to prepend to the URL. For example git clone. | optional | ||
opt | Any additional options to show after cmd, but before the URL.
|
optional | ||
type | Choose between the web interface, a direct repository link, or a zip file download. This can be one of git, git webzip. See the {{* zip file}} templates for a simplified interface for the zip files. The default is git web. | optional | ||
user | The name of the user page for the open source infrastructure. This is notably different to the login parameter. This will have precedence over the proj parameter. The user page is treated in the same way as a project name. | u | 1 | mandatory |
proj | The name of the project, consisting of a grouping of repositories on the open source infrastructure. | p | 1 | mandatory |
repo | The name of the repository. A project registered on one of the open source infrastructures generally allows for multiple repositories under that project name. | r | 2 | mandatory |
branch | The branch name. This defaults to next. | b | 3 | optional |
tag | The repository tag name. | t | optional | |
commit | The commit identifier (git hash). This defaults to HEAD. | c | 5 | optional |
path | The file or directory path. | f | 4 | optional |
line | The line number(s) of the file to display.
|
l | optional | |
post | Text to append. This is forms a set with the parameter cmd and opt. For example it can represent any command line options that come after the URL. | optional | ||
view | View to display:
|
v | optional |
Design
In this section, the following notation will be used:
- Angular brackets + lower case text
<xyz>
- Template parameters.
- Angular brackets + upper case text
<XYZ>
- Template constructed text.
- Square brackets
[xyz]
- Optional text, only added if the parameter is set.
- Or symbol
|
- The value on the left, if present, otherwise the value on the right of the symbol.
Overview
The general design is:
<cmd> <opt> <URL> <post>
Site: GitHub
The base URL for GitHub repositories is:
<protocol>://github.com/<user|proj>/<repo>
GitHub <URL> for 'type=git'
For this parameter value, the complete <URL>
value will be:
<protocol>://github.com/<user|proj>/<repo>.git
GitHub <URL> for 'type=git web'
For this parameter value, the <URL>
value will be:
<protocol>://github.com/<user|proj>/<repo>/<view>/<commit|branch>[/<path>][#L<line>]
GitHub <URL> for 'type=zip'
For this parameter value, the zip file URL will be:
<protocol>://github.com/<proj>/<repo>/archive/<commit|tag|branch>.zip
If neither a commit, branch, nor tag is specified, the URL will default to:
<protocol>://github.com/<proj>/<repo>/archive/master.zip
GitHub URL <TEXT> for 'type=git' and 'type=git web'
The link text <TEXT>
, if the full parameter is not set, will be:
github/<user|proj>/<repo>/<commit|branch|HEAD>[/<path>][#L<line>]
If the simplepath parameter is set, this changes to:
[/<path>][#L<line>]
If the pre parameter is supplied, this changes to:
<pre>[/<path>][#L<line>]
The text parameter trumps all, and <TEXT>
is simply:
<text>
GitHub URL <TEXT> for 'type=zip'
The link text <TEXT>
, if the full parameter is not set, will be:
github/<user|proj>/<repo>/[<commit|tag|branch>] zip file
If the simplepath parameter is set, this changes to:
zip file
If the pre parameter is supplied, this changes to:
<pre> zip file
The text parameter trumps all, and <TEXT>
is simply:
<text>
Plain text
To create a URL or link as plain text and avoid external links, simply use the {{#tag:tagname|content}}
magic word construct:
{{#tag:nowiki| {{repo link | full = 1 }} }}
https://sourceforge.net/p/flightgear/flightgear/ci/next/tree/
To use the <code> tags:
{{#tag:code|{{#tag:nowiki| {{repo link | full = 1 }} }}}}
https://sourceforge.net/p/flightgear/flightgear/ci/next/tree/
Examples
No parameters given
{{github url}}
Project given
{{github url|ruby|ruby}}
Project and path given
{{github url|NikolaiVChr|flightgear-saab-ja-37-viggen|f=Aircraft/JA37/readme.txt}}
https://github.com/NikolaiVChr/flightgear-saab-ja-37-viggen/tree/master/Aircraft/JA37/readme.txt
Project, path and a commit reference given
{{github url|NikolaiVChr|flightgear-saab-ja-37-viggen|f=index.html|b=gh-pages}}
https://github.com/NikolaiVChr/flightgear-saab-ja-37-viggen/tree/gh-pages/index.html
{{github url|NikolaiVChr|flightgear-saab-ja-37-viggen|f=Aircraft/JA37|t=FG-v3.4}}
https://github.com/NikolaiVChr/flightgear-saab-ja-37-viggen/tree/FG-v3.4/Aircraft/JA37
{{github url|NikolaiVChr|flightgear-saab-ja-37-viggen|f=Aircraft/JA37/readme.txt|commit=79282e8}}
https://github.com/NikolaiVChr/flightgear-saab-ja-37-viggen/tree/79282e8/Aircraft/JA37/readme.txt
{{github url|NikolaiVChr|flightgear-saab-ja-37-viggen|f=Aircraft/JA37/readme.txt|commit=79282e899712784c4bb21c04cc7482eca3908f71}}
Line parameter given
{{github url|NikolaiVChr|flightgear-saab-ja-37-viggen|f=Aircraft/JA37/Nasal/radar.nas|l=2}}
Mulitple lines given
{{github url|NikolaiVChr|flightgear-saab-ja-37-viggen|f=Aircraft/JA37/Nasal/radar.nas|l=17-22}}
The c172p-detailed repository
This is for the c172p-detailed repository https://github.com/Juanvvc/c172p-detailed/tree/master (this is the same as https://github.com/Juanvvc/c172p-detailed).
{{github url | user = Juanvvc | repo = c172p-detailed }}
https://github.com/Juanvvc/c172p-detailed.
Git clone
This is for cloning the c172p-detailed aircraft with git clone https://github.com/Juanvvc/c172p-detailed.git
.
{{#tag:code | {{#tag:nowiki | {{github url | cmd = git clone | user = Juanvvc | repo = c172p-detailed | type = git }} }} }}
git clone https://github.com/Juanvvc/c172p-detailed.git
File with line number
This is for https://github.com/Juanvvc/c172p-detailed/blob/release/2016.1/c172p-set.xml#L49.
{{github url | user = Juanvvc | repo = c172p-detailed | view = blob | branch = release/2016.1 | path = c172p-set.xml | line = 49 }}.
https://github.com/Juanvvc/c172p-detailed/blob/release/2016.1/c172p-set.xml#L49.
Raw view
This is for https://github.com/Juanvvc/c172p-detailed/raw/master/c172p-set.xml, which will redirect itself to https://raw.githubusercontent.com/Juanvvc/c172p-detailed/master/c172p-set.xml.
{{github url | user = Juanvvc | repo = c172p-detailed | view = raw | path = c172p-set.xml }}.
https://github.com/Juanvvc/c172p-detailed/raw/master/c172p-set.xml.
Commit
This is for https://github.com/Juanvvc/c172p-detailed/commit/df6f10608116674643a3cc4bf18819eeee016d42.
{{github url | user = Juanvvc | repo = c172p-detailed | view = commit | commit = df6f10608116674643a3cc4bf18819eeee016d42 }}.
https://github.com/Juanvvc/c172p-detailed/commit/df6f10608116674643a3cc4bf18819eeee016d42.
Tree view at a given commit
This is for https://github.com/Juanvvc/c172p-detailed/tree/df6f10608116674643a3cc4bf18819eeee016d42.
{{github url | user = Juanvvc | repo = c172p-detailed | view = tree | commit = df6f10608116674643a3cc4bf18819eeee016d42 }}.
https://github.com/Juanvvc/c172p-detailed/tree/df6f10608116674643a3cc4bf18819eeee016d42.
Main views
History view
This is for https://github.com/Juanvvc/c172p-detailed/commits/master.
{{github url | user = Juanvvc | repo = c172p-detailed | view = commits }}.
https://github.com/Juanvvc/c172p-detailed/commits/master.
History view from a commit
This is for https://github.com/Juanvvc/c172p-detailed/commits/df6f10608116674643a3cc4bf18819eeee016d42.
{{github url | user = Juanvvc | repo = c172p-detailed | view = commits | commit = df6f10608116674643a3cc4bf18819eeee016d42 }}.
https://github.com/Juanvvc/c172p-detailed/commits/df6f10608116674643a3cc4bf18819eeee016d42.
Aliased parameters
This is for https://github.com/Juanvvc/c172p-detailed/blob/release/2016.1/c172p-set.xml#L49.
{{github url | u = Juanvvc | r = c172p-detailed | v = blob | b = release/2016.1 | f = c172p-set.xml | l = 49 }}.
https://github.com/Juanvvc/c172p-detailed/blob/release/2016.1/c172p-set.xml#L49.
Numbered parameters
This is for https://github.com/Juanvvc/c172p-detailed/blob/release/2016.1/c172p-set.xml#L49.
{{github url | Juanvvc | c172p-detailed | release/2016.1 | c172p-set.xml | l = 49 | v = blob }}.
https://github.com/Juanvvc/c172p-detailed/blob/release/2016.1/c172p-set.xml#L49.
Related templates
|