Edgewall Software

Ticket #234 (closed enhancement: fixed)

Opened 4 years ago

Last modified 2 years ago

Inter-project links

Reported by: david.larsson@… Owned by: cboos
Priority: normal Milestone: 0.10
Component: wiki system Version: devel
Severity: major Keywords: intertrac
Cc: trac.tickets@…, pixelpapst@…

Description

It would be nice to be able to link between projects (on the same server), e.g. [link:/trac/TestPage A test page in the trac project]. I know I can use a full URL, but I want to use the same protocol (https/http) in the link as the current user session. (This is because I force user login on https but not on http).

Attachments

intertrac.1017.diff (8.0 kB) - added by cboos@… 4 years ago.
Intertrac patch, made against 1017
intertrac.1017.2.diff (8.0 kB) - added by cboos@… 4 years ago.
Fixed version of the Intertrac patch against 1017.

Change History

Changed 4 years ago by daniel

A possible syntax, that also remains compatible with InterWikiLinks?:

  • project:#42 == project:ticket:42
  • project:WikiPage == project:wiki:WikiPage

See also: http://c2.com/cgi/wiki?InterWiki, http://c2.com/cgi/wiki?InterWiki

Changed 4 years ago by daniel

A more advanced example:

{{{[project:changeset:42 my changeset]}}.

Changed 4 years ago by daniel

Oops, didn't get quoting on that previous comment:

[project:changeset:42 my changeset]

Changed 4 years ago by daniel

the <project> part should be automatically detemermined for locally hosted projects, but it should also reference an Intermap-style map, to retain the InterWiki semantic.

Changed 4 years ago by daniel

  • priority changed from normal to low
  • milestone set to 0.8

Changed 4 years ago by Daniel Lundin <daniel@…>

  • milestone changed from 0.8 to 1.0

Changed 4 years ago by cboos@…

Intertrac patch, made against 1017

Changed 4 years ago by cboos@…

  • priority changed from low to normal
  • version changed from 0.6 to devel
  • severity changed from normal to enhancement

This ticket seems related to my need of handling intertrac links.

An intertrac link is a 1-character prefix you put before the ticket/changeset number, e.g. #T234 or [T1010]. It can also be set in a module href: ticket:T:234, changeset:T:1010.

Each prefix should be documented in the [intertrac] section of the conf/trac.ini file:

[intertrac]
T.title = Edgewall Trac
T.href = http://projects.edgewall.com/trac

(I hope this patch gets noticed, otherwise I'll create a new ticket for it)

Patch added intertrac.1017.diff

Changed 4 years ago by cboos@…

Oops, the patch initially posted ( Fri Nov 5 09:37:01 2004. ) had a little typo in it, I just uploaded the fixed version.

The typo was:

  • trac/WikiFormatter.py

    === trac/WikiFormatter.py
    ==================================================================
     
    186186    def _tickethref_formatter(self, match, fullmatch): 
    187187        intertrac = fullmatch.group('t_intertrac') 
    188188        if intertrac: 
    189             number = int(match[1+len(intertrac):-1]) 
     189            number = int(match[1+len(intertrac):]) 
    190190            href, title, _class = self._intertrac_link(intertrac) 
    191191            return '<a class="%s" title="%s" href="%s/ticket/%d">#%d</a>' % (_class, title, href, number, number) 
    192192        else: 

Changed 4 years ago by cboos@…

Fixed version of the Intertrac patch against 1017.

Changed 4 years ago by cmlenz

Isn't this just a special case of #40 (InterWiki links)?

Changed 4 years ago by cboos@…

> Isn't this just a special case of #40 (InterWiki links)?

I think that an InterWiki link is a kind of InterTrac link, as the proposed cross-referencing is not only for Wiki pages, but for all trac related objects: wikis, tickets and changesets. That's why I added my intertrac patch here (#234) and not there (#40).

I find it useful to have quick shortcuts to other trac projects (like #T234 to refer to the #234 ticket for Trac), because sometimes you work on a project that involves multiple source repositories (SVN repositories only for now).

For instance, I have a trac database set up on a local source code repository for 3rd party software, which is managed by SVK. In there, I mirror the edgewall trac SVN repository.

I often need to refer to bugs and changesets from the official trac database for Trac when I hack my local version of Trac. I also often refer to our "main" SVN repository, under the control of a different trac database.

Changed 4 years ago by cboos@…

I just fixed an embarassing bug in my patch:

!diff
=== WikiFormatter.py
==================================================================
--- WikiFormatter.py  (revision 1072)
+++ WikiFormatter.py  (local)
@@ -116,7 +116,7 @@
               r"""(?P<tickethref>!?#(?P<t_intertrac>[a-zA-z]?)\d+)""",
               r"""(?P<changesethref>!?\[(?P<c_intertrac>[a-zA-z]?)\d+\])""",
               r"""(?P<reporthref>!?\{\d+\})""",
-              r"""(?P<modulehref>!?((?P<modulename>bug|ticket|browser|source|repos|report|changeset|wiki|milestone|search):(?P<m_intertrac>[a-zA-z]:?)(?P<moduleargs>(&#34;(.*?)&#34;|'(.*?)')|([^ ]*[^\., \)]))))""",
+              r"""(?P<modulehref>!?((?P<modulename>bug|ticket|browser|source|repos|report|query|changeset|wiki|milestone|search):(?P<m_intertrac>[a-zA-z]:)?(?P<moduleargs>(&#34;(.*?)&#34;|'(.*?)')|([^ ]*[^\., \)]))))""",
               r"""(?P<wikilink>!?(^|(?<=[^A-Za-z]))[A-Z][a-z]+(?:[A-Z][a-z]*[a-z/])+(?=\Z|\s|,|\.|:|\)))""",
               r"""(?P<fancylink>!?\[(?P<fancyurl>([a-z]+:[^ ]+)) (?P<linkname>.*?)\])"""]

Changed 4 years ago by cboos@…

(Once again, coffee badly needed...)

  • WikiFormatter.py

    === WikiFormatter.py
    ==================================================================
     
    116116              r"""(?P<tickethref>!?#(?P<t_intertrac>[a-zA-z]?)\d+)""", 
    117117              r"""(?P<changesethref>!?\[(?P<c_intertrac>[a-zA-z]?)\d+\])""", 
    118118              r"""(?P<reporthref>!?\{\d+\})""", 
    119               r"""(?P<modulehref>!?((?P<modulename>bug|ticket|browser|source|repos|report|changeset|wiki|milestone|search):(?P<m_intertrac>[a-zA-z]:?)(?P<moduleargs>(&#34;(.*?)&#34;|'(.*?)')|([^ ]*[^\., \)]))))""", 
     119              r"""(?P<modulehref>!?((?P<modulename>bug|ticket|browser|source|repos|report|changeset|wiki|milestone|search):(?P<m_intertrac>[a-zA-z]:)?(?P<moduleargs>(&#34;(.*?)&#34;|'(.*?)')|([^ ]*[^\., \)]))))""", 
    120120              r"""(?P<wikilink>!?(^|(?<=[^A-Za-z]))[A-Z][a-z]+(?:[A-Z][a-z]*[a-z/])+(?=\Z|\s|,|\.|:|\)))""", 
    121121              r"""(?P<fancylink>!?\[(?P<fancyurl>([a-z]+:[^ ]+)) (?P<linkname>.*?)\])"""] 
    122122 

Changed 4 years ago by cboos@…

...hum, what about a feature to edit/remove embarassingly stupid comments :)

  • WikiFormatter.py

    === WikiFormatter.py
    ==================================================================
     
    116116              r"""(?P<tickethref>!?#(?P<t_intertrac>[a-zA-z]?)\d+)""", 
    117117              r"""(?P<changesethref>!?\[(?P<c_intertrac>[a-zA-z]?)\d+\])""", 
    118118              r"""(?P<reporthref>!?\{\d+\})""", 
    119               r"""(?P<modulehref>!?((?P<modulename>bug|ticket|browser|source|repos|report|changeset|wiki|milestone|search):(?P<m_intertrac>[a-zA-z]:?)(?P<moduleargs>(&#34;(.*?)&#34;|'(.*?)')|([^ ]*[^\., \)]))))""", 
     119              r"""(?P<modulehref>!?((?P<modulename>bug|ticket|browser|source|repos|report|changeset|wiki|milestone|search):(?P<m_intertrac>[a-zA-z]:)?(?P<moduleargs>(&#34;(.*?)&#34;|'(.*?)')|([^ ]*[^\., \)]))))""", 
    120120              r"""(?P<wikilink>!?(^|(?<=[^A-Za-z]))[A-Z][a-z]+(?:[A-Z][a-z]*[a-z/])+(?=\Z|\s|,|\.|:|\)))""", 
    121121              r"""(?P<fancylink>!?\[(?P<fancyurl>([a-z]+:[^ ]+)) (?P<linkname>.*?)\])"""] 
    122122 

