Template:Github source

From relax wiki
Jump to navigation Jump to search

GitHub website

Template documentation

Goal

This template is for creating links or URLs for the content of the version control repositories of the GitHub open source infrastructure. It is a subtemplate of the master {{repo link}} template designed to be specific for the GitHub repositories.

Usage

{{github source
| cmd        =
| opt        =
| type       =
| user       =
| proj       =
| repo       =
| branch     =
| tag        =
| commit     =
| path       =
| line       =
| post       =

| view       =
| text       =
| pre        =
| simplepath =
| full       =
}}

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.
Note The separation of cmd and opt is for future non-CLI handling of a standardised set of cmd parameter values
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. 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.
  • For GitHub either use:
    • A single line number, for example 2.
    • Two line numbers separated with a hyphen (-), for example 3-10.
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:
  • For GitHub use one of blob, blame, commit, commits or raw. The default is tree.
v optional
text Text to display as the link label. Overrides pre. t optional
pre Prefix to a link label. optional
simplepath If set, this strips off the repository name from the URL label, leaving just the contents of the path parameter.
Note The text parameter will override this.
optional
full If set to 1, the full URL will be shown rather than any text label. 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> <TEXT>] <post>

Here the square brackets do not denote optional text, but will instead produce a Mediawiki link. This can be modified by setting full = 1 to produce:

<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 source}}.

GitHub website.

{{github source|full=1}}.

https://github.com.

The source repository

This is a link to https://github.com/nmr-relax/relax/tree/master.

{{github source
| proj   = nmr-relax
| repo   = relax
| branch = master
| text   = The relax source repository
}}.

The relax source repository.

File with line number

This is a link to https://github.com/nmr-relax/relax/tree/master/gui/spin_viewer/tree.py#L68.

{{github source
| proj = nmr-relax
| repo = relax
| path = gui/spin_viewer/tree.py
| line = 68
}}.

github/nmr-relax/relax/gui/spin_viewer/tree.py#L68.

File prefixed with $RELAX_SRC

This is a link to https://github.com/nmr-relax/relax/tree/master/pipe_control/diffusion_tensor.py. The expected link text is "$RELAX_SRC/pipe_control/diffusion_tensor.py".

{{github source
| proj = nmr-relax
| repo = relax
| path = pipe_control/diffusion_tensor.py
| pre  = $RELAX_SRC
}}.

$RELAX_SRC/pipe_control/diffusion_tensor.py.

Branch

This is a link to https://github.com/nmr-relax/relax/tree/j_couplings.

{{github source
| proj   = nmr-relax
| repo   = relax
| branch = j_couplings
}}.

github/nmr-relax/relax/j_couplings.

Tag

This is a link to https://github.com/nmr-relax/relax/tree/4.0.3.

{{github source
| proj = nmr-relax
| repo = relax
| tag  = 4.0.3
}}.

github/nmr-relax/relax/4.0.3.

Tag, history view

This is a link to https://github.com/nmr-relax/relax/commits/4.0.3.

{{github source
| proj = nmr-relax
| repo = relax
| tag  = 4.0.3
| view = commits
}}.

github/nmr-relax/relax/4.0.3 history view.

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 source
| proj   = nmr-relax
| repo   = relax
| commit = bb91d693f4102f81735e2a965cc1eed610211753
| view   = commit
}}.

github/nmr-relax/relax/bb91d693f4102f81735e2a965cc1eed610211753 commit view.

Commit, history view

This is a link to https://github.com/nmr-relax/relax/commits/6105c8.

{{github source
| proj   = nmr-relax
| repo   = relax
| commit = 6105c8
| view   = commits
}}.

github/nmr-relax/relax/6105c8 history view.

Repository clone

Note  For a simpler interface for this specific example, see {{github clone}} and {{relax clone}}.

This is for git clone git://git.code.sf.net/p/nmr-relax/relax relax.

{{#tag:code|{{#tag:nowiki|{{github source
| 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 source
| 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 source
| p    = nmr-relax
| r    = relax
| b    = j_couplings
| f    = generic_fns/align_tensor.py
| l    = 68
| full = 1
}}.

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 source | nmr-relax | relax | j_couplings | generic_fns/align_tensor.py | l=68 | full = 1 }}.

https://github.com/nmr-relax/relax/tree/j_couplings/generic_fns/align_tensor.py#L68.

Related templates