Difference between revisions of "Template:Git link"

From VideoLAN Wiki
Jump to navigation Jump to search
m (Change examples: you can link to removed modules (with some effort), remove useless example, explain other example)
(Tweaks)
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
 
         -->|{{#if:{{{h|}}}<!--
 
         -->|{{#if:{{{h|}}}<!--
 
           -->|{{#if:{{{hb|}}}<!--
 
           -->|{{#if:{{{hb|}}}<!--
               p given, a given, f given, h given, hb given:
+
               p given, a given, f given, h given, hb given: show filename
 
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}};f={{{f}}};h={{{h}}};hb={{{hb}}} {{{l|{{{f}}}}}}]<!--
 
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}};f={{{f}}};h={{{h}}};hb={{{hb}}} {{{l|{{{f}}}}}}]<!--
               p given, a given, f given, h given, hb not given:
+
               p given, a given, f given, h given, hb not given: show filename
 
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}};f={{{f}}};h={{{h}}} {{{l|{{{f}}}}}}]<!--
 
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}};f={{{f}}};h={{{h}}} {{{l|{{{f}}}}}}]<!--
 
             -->}}<!-- end hb
 
             -->}}<!-- end hb
 
           -->|{{#if:{{{hb|}}}<!-- h not given branch
 
           -->|{{#if:{{{hb|}}}<!-- h not given branch
               p given, a given, f given, h not given, hb given:
+
               p given, a given, f given, h not given, hb given: show filename
 
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}};f={{{f}}};hb={{{hb}}} {{{l|{{{f}}}}}}]<!--
 
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}};f={{{f}}};hb={{{hb}}} {{{l|{{{f}}}}}}]<!--
               p given, a given, f given, h not given, hb not given:
+
               p given, a given, f given, h not given, hb not given: show filename
 
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}};f={{{f}}} {{{l|{{{f}}}}}}]<!--
 
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}};f={{{f}}} {{{l|{{{f}}}}}}]<!--
 
             -->}}<!-- end hb
 
             -->}}<!-- end hb