Changed 3 years ago by mgood

Well, it looks like cboos put [1505] in his branch related to this. I would prefer the original syntax proposed by daniel. The patch apparently supports arbitrary length names, although cboos tends to use a single character. I think that the syntax used by [1505] is ok if it is just a single character name, but for longer names I think the original syntax would work better.

I think we want to focus on handling the longer names, since for multi-project setups people will want to use the project's path as its InterTrac name. This will be important for forwards compatibility, since as daniel noted earlier, we should provide out-of-the-box support for linking to other projects in a multi-project installation.

Changed 3 years ago by cboos

  • owner changed from jonas to cboos
  • status changed from new to assigned

Well, I don't mind changing in favor of <project>:<module>:<id>, instead of <module>:<project>:<id>, for long links.

However, I largely prefer #<project><id> over <project>:#<id> and [<project><id>] over <project>:[<id>], for short-hand links.

I'll also have a look how to handle InterWiki links (#40) at the same time.

Changed 3 years ago by mgood

Well, besides just a personal preference for <project>:#<id> and the equivalents for other modules, the problem I can see with #<project><id> is possible ambiguities. Particularly, if the project name contains a number, it becomes difficult or impossible to determine what's part of the project name and what's the id. Numbers are valid for project URLs, so there's a chance that people are using them in multi-project setups. I don't think : characters are nearly as likely to be in a project URL as a number would be.

Changed 3 years ago by cboos

#<project><id> ... ambiguities. Particularly, if the project name contains a number

I see. My original idea was not to use the project name, but a project key, a kind of shortcut, e.g. T for Trac's Trac, most of the time one letter, but I allowed for more in case disambiguation is needed.

Now I also see the benefit of using the environment's name, for automatic linking into a Trac hosted by the same server, removing the need of setting up an [intertrac] section in TracIni.

Anyway, one can have the full project name and additionally define a project key, e.g. one of our environment is bct_repository: you can see it's more convenient to type #b123 than bct_repository:#123.

Changed 3 years ago by cboos

I tried to get the best of both worlds in [1508]. See the updated InterTrac specification. Please test!

Changed 3 years ago by trac@…

One simple way to fulfill David's original request is to use relative URLs, which use the same protocol as the current page. If you need to construct an absolute URL that uses the same protocol, you can use the relatively unknown protocol-relative URL link syntax:

//hostname.domain/path/to/filename.ext

(just leave off the http:)

Changed 3 years ago by cboos

I think the InterTrac feature is candidate for merging, see [1569].

Feedback welcomed!

Changed 3 years ago by ebcom

Using URLs (relative or absolute) is a bad idea: What about if the server name changes, or if the projects change on the server?: all the Wiki syntax (including pages, tickets, milestones, etc.) would have to be updated ;-(

InterTrac proposal seems nice. I hope it would be merged (very) soon into the trunk, as the need for InterTrac links is increasing every day.

Any comment from C.Lenz ?

Changed 3 years ago by cboos

  • priority changed from normal to high
  • milestone changed from 1.0 to 0.9

It would help to get some feedback about the feature. You can do a checkout of the intertrac-branch

svn co http://svn.projects.edgewall/trac/branches/cboos-dev/intertrac-branch

and setup several test environments, all managed by one tracd server, and tell us what you think.

Btw, if you rename an environment, you either have to rename the links or you have to setup an alias, e.g.

[intertrac]
# 'testproj' is now named 'project', but let's keep the intertrac links working
testproj = project

Changed 3 years ago by cmlenz

  • component changed from general to wiki

Changed 3 years ago by cboos

  • priority changed from high to highest

The feature was reimplemented against the current trunk.

Check out r1912.

Note: The InterTrac branch is a superset of the TracDiff branch. This has the advantage of needing less work for me in order to stay in sync with the trunk in all of my branches, and has the only disadvantage of needing a bit of work if one wants to isolate the feature.

But this isolation work should not happen often, in fact at most once if we decide to integrate InterTrac and not TracDiff, whereas the synchronization of the branches with the trunk happens quite regularly...

Changed 3 years ago by anonymous

이렇게 올리면 되는걸까요?

Changed 3 years ago by cboos

  • priority changed from highest to normal
  • severity changed from normal to major
  • milestone changed from 0.9 to 1.0

This will be post-poned to 1.0.

The InterTrac branch will be actively maintained meanwhile, and a patch for each released 0.9 version will be uploaded here.

Changed 3 years ago by cboos

I created a special purpose ticket for the branch integration: #2041. You can find the patches against 0.9.x there.

Changed 3 years ago by anonymous

  • cc trac.tickets@… added

Changed 3 years ago by cboos

  • keywords intertrac added

Changed 3 years ago by pixelpapst@…

  • cc pixelpapst@… added

Changed 2 years ago by cboos

  • milestone changed from 1.0 to 0.10

The syntax proposed by mgood is not working anymore for changesets and reports, because of issues like #1153 and #2240.

Only ticket links like trac:#234 are still working that way, so now there's the question to keep that as special cases or not.

Other forms of shorthand intertrac links still work (e.g. [T1505] or [trac 1505] and #T234).

Changed 2 years ago by cboos

  • status changed from assigned to closed
  • resolution set to fixed

Inter-project links (InterTrac links) are now part of the mainstream Trac, since r2839.

Add/Change #234 (Inter-project links)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.