Template:Github url
Template documentation
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/nmr-relax/code/ci/master/tree/
To use the <code> tags:
{{#tag:code|{{#tag:nowiki| {{repo link | full = 1 }} }}}}
https://sourceforge.net/p/nmr-relax/code/ci/master/tree/
Examples
Base site URL
This is for the GitHub website when no parameters are supplied.
{{github url}}.
Project given
{{github url|nmr-relax|website}}
https://github.com/nmr-relax/website
The source repository
This is a link to https://github.com/nmr-relax/relax/tree/master.
{{github url | proj = nmr-relax | repo = relax | branch = master }}.
https://github.com/nmr-relax/relax/tree/master.
File with line number
This is a link to https://github.com/nmr-relax/relax/tree/master/gui/spin_viewer/tree.py#L68.
{{github url | proj = nmr-relax | repo = relax | path = gui/spin_viewer/tree.py | line = 68 }}.
https://github.com/nmr-relax/relax/tree/master/gui/spin_viewer/tree.py#L68.
Branch
This is a link to https://github.com/nmr-relax/relax/tree/j_couplings.
{{github url | proj = nmr-relax | repo = relax | branch = j_couplings }}.
https://github.com/nmr-relax/relax/tree/j_couplings.
Tag
This is a link to https://github.com/nmr-relax/relax/tree/4.0.3.
{{github url | proj = nmr-relax | repo = relax | tag = 4.0.3 }}.
https://github.com/nmr-relax/relax/tree/4.0.3.
Tag, history view
This is a link to https://github.com/nmr-relax/relax/commits/4.0.3.
{{github url | proj = nmr-relax | repo = relax | tag = 4.0.3 | view = commits }}.
https://github.com/nmr-relax/relax/commits/4.0.3.
Commit
Note For a simpler interface for this specific example, see {{relax commit}}. |
This is a link to https://github.com/nmr-relax/relax/commit/bb91d693f4102f81735e2a965cc1eed610211753.
{{github url | proj = nmr-relax | repo = relax | commit = bb91d693f4102f81735e2a965cc1eed610211753 | view = commit }}.
https://github.com/nmr-relax/relax/commit/bb91d693f4102f81735e2a965cc1eed610211753.
Commit, history view
This is a link to https://github.com/nmr-relax/relax/commits/6105c8.
{{github url | proj = nmr-relax | repo = relax | commit = 6105c8 | view = commits }}.
https://github.com/nmr-relax/relax/commits/6105c8.
Repository clone
Note For a simpler interface for this specific example, see {{github clone}} and {{relax clone}}. |
This is for git clone https://github.com/nmr-relax/relax.git relax
.
{{#tag:code|{{#tag:nowiki|{{github url | cmd = git clone | protocol = git | type = git | proj = nmr-relax | repo = relax | post = relax | full = 1 }}}}}}.
git clone https://github.com/nmr-relax/relax.git relax
.
Or as plain text:
{{#tag:nowiki|{{github url | cmd = git clone | protocol = git | type = git | proj = nmr-relax | repo = relax | post = relax | full = 1 }}}}.
git clone https://github.com/nmr-relax/relax.git relax.
Aliased parameters
This is a link to https://github.com/nmr-relax/relax/tree/j_couplings/generic_fns/align_tensor.py#L68.
{{github url | p = nmr-relax | r = relax | b = j_couplings | f = generic_fns/align_tensor.py | l = 68 }}.
https://github.com/nmr-relax/relax/tree/j_couplings/generic_fns/align_tensor.py#L68.
Numbered parameters
This is a link to https://github.com/nmr-relax/relax/tree/j_couplings/generic_fns/align_tensor.py#L68.
{{github url | nmr-relax | relax | j_couplings | generic_fns/align_tensor.py | l=68 }}.
https://github.com/nmr-relax/relax/tree/j_couplings/generic_fns/align_tensor.py#L68.
Related templates
|