Line 19: Line 19:
 
         -->|{{#if:{{{h|}}}<!-- f not given branch
 
         -->|{{#if:{{{h|}}}<!-- f not given branch
 
           -->|{{#if:{{{hb|}}}<!--
 
           -->|{{#if:{{{hb|}}}<!--
               p given, a given, f not given, h given, hb given:
+
               p given, a given, f not given, h given, hb given: show hash
 
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}};h={{{h}}};hb={{{hb}}} {{{l|&#x5B;{{{h}}}&#x5D;}}}]<!--
 
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}};h={{{h}}};hb={{{hb}}} {{{l|&#x5B;{{{h}}}&#x5D;}}}]<!--
               p given, a given, f not given, h given, hb not given:
+
               p given, a given, f not given, h given, hb not given: show hash
 
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}};h={{{h}}} {{{l|&#x5B;{{{h}}}&#x5D;}}}]<!--
 
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}};h={{{h}}} {{{l|&#x5B;{{{h}}}&#x5D;}}}]<!--
 
             -->}}<!-- end hb
 
             -->}}<!-- end hb
 
           -->|{{#if:{{{hb|}}}<!-- h not given branch
 
           -->|{{#if:{{{hb|}}}<!-- h not given branch
               p given, a given, f not given, h not given, hb given:
+
               p given, a given, f not given, h not given, hb given: show branch
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}};hb={{{hb}}} {{{l|{{{p}}}}}}]<!--
+
               -->|[https://git.videolan.org/?p={{{p}}} {{{l|{{{p}}}}}}]<!--
               p given, a given, f not given, h not given, hb not given:
+
               p given, a given, f not given, h not given, hb not given: show branch
               -->|[https://git.videolan.org/?p={{{p}}};a={{{a}}} {{{l|{{{p}}}}}}]<!--
+
               -->|[https://git.videolan.org/?p={{{p}}} {{{l|{{{p}}}}}}]<!--
 
             -->}}<!-- end hb
 
             -->}}<!-- end hb
 
         -->}}<!-- end h
 
         -->}}<!-- end h
Line 35: Line 35:
 
         -->|{{#if:{{{h|}}}<!--
 
         -->|{{#if:{{{h|}}}<!--
 
           -->|{{#if:{{{hb|}}}<!--
 
           -->|{{#if:{{{hb|}}}<!--
               p given, a not given, f given, h given, hb given:
+
               p given, a not given, f given, h given, hb given: show filename
 
               -->|[https://git.videolan.org/?p={{{p}}};f={{{f}}};h={{{h}}};hb={{{hb}}} {{{l|{{{f}}}}}}]<!--
 
               -->|[https://git.videolan.org/?p={{{p}}};f={{{f}}};h={{{h}}};hb={{{hb}}} {{{l|{{{f}}}}}}]<!--
               p given, a not given, f given, h given, hb not given:
+
               p given, a not given, f given, h given, hb not given: show filename
 
               -->|[https://git.videolan.org/?p={{{p}}};f={{{f}}};h={{{h}}} {{{l|{{{f}}}}}}]<!--
 
               -->|[https://git.videolan.org/?p={{{p}}};f={{{f}}};h={{{h}}} {{{l|{{{f}}}}}}]<!--
 
             -->}}<!-- end hb
 
             -->}}<!-- end hb
 
           -->|{{#if:{{{hb|}}}<!-- h not given branch
 
           -->|{{#if:{{{hb|}}}<!-- h not given branch
               p given, a not given, f given, h not given, hb given:
+
               p given, a not given, f given, h not given, hb given: show filename
 
               -->|[https://git.videolan.org/?p={{{p}}};f={{{f}}};hb={{{hb}}} {{{l|{{{f}}}}}}]<!--
 
               -->|[https://git.videolan.org/?p={{{p}}};f={{{f}}};hb={{{hb}}} {{{l|{{{f}}}}}}]<!--
               p given, a not given, f given, h not given, hb not given:
+
               p given, a not given, f given, h not given, hb not given: show filename
 
               -->|[https://git.videolan.org/?p={{{p}}};f={{{f}}}; {{{l|{{{f}}}}}}]<!--
 
               -->|[https://git.videolan.org/?p={{{p}}};f={{{f}}}; {{{l|{{{f}}}}}}]<!--
 
             -->}}<!-- end hb
 
             -->}}<!-- end hb
Line 49: Line 49:
 
         -->|{{#if:{{{h|}}}<!-- f not given branch
 
         -->|{{#if:{{{h|}}}<!-- f not given branch
 
           -->|{{#if:{{{hb|}}}<!--
 
           -->|{{#if:{{{hb|}}}<!--
               p given, a not given, f not given, h given, hb given:
+
               p given, a not given, f not given, h given, hb given: show hash
 
               -->|[https://git.videolan.org/?p={{{p}}};h={{{h}}};hb={{{hb}}} {{{l|&#x5B;{{{h}}}&#x5D;}}}]<!--
 
               -->|[https://git.videolan.org/?p={{{p}}};h={{{h}}};hb={{{hb}}} {{{l|&#x5B;{{{h}}}&#x5D;}}}]<!--
               p given, a not given, f not given, h given, hb not given:
+
               p given, a not given, f not given, h given, hb not given: show hash
 
               -->|[https://git.videolan.org/?p={{{p}}};h={{{h}}} {{{l|&#x5B;{{{h}}}&#x5D;}}}]<!--
 
               -->|[https://git.videolan.org/?p={{{p}}};h={{{h}}} {{{l|&#x5B;{{{h}}}&#x5D;}}}]<!--
 
             -->}}<!-- end hb
 
             -->}}<!-- end hb
 
           -->|{{#if:{{{hb|}}}<!--
 
           -->|{{#if:{{{hb|}}}<!--
               p given, a not given, f not given, h not given, hb given:
+
               p given, a not given, f not given, h not given, hb given: show branch
               -->|[https://git.videolan.org/?p={{{p}}};hb={{{hb}}} {{{l|{{{p}}}}}}]<!--
+
               -->|[https://git.videolan.org/?p={{{p}}} {{{l|{{{p}}}}}}]<!--
               p given, a not given, f not given, h not given, hb not given:
+
               p given, a not given, f not given, h not given, hb not given: show branch
 
               -->|[https://git.videolan.org/?p={{{p}}} {{{l|{{{p}}}}}}]<!--
 
               -->|[https://git.videolan.org/?p={{{p}}} {{{l|{{{p}}}}}}]<!--
 
             -->}}<!-- end hb
 
             -->}}<!-- end hb
Line 63: Line 63:
 
       -->}}<!-- end f
 
       -->}}<!-- end f
 
   -->}}<!-- end a
 
   -->}}<!-- end a
   -->|<!-- p not given branch -->[https://git.videolan.org/ {{{l|Git}}}]<!--
+
   -->|<!-- p not given branch: show Git -->[https://git.videolan.org/ {{{l|Git}}}]<!--
 
-->}}<noinclude>
 
-->}}<noinclude>
 
== Usage ==
 
== Usage ==
Line 74: Line 74:
 
  <code>{{ {{PAGENAME}} <nowiki>|p= |a= |f= |h= }}</nowiki></code>
 
  <code>{{ {{PAGENAME}} <nowiki>|p= |a= |f= |h= }}</nowiki></code>
  
This is a meta-template.
+
This is a meta-template, a wrapper around URL requests to git.videolan.org. This template ''does not'' perform [[wikipedia:sanity check|sanity check]]s. It saves keystrokes and avoids [[wikipedia:XSS|XSS]] requests from passed parameters.
  
 
Parameters:
 
Parameters:
 
* '''<code>|p=</code>''' is the '''branch''' e.g. <kbd>vlc.git</kbd>, <kbd>vlc/vlc-2.2.git</kbd> or <kbd>vlma.git</kbd> (see https://git.videolan.org for a list of branch names)
 
* '''<code>|p=</code>''' is the '''branch''' e.g. <kbd>vlc.git</kbd>, <kbd>vlc/vlc-2.2.git</kbd> or <kbd>vlma.git</kbd> (see https://git.videolan.org for a list of branch names)
* '''<code>|a=</code>''' is the '''format''' e.g. <kbd>blob</kbd>. No sanity checks are done by this template but only <kbd>summary</kbd>, <kbd>shortlog</kbd>, <kbd>log</kbd>, <kbd>commit</kbd>, <kbd>commitdiff</kbd>, <kbd>tree</kbd> and <kbd>patch</kbd> are valid.
+
* '''<code>|a=</code>''' is the '''format''' e.g. <kbd>blob</kbd>. This may be given free-form but only the following are valid: <kbd>summary</kbd>, <kbd>shortlog</kbd>, <kbd>log</kbd>, <kbd>commit</kbd>, <kbd>commitdiff</kbd>, <kbd>tree</kbd> and <kbd>patch</kbd>
 
* '''<code>|f=</code>''' is the '''file''' e.g. <kbd>modules/demux/image.c</kbd>. You can pass directory names to <kbd>|f=</kbd> as well if <kbd>|a=tree</kbd>
 
* '''<code>|f=</code>''' is the '''file''' e.g. <kbd>modules/demux/image.c</kbd>. You can pass directory names to <kbd>|f=</kbd> as well if <kbd>|a=tree</kbd>
 
* '''<code>|h=</code>''' is the '''hash''' e.g. <kbd>72f3067a6fddcd30e0ee33928a0ec6622ed2e74b</kbd>
 
* '''<code>|h=</code>''' is the '''hash''' e.g. <kbd>72f3067a6fddcd30e0ee33928a0ec6622ed2e74b</kbd>
Line 93: Line 93:
  
 
Example 3:
 
Example 3:
  <code>{{{{PAGENAME}}<nowiki>|p=x264.git|a=tree|f=modules}}</nowiki></code>
+
  <code>{{{{PAGENAME}}<nowiki>|p=x264.git|a=tree|f=doc}}</nowiki></code>
{{{{PAGENAME}}|p=vlc.git|a=tree|f=modules}}
+
{{{{PAGENAME}}|p=x264.git|a=tree|f=doc}}
  
 
Example 4:
 
Example 4:
Line 108: Line 108:
 
{{{{PAGENAME}}|p=vlc/vlc-2.0.git|a=blob|f=modules/video_filter/crop.c|h=b5e946097a7e7acbe0c90446d0752ff0f7f706ec|hb=HEAD|l=This module no longer exists. Here's a link to it anyway}}
 
{{{{PAGENAME}}|p=vlc/vlc-2.0.git|a=blob|f=modules/video_filter/crop.c|h=b5e946097a7e7acbe0c90446d0752ff0f7f706ec|hb=HEAD|l=This module no longer exists. Here's a link to it anyway}}
  
This template will branch intelligently if any parameter or combination of parameters are omitted, because raw parameters send [[wikipedia:XSS|XSS]] requests:
+
This template will branch to the most specific condition upon parameter omission:
* <code>{{{{PAGENAME}}<nowiki>}}</nowiki></code> gives {{{{PAGENAME}}<!---->}}
+
* <code>{{{{PAGENAME}}<nowiki>}}</nowiki></code> gives {{{{PAGENAME}}<!---->}} rather than https://git.videolan.org/?p={{{p}}};a={{{a}}};f={{{f}}};h={{{h}}};hb={{{hb}}}
 
* <code>{{{{PAGENAME}}|a=blob|h=72f3067a6fddcd30e0ee33928a0ec6622ed2e74b<nowiki>}}</nowiki></code> gives {{{{PAGENAME}}|a=blob|h=72f3067a6fddcd30e0ee33928a0ec6622ed2e74b}} because no branch was specified
 
* <code>{{{{PAGENAME}}|a=blob|h=72f3067a6fddcd30e0ee33928a0ec6622ed2e74b<nowiki>}}</nowiki></code> gives {{{{PAGENAME}}|a=blob|h=72f3067a6fddcd30e0ee33928a0ec6622ed2e74b}} because no branch was specified
 +
* <code>{{{{PAGENAME}}|p=vlc.git|a=summary|hb=HEAD<nowiki>}}</nowiki></code> gives {{{{PAGENAME}}|p=vlc.git|a=summary|hb=HEAD}}
  
 
[[Category:Templates]]
 
[[Category:Templates]]
 
</noinclude>
 
</noinclude>

Latest revision as of 03:44, 12 March 2019

Git

Usage

{{ Git link |p= |a= |h= }}

or

{{ Git link |p= |a= |h= |l= }}

or

{{ Git link |p= |a= |f= }}

or

{{ Git link |p= |a= |f= |h= }}

This is a meta-template, a wrapper around URL requests to git.videolan.org. This template does not perform sanity checks. It saves keystrokes and avoids XSS requests from passed parameters.

Parameters:

  • |p= is the branch e.g. vlc.git, vlc/vlc-2.2.git or vlma.git (see https://git.videolan.org for a list of branch names)
  • |a= is the format e.g. blob. This may be given free-form but only the following are valid: summary, shortlog, log, commit, commitdiff, tree and patch
  • |f= is the file e.g. modules/demux/image.c. You can pass directory names to |f= as well if |a=tree
  • |h= is the hash e.g. 72f3067a6fddcd30e0ee33928a0ec6622ed2e74b
  • |hb= ???
  • |l= is the label (optional) e.g. arbitrary

Example 1:

{{Git link|p=vlc.git|a=commit|h=72f3067a6fddcd30e0ee33928a0ec6622ed2e74b}}

[72f3067a6fddcd30e0ee33928a0ec6622ed2e74b]

Example 2:

{{Git link|p=vlc.git|a=commit|h=72f3067a6fddcd30e0ee33928a0ec6622ed2e74b|l=First revision of VLC}}

First revision of VLC

Example 3:

{{Git link|p=x264.git|a=tree|f=doc}}

doc

Example 4:

{{Git link|p=vlc.git|a=commitdiff|h=72f3067a6fddcd30e0ee33928a0ec6622ed2e74b}}

[72f3067a6fddcd30e0ee33928a0ec6622ed2e74b]

Example 5:

{{Git link|p=x264.git|a=history}}

x264.git

Example 6:

{{Git link|p=vlc/vlc-2.0.git|a=blob|f=modules/video_filter/crop.c|h=b5e946097a7e7acbe0c90446d0752ff0f7f706ec|hb=HEAD|l=This module no longer exists. Here's a link to it anyway}}

This module no longer exists. Here's a link to it anyway

This template will branch to the most specific condition upon parameter omission: