Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Template:Github source

From FlightGear wiki
Jump to: navigation, search

GitHub website


The following template description is not displayed when the template is inserted in an article.

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/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

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 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 source
| user = Juanvvc
| repo = c172p-detailed
| text = A high detailed version of the C172P aircraft for FlightGear
}}

A high detailed version of the C172P aircraft for FlightGear.

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 source
  | cmd  = git clone
  | user = Juanvvc
  | repo = c172p-detailed
  | type = git
  | full = 1
  }}
}} }}

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 source
| user   = Juanvvc
| repo   = c172p-detailed
| view   = blob
| branch = release/2016.1
| path   = c172p-set.xml
| line   = 49
| text   = The c172p-detailed authors
}}.

The c172p-detailed authors.

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 source
| user = Juanvvc
| repo = c172p-detailed
| view = raw
| path = c172p-set.xml
}}.

github/Juanvvc/c172p-detailed/master/c172p-set.xml raw view.

Commit

This is for https://github.com/Juanvvc/c172p-detailed/commit/df6f10608116674643a3cc4bf18819eeee016d42.

{{github source
| user   = Juanvvc
| repo   = c172p-detailed
| view   = commit
| commit = df6f10608116674643a3cc4bf18819eeee016d42
}}.

github/Juanvvc/c172p-detailed/df6f10608116674643a3cc4bf18819eeee016d42 commit view.

Tree view at a given commit

This is for https://github.com/Juanvvc/c172p-detailed/tree/df6f10608116674643a3cc4bf18819eeee016d42.

{{github source
| user   = Juanvvc
| repo   = c172p-detailed
| view   = tree
| commit = df6f10608116674643a3cc4bf18819eeee016d42
}}.

github/Juanvvc/c172p-detailed/df6f10608116674643a3cc4bf18819eeee016d42.

Main views

History view

This is for https://github.com/Juanvvc/c172p-detailed/commits/master.

{{github source
| user   = Juanvvc
| repo   = c172p-detailed
| view   = commits
}}.

github/Juanvvc/c172p-detailed/master history view.

History view from a commit

This is for https://github.com/Juanvvc/c172p-detailed/commits/df6f10608116674643a3cc4bf18819eeee016d42.

{{github source
| user   = Juanvvc
| repo   = c172p-detailed
| view   = commits
| commit = df6f10608116674643a3cc4bf18819eeee016d42
}}.

github/Juanvvc/c172p-detailed/df6f10608116674643a3cc4bf18819eeee016d42 history view.

Aliased parameters

This is for https://github.com/Juanvvc/c172p-detailed/blob/release/2016.1/c172p-set.xml#L49.

{{github source
| u    = Juanvvc
| r    = c172p-detailed
| v    = blob
| b    = release/2016.1
| f    = c172p-set.xml
| l    = 49
| full = 1
}}.

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 source | Juanvvc | c172p-detailed | release/2016.1 | c172p-set.xml | l = 49 | v = blob | full = 1 }}.

https://github.com/Juanvvc/c172p-detailed/blob/release/2016.1/c172p-set.xml#L49.

Related templates