Changes between Version 2 and Version 3 of TracLinks


Ignore:
Timestamp:
Aug 1, 2024, 10:29:31 AM (4 months ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracLinks

    v2 v3  
    44[[PageOutline(2-5,Contents,pullout)]]
    55
    6 TracLinks are a fundamental feature of Trac, because they allow easy hyperlinking between the various entities in the system — such as tickets, reports, changesets, Wiki pages, milestones, and source files — from anywhere where WikiFormatting is used.
     6TracLinks are a fundamental feature of Trac, allowing easy hyperlinking between the various entities in the system — such as tickets, reports, changesets, Wiki pages, milestones, and source files — from anywhere WikiFormatting is used.
    77
    88TracLinks are generally of the form '''type:id''' (where ''id'' represents the number, name or path of the item) though some frequently used kinds of items also have short-hand notations.
     
    3232 Revision log :: `r1:3`, `[1:3]` or `log:@1:3`, `log:trunk@1:3`, `[2:5/trunk]`
    3333 Diffs :: `diff:@1:3`, `diff:plugins/0.12/mercurial-plugin@9128:9953`,
    34           `diff:tags/trac-0.9.2/wiki-default//tags/trac-0.9.3/wiki-default` 
     34          `diff:tags/trac-0.9.2/wiki-default//tags/trac-0.9.3/wiki-default`
    3535          or `diff:trunk/trac@3538//sandbox/vc-refactoring@3539`
    36  Files :: `source:trunk/COPYING`, `source:/trunk/COPYING@200` (at version 200), `source:/trunk/COPYING@200#L25` (at version 200, line 25)
     36 Files :: `source:trunk/COPYING`, `source:/trunk/COPYING@200` (at version 200), `source:/trunk/COPYING@200#L25` (at version 200, line 25), `source:/trunk/COPYING@200:27-30#L25` (at version 200, line 25, highlighting lines 27-30)
    3737}}}
    3838{{{#!td
     
    4040 Parent page :: [..]
    4141 Tickets :: #1 or ticket:1
    42  Ticket comments :: comment:1:ticket:2 
     42 Ticket comments :: comment:1:ticket:2
    4343 Reports :: {1} or report:1
    4444 Milestones :: milestone:1.0
     
    4747 Revision log :: r1:3, [1:3] or log:@1:3, log:trunk@1:3, [2:5/trunk]
    4848 Diffs :: diff:@1:3, diff:plugins/0.12/mercurial-plugin@9128:9953,
    49           diff:tags/trac-0.9.2/wiki-default//tags/trac-0.9.3/wiki-default 
     49          diff:tags/trac-0.9.2/wiki-default//tags/trac-0.9.3/wiki-default
    5050          or diff:trunk/trac@3538//sandbox/vc-refactoring@3539
    51  Files :: source:trunk/COPYING, source:/trunk/COPYING@200 (at version 200), source:/trunk/COPYING@200#L25 (at version 200, line 25)
     51 Files :: source:trunk/COPYING, source:/trunk/COPYING@200 (at version 200), source:/trunk/COPYING@200#L25 (at version 200, line 25) source:/trunk/COPYING@200:28-31#L25 (at version 200, line 25, highlighting lines 28-31)
    5252}}}
    5353
     
    7878}}}
    7979|--------------------------------------------------------------------------------------
    80 |||| `wiki` is the default if the namespace part of a full link is omitted:  || 
     80|||| `wiki` is the default if the namespace part of a full link is omitted:  ||
    8181{{{#!td
    8282{{{
     
    9999<wiki:Strange(page@!)>
    100100}}}
     101|--------------------------------------------------------------------------------------
     102|||| Quoting can be used with the full notation to allow brackets in the label. ||
     103{{{#!td
     104{{{
     105[TracIni#logging-log_type-option "[logging] log_type"]
     106}}}
     107}}}
     108{{{#!td
     109[TracIni#logging-log_type-option "[logging] log_type"]
     110}}}
    101111}}}
    102112
     
    125135
    126136But in practice you often won't need to add the `../` prefix to link to a sibling page.
    127 For resolving the location of a wiki link, it's the target page closest in the hierarchy to the page where the link is written which will be selected. So for example, within a sub-hierarchy, a sibling page will be targeted in preference to a toplevel page.
     137For resolving the location of a wiki link, it's the target page closest in the hierarchy to the page where the link is written which will be selected. So for example, within a sub-hierarchy, a sibling page will be targeted in preference to a top-level page.
    128138This makes it easy to copy or move pages to a sub-hierarchy by [[WikiNewPage#renaming|renaming]] without having to adapt the links.
    129139
     
    132142=== Link anchors
    133143
    134 To create a link to a specific anchor in a page, use '#':
     144To create a link to a specific anchor in a page, use `#`:
    135145{{{
    136146 [#Linkanchors Link anchors] or [[#Linkanchors|Link anchors]]
     
    138148  [#Linkanchors Link anchors] or [[#Linkanchors|Link anchors]]
    139149
    140 Hint: when you move your mouse over the title of a section, a '¶' character will be displayed. This is a link to that specific section and you can use this to copy the `#...` part inside a relative link to an anchor.
    141 
    142 To create a link to the first or last occurrence of a term on a page, use a ''pseudo anchor'' starting with '#/' or '#?':
     150To create an anchor in a page, use `[=#...]`:
     151{{{
     152 [=#myanchor my anchor] or empty form [=#myanchor]
     153}}}
     154 [=#myanchor my anchor] or empty form [=#myanchor]
     155
     156Hint: when you hover your mouse over the title of a section, a '¶' character will be displayed. This is a link to that specific section and you can use this to copy the `#...` part inside a relative link to an anchor.
     157
     158To create a link to the first or last occurrence of a term on a page, use a ''pseudo anchor'' starting with `#/` or `#?`:
    143159{{{
    144160 [#/Milestone first occurrence of Milestone] or
     
    147163 [#/Milestone first occurrence of Milestone] or
    148164 [#?Milestone last occurrence of Milestone]
    149 This will also highlight all other matches on the linked page. By default only case sensitive matches are considered. To include case insensitive matches append '/i':
     165This will also highlight all other matches on the linked page. By default only case sensitive matches are considered. To include case insensitive matches append `/i`:
    150166{{{
    151167 [#/Milestone/i first occurrence of Milestone or milestone] or
     
    166182(Hint: The line numbers displayed in the source browser are links to anchors on the respective lines.)
    167183
    168 Since such links become outdated when the file changes, it can be useful to link using a '#/' pseudo anchor instead:
     184Since such links become outdated when the file changes, it can be useful to link using a `#/` pseudo anchor instead:
    169185{{{
    170186 [trac:source:trunk/trac/wiki/api.py#/IWikiSyntaxProvider IWikiSyntaxProvider] or
     
    182198This can be seen as a kind of InterWiki link specialized for targeting other Trac projects.
    183199
    184 Any type of Trac link can be written in one Trac environment and actually refer to resources in another Trac environment. All that is required is to prefix the Trac link with the name of the other Trac environment followed by a colon. The other Trac environment must be registered on the InterTrac page. 
    185 
    186 A distinctive advantage of InterTrac links over InterWiki links is that the shorthand form of Trac links (e.g. `{}`, `r`, `#`) can also be used. For example if T was set as an alias for Trac, links to Trac tickets can be written #T234, links to Trac changesets can be written [trac 1508].
    187 See InterTrac for the complete details. 
     200Any type of Trac link can be written in one Trac environment and actually refer to resources in another Trac environment. All that is required is to prefix the Trac link with the name of the other Trac environment followed by a colon. The other Trac environment must be registered on the InterTrac page.
     201
     202A distinct advantage of InterTrac links over InterWiki links is that the shorthand form of Trac links can also be used, such as `{}`, `r`, `#`. For example, if T was set as an alias for Trac, then links to Trac tickets can be written as #T234, and links to Trac changesets can be written as [trac 1508].
     203See InterTrac for the complete details.
    188204
    189205=== Server-relative links
     
    215231 * !wiki:"The whitespace convention"
    216232 * !attachment:'the file.txt' or
    217  * !attachment:"the file.txt" 
    218  * !attachment:"the file.txt:ticket:123" 
     233 * !attachment:"the file.txt"
     234 * !attachment:"the file.txt:ticket:123"
    219235
    220236Note that by using [trac:WikiCreole] style links, it's quite natural to write links containing spaces:
     
    251267
    252268The link syntax for attachments is as follows:
    253  * !attachment:the_file.txt creates a link to the attachment the_file.txt of the current object
     269 * !attachment:the_file.txt creates a link to the attachment the_file.txt of the current page
    254270 * !attachment:the_file.txt:wiki:MyPage creates a link to the attachment the_file.txt of the !MyPage wiki page
    255271 * !attachment:the_file.txt:ticket:753 creates a link to the attachment the_file.txt of the ticket 753
    256272
    257 Note that the older way, putting the filename at the end, is still supported: !attachment:ticket:753:the_file.txt.
     273Note that the older way, putting the filename at the end, is still supported: !attachment:ticket:753:the_file.txt, but is not recommended.
    258274
    259275If you'd like to create a direct link to the content of the attached file instead of a link to the attachment page, simply use `raw-attachment:` instead of `attachment:`.
    260276
    261 This can be useful for pointing directly to an HTML document, for example. Note that for this use case, you'd have to allow the web browser to render the content by setting `[attachment] render_unsafe_content = yes` (see TracIni#attachment-section). Caveat: only do that in environments for which you're 100% confident you can trust the people who are able to attach files, as otherwise this would open up your site to [wikipedia:Cross-site_scripting cross-site scripting] attacks.
     277This can be useful for pointing directly to an HTML document, for example. Note that for this use case, you'd have to allow the web browser to render the content by setting [[TracIni#attachment-render_unsafe_content-option|"[attachment] render_unsafe_content"]] = `enabled`. Caveat: only do that in environments for which you're 100% confident you can trust the people who are able to attach files, as this opens up your site to [https://en.wikipedia.org/wiki/Cross-site_scripting cross-site scripting] attacks.
    262278
    263279See also [#export:links].
     
    267283When you're inside a given ticket, you can simply write e.g. !comment:3 to link to the third change comment.
    268284It is possible to link to a comment of a specific ticket from anywhere using one of the following syntax:
    269  - `comment:3:ticket:123` 
     285 - `comment:3:ticket:123`
    270286 - `ticket:123#comment:3` (note that you can't write `#123#!comment:3`!)
    271287It is also possible to link to the ticket's description using one of the following syntax:
     
    284300=== search: links
    285301
    286 See TracSearch#SearchLinks
     302See TracSearch#SearchTracLinks
    287303
    288304=== ticket: links
    289305
    290  ''alias:'' `bug:`
     306 ''aliases:'' `bug:`, `issue:`
    291307
    292308Besides the obvious `ticket:id` form, it is also possible to specify a list of tickets or even a range of tickets instead of the `id`. This generates a link to a custom query view containing this fixed set of tickets.
    293309
    294 Example: 
     310Example:
    295311 - `ticket:5000-6000`
    296312 - `ticket:1,150`
     
    312328See WikiPageNames and [#QuotingspaceinTracLinks quoting space in TracLinks] above. It is possible to create a link to a specific page revision using the syntax WikiStart@1.
    313329
    314 === Version Control related links
    315 
    316 It should be noted that multiple repository support works by creating a kind of virtual namespace for versioned files in which the toplevel folders correspond to the repository names. Therefore, in presence of multiple repositories, a ''/path'' specification in the syntax of links detailed below should start with the name of the repository. If omitted, the default repository is used. In case a toplevel folder of the default repository has the same name as a repository, the latter "wins". One can always access such folder by fully qualifying it. The default repository can be an alias of a named repository, or conversely, it is always possible to create an alias for the default repository, ask your Trac administrator.
     330=== Version Control system links
     331
     332It should be noted that multiple repository support works by creating a kind of virtual namespace for versioned files in which the toplevel folders correspond to the repository names. Therefore, in presence of multiple repositories, a ''/path'' specification in the syntax of links detailed below should start with the name of the repository. If omitted, the default repository is used. In case a toplevel folder of the default repository has the same name as a repository, the link directs to the latter. One can always access such folder by fully qualifying it. The default repository can be an alias of a named repository, or conversely, there may be one or more aliases for the default repository, ask your Trac administrator.
    317333
    318334For example, `source:/trunk/COPYING` targets the path `/trunk/COPYING` in the default repository, whereas `source:/projectA/trunk/COPYING` targets the path `/trunk/COPYING` in the repository named `projectA`. This can be the same file if `'projectA'` is an alias to the default repository or if `''` (the default repository) is an alias to `'projectA'`.
     
    348364 * `export:/some/file@named-branch` - get latest revision of the specified file in `named-branch` (DVCS such as Git or Mercurial).
    349365
    350 This can be very useful for displaying XML or HTML documentation with correct stylesheets and images, in case that has been checked in into the repository. Note that for this use case, you'd have to allow the web browser to render the content by setting `[browser] render_unsafe_content = yes` (see TracIni#browser-section), otherwise Trac will force the files to be downloaded as attachments for security concerns.
     366This can be very useful for displaying XML or HTML documentation with correct stylesheets and images, in case that has been checked in into the repository. Note that for this use case, you'd have to allow the web browser to render the content by setting [[TracIni#browser-render_unsafe_content-option|"[browser] render_unsafe_content"]] = `enabled`, otherwise Trac will force the files to be downloaded as attachments for security concerns.
    351367
    352368If the path is to a directory in the repository instead of a specific file, the source browser will be used to display the directory (identical to the result of `source:/some/dir`).
     
    358374 - `log:/trunk/tools` - the latest revisions in `trunk/tools`
    359375 - `log:/trunk/tools@10000` - the revisions in `trunk/tools` starting from  revision 10000
    360  - `log:@20788,20791:20795` - list revision 20788 and the revisions from 20791 to 20795 
     376 - `log:@20788,20791:20795` - list revision 20788 and the revisions from 20791 to 20795
    361377 - `log:/trunk/tools@20788,20791:20795` - list revision 20788 and the revisions from 20791 to 20795 which affect the given path
    362378 - `log:/tools@named-branch` - the revisions in `tools` starting from the latest revision in `named-branch` (DVCS such as Git or Mercurial)
     
    369385Finally, note that in all of the above, a revision range can be written either as `x:y` or `x-y`.
    370386
    371 In the presence of multiple repositories, the name of the repository should be specified as the first part of the path, e.g. `log:repos/branches` or `[20-40/repos]`.
     387==== Multi-repository links
     388
     389In the presence of multiple repositories, the name of the repository should be specified as the first part of the path:
     390- `log:repos/branch`
     391- `[20-40/repos]`
     392- `r20/repos`
    372393
    373394----
    374395See also: WikiFormatting, TracWiki, WikiPageNames, InterTrac, InterWiki
    375