Template:Repo link: Difference between revisions

Jump to navigation Jump to search
Redesign and large simplification of the GitHub URL and Mediawiki link text construction. Now if the 'user' or 'proj' parameters are not supplied the base GitHub URL will be constructed, and the default text of "GitHub website" will be used.
(Switch the 'site' parameter default to use the {{project infrastructure/code}} subtemplate.)
(Redesign and large simplification of the GitHub URL and Mediawiki link text construction. Now if the 'user' or 'proj' parameters are not supplied the base GitHub URL will be constructed, and the default text of "GitHub website" will be used.)
Line 198: Line 198:
| github = <!--
| github = <!--
-->{{{protocol|https}}}://<!--                                      URL protocol (default = https).
-->{{{protocol|https}}}://<!--                                      URL protocol (default = https).
-->github.com/<!--                                                 The URL.
-->github.com<!--                                                   The URL.
-->{{#if: {{{user|}}} <!--                                         Project or user? -->
-->{{#if: {{{user|{{{proj|}}}}}} | {{#if: {{{repo|}}}<!--          Continue with the URL construction, only if the project or repository is given. -->
    | {{{user}}}
    | {{#if: {{{user|}}} <!--                                     Project or user? -->
    | {{{proj|}}}
        | /{{{user}}}
  }}/<!--
        | {{#if: {{{proj|}}} | /{{{proj|}}}}}
-->{{{repo|}}}<!--                                                 The version control repository.
      }}<!--
-->{{#switch: {{{type|git web}}} <!--                               The URL type. -->
    -->{{#if: {{{repo|}}} | /{{{repo|}}}}}<!--                     The version control repository.
    | git
    -->{{#switch: {{{type|git web}}} <!--                           The URL type. -->
    | git web =
      {{#switch: {{{type|git web}}}
         | git = .git<!--                                          Append '.git' to the base repository URL. -->
         | git = .git<!--                                          Append '.git' to the base repository URL. -->
         | git web = /<!--
         | git web = /<!--
         -->{{{view|tree}}}/<!--                                    The repository view.
         -->{{{view|tree}}}/<!--                                    The repository view.
         -->{{{commit|{{{branch|master}}}}}}<!--                     The branch or commit.
         -->{{{commit|{{{tag|{{{branch|master}}}}}}}}}<!--           The branch or commit.
         -->{{#if: {{{path|}}} | /{{{path}}}}}<!--                  The file or directory path.
         -->{{#if: {{{path|}}} | /{{{path}}}}}<!--                  The file or directory path.
         -->{{#if: {{{line|}}} | &#35;L{{{line}}} }} <!--            The optional line number(s). -->
         -->{{#if: {{{line|}}} | &#35;L{{{line}}} }} <!--            The optional line number(s). -->
       }} <!--
        | zip = /archive/<!--                                      The base zip file URL.
    -->{{#if: {{{text|}}}
        -->{{{commit|{{{tag|{{{branch|master}}}}}}}}}.zip<!--      Download for a specific commit, tag, or branch (defaulting to master). -->
          | {{{text}}}<!--                                         The text description for the link. -->
       }}
          | {{#ifeq: {{{full|}}} | 1
  }}}} <!--
              | <!--                                               No text. -->
-->{{#if: {{{text|}}}
              | {{#if: {{{pre|}}}
    | {{{text}}}<!--                                               The text description for the link. -->
                  | {{{pre}}}<!--                                   A prefix to the link label. -->
    | {{#ifeq: {{{full|}}} | 1
                  | {{#if: {{{simplepath|}}}
        | <!--                                                     No text. -->
                      | <!--                                       No project, repository or branch. -->
        | {{#if: {{{user|{{{proj|}}}}}}
                      | github/<!--                                 Site advertising.
            | {{#if: {{{repo|}}}
                    -->{{{user|{{{proj|}}}}}}/<!--                 The user or project name.
                | {{#if: {{{pre|}}}
                    -->{{{repo|}}}/<!--                           The repository name.
                    | {{{pre}}}<!--                               A prefix to the link label. -->
                    -->{{{commit|{{{branch|master}}}}}}<!--       The repository branch.-->
                    | {{#if: {{{simplepath|}}}
                    }}
                        | <!--                                     No project, repository or branch. -->
                 }}<!--
                        | github/<!--                             Site advertising.
            -->{{#if: {{{path|}}} | /{{{path}}}}}<!--             The file or directory path.
                        -->{{{user|{{{proj|}}}}}}/<!--             The user or project name.
            -->{{#if: {{{line|}}} | &#35;L{{{line}}}}} <!--       The optional line number(s).
                        -->{{{repo|}}}/<!--                         The repository name.
            -->{{#switch: {{{view|tree}}} <!--                     The view description. -->
                        -->{{{commit|{{{tag|{{{branch|master}}}}}}}}}<!-- The repository commit, tag or branch.-->
                  | blob =
                      }}
                  | blame = <nowiki></nowiki> blame view
                  }}<!--
                  | commit = <nowiki></nowiki> commit view
                 -->{{#switch: {{{type|git web}}} <!--               The URL type. -->
                  | commits = <nowiki></nowiki> history view
                    | git web =
                  | raw = <nowiki></nowiki> raw view
                      {{#if: {{{path|}}} | /{{{path}}}}}<!--       The file or directory path.
                  | tree =
                    -->{{#if: {{{line|}}} | &#35;L{{{line}}}}} <!-- The optional line number(s).
                }}
                    -->{{#switch: {{{view|tree}}} <!--             The view description. -->
            }}
                        | blob =
        }}
                        | blame = <nowiki></nowiki> blame view
    | zip = /archive/<!--                                          The base zip file URL.
                        | commit = <nowiki></nowiki> commit view
    -->{{#if: {{{commit|{{{tag|{{{branch|}}} }}} }}}
                        | commits = <nowiki></nowiki> history view
        | {{{commit|{{{tag|{{{branch|}}} }}} }}}<!--              Download for a specific commit, tag, or branch (defaulting to master). -->
                        | raw = <nowiki></nowiki> raw view
        | master<!--                                              Default to the master branch. -->
                        | tree =
      }}.zip <!--
                      }}
    -->{{#if: {{{text|}}}
                    | zip = <nowiki></nowiki> zip file<!--         The link description. -->
        | {{{text}}}<!--                                          The text description for the link. -->
        | {{#ifeq: {{{full|}}} | 1
            | <!--                                                No text. -->
            | {{#if: {{{pre|}}}
                | {{{pre}}}<!--                                    A prefix to the link label. -->
                | {{#if: {{{simplepath|}}}
                    | <!--                                        No project, repository or branch. -->
                    | github/<!--                                  Site advertising.
                    -->{{{user|{{{proj|}}}}}}/<!--                  The user or project name.
                    -->{{{repo|}}}/<!--                            The repository name.
                    -->{{{commit|{{{tag|{{{branch|}}} }}} }}}<!--  The commit, tag, or branch.-->
                   }}
                   }}
               }} <nowiki></nowiki> zip file<!--                    The link description. -->
               }}
            | GitHub website
           }}
           }}
       }}
       }}

Navigation menu