Template:Simgear file: Difference between revisions

Jump to navigation Jump to search
Add t[ext] and nopath parameters, and change others as per Johan's suggestions at FGW:VP#Repository link templates
(Decided to remove path abbreviation ("simgear/simgear/..." → "simgear/...") so that it matches the path on a user's computer; added a non-breaking space)
(Add t[ext] and nopath parameters, and change others as per Johan's suggestions at FGW:VP#Repository link templates)
Line 1: Line 1:
[http://sourceforge.net/p/flightgear/simgear/ci/<!--
[http://sourceforge.net/p/flightgear/simgear/ci/<!--
-->{{#if: {{{2|}}} <!-- Is a commit reference defined? -->
-->{{#if: {{{r|}}} <!-- Is a commit reference defined? -->
   | <!-- Yes, a commit reference is defined --><!--
   | <!-- Yes, a commit reference is defined --><!--
     -->{{{2}}}<!--
     -->{{{r}}}<!--
     -->{{#if: {{#titleparts: {{{2|}}}|1|2}} <!-- Do the commit reference contain a slash? -->
     -->{{#if: {{#titleparts: {{{r|}}}|1|2}} <!-- Does the commit reference contain a slash? -->
       | <!-- Yes. Add a trailing slash and tilde after the reference (needed for the SourceForge URL). --><!--
       | <!-- Yes. Add a trailing slash and tilde after the reference (needed for the SourceForge URL). --><!--
         -->/~
         -->/~
     }}/tree/{{{1|}}}<!--
     }}/tree/{{{1|}}}<!--
     -->{{#if: {{{3|}}} <!-- Is a line defined? -->
     -->{{#if: {{{l|}}} <!-- Is a line defined? -->
       | &#35;l{{{3}}}
       | &#35;l{{{l}}}
     }} simgear/{{{1|}}}]&nbsp;({{{2}}}{{#if: {{{3|}}} | ,&nbsp;line&nbsp;{{{3}}} }})
     }} {{#if: {{{t|}}} | {{{t}}}] | {{#if: {{{nopath|}}} | | simgear/ }}{{{1|}}}] ({{{r}}}{{#if: {{{l|}}} | ,&nbsp;line&nbsp;{{{l}}} }}) }}
   | <!-- No, a commit reference is not defined.  Fall back on "next" and do not display commit reference. --><!--
   | <!-- No, a commit reference is not defined.  Fall back on "next" and do not display commit reference. --><!--
     -->next/tree/{{{1|}}}<!--
     -->next/tree/{{{1|}}}<!--
     -->{{#if: {{{3|}}} <!-- Is a line defined? -->
     -->{{#if: {{{l|}}} <!-- Is a line defined? -->
       | &#35;l{{{3}}}
       | &#35;l{{{l}}}
     }} simgear/{{{1|}}}]{{#if: {{{3|}}} | &nbsp;(line&nbsp;{{{3}}}) }}
     }} {{#if: {{{t|}}} | {{{t}}}] | {{#if: {{{nopath|}}} | | simgear/ }}{{{1|}}}]{{#if: {{{l|}}} | &nbsp;(line&nbsp;{{{l}}}) }} }}
}}<noinclude>
}}<noinclude>
{{Informative template|1=
{{Informative template|1=
Line 22: Line 22:


== Usage ==
== Usage ==
  {{obr}}'''simgear file'''{{!}}''path''{{!}}''reference''{{!}}''line''{{cbr}}
  {{obr}}'''simgear file'''{{!}}''path''{{!}}''l=''{{!}}''t=''{{!}}''r=''{{!}}''nopath=''{{cbr}}


Both parameters are optional.
Both parameters are optional.
Line 28: Line 28:
; path:  What follows after <code>/tree/</code> in the URL.  Can be the path to a file or a directory.  If empty, the link will point to the root of the SimGear repository.
; path:  What follows after <code>/tree/</code> in the URL.  Can be the path to a file or a directory.  If empty, the link will point to the root of the SimGear repository.


; reference:  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 '''next''' branch.
; l:  A line number. This should just be a single number, as SourceForge does not support multiple line numbers.
: {{inote|This parameter will not work if the linked file is of a certain file type, such as <code>.nas</code>. However, this is to do with SourceForge, not the template.}}
 
; 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 '''next''' branch.
 
; t:  Text to show as the URL's label instead of file path.


; lineA line number. This should just be a single number, as SourceForge does not support multiple line numbers.
; nopathStrips off the <code>fgdata/</code> part of the URL label, leaving just the contents of the '''path''' parameter.
: {{inote|This parameter will not work if the linked file is of a certain file type, such as <code>.nas</code>. However, this is to do with SourceForge, not the template.}}
: {{inote|The '''t''' parameter will override this parameter.}}


== Examples ==
== Examples ==
Line 43: Line 48:


=== Path and a commit reference given ===
=== Path and a commit reference given ===
  {{obr}}simgear file{{!}}simgear/canvas/Canvas.cxx{{!}}release/2.12.0{{cbr}}
  {{obr}}simgear file{{!}}simgear/canvas/Canvas.cxx{{!}}r=release/2.12.0{{cbr}}
{{simgear file|simgear/canvas/Canvas.cxx|release/2.12.0}}
{{simgear file|simgear/canvas/Canvas.cxx|r=release/2.12.0}}


  {{obr}}simgear file{{!}}simgear/canvas/Canvas.cxx{{!}}4f94c2{{cbr}}
  {{obr}}simgear file{{!}}simgear/canvas/Canvas.cxx{{!}}r=4f94c2{{cbr}}
{{simgear file|simgear/canvas/Canvas.cxx|4f94c2}}
{{simgear file|simgear/canvas/Canvas.cxx|r=4f94c2}}


  {{obr}}simgear file{{!}}simgear/canvas/Canvas.cxx{{!}}4f94c22241e5ef90026fd087168b24a13ee5ef9b{{cbr}}
  {{obr}}simgear file{{!}}simgear/canvas/Canvas.cxx{{!}}r=4f94c22241e5ef90026fd087168b24a13ee5ef9b{{cbr}}
{{simgear file|simgear/canvas/Canvas.cxx|4f94c22241e5ef90026fd087168b24a13ee5ef9b}}
{{simgear file|simgear/canvas/Canvas.cxx|r=4f94c22241e5ef90026fd087168b24a13ee5ef9b}}


=== Files not in simgear/ ===
=== Line parameter given ===
  {{obr}}simgear file{{!}}version{{cbr}}
  {{obr}}simgear file{{!}}simgear/canvas/Canvas.cxx{{!}}l=5{{cbr}}
{{simgear file|version}}
{{simgear file|simgear/canvas/Canvas.cxx|l=5}}


=== Line parameter given ===
{{obr}}simgear file{{!}}simgear/canvas/Canvas.cxx{{!}}r=4f94c2{{!}}l=5{{cbr}}
  {{obr}}simgear file{{!}}simgear/canvas/Canvas.cxx{{!}}{{!}}5{{cbr}}
{{simgear file|simgear/canvas/Canvas.cxx|r=4f94c2|l=5}}
{{simgear file|simgear/canvas/Canvas.cxx||5}}
 
=== Custom label given ===
  {{obr}}simgear file{{!}}simgear/canvas/Canvas.cxx{{!}}t=Canvas.cxx{{cbr}}
{{simgear file|simgear/canvas/Canvas.cxx|t=Canvas.cxx}}


  {{obr}}simgear file{{!}}simgear/canvas/Canvas.cxx{{!}}4f94c2{{!}}5{{cbr}}
=== Nopath parameter given ===
{{simgear file|simgear/canvas/Canvas.cxx|4f94c2|5}}
  {{obr}}simgear file{{!}}simgear/canvas/Canvas.cxx{{!}}nopath=1{{cbr}}
{{simgear file|simgear/canvas/Canvas.cxx|nopath=1}}


== Related templates ==
== Related templates ==

Navigation menu