Opened 11 years ago
Last modified 4 years ago
#11432 new defect
The href of customized navigation items doesn't work as documented
Reported by: | Ryan J Ollos | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | next-dev-1.7.x |
Component: | general | Version: | |
Severity: | normal | Keywords: | navigation bitesized |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
TracNavigation#Notes suggests that the following mappings should occur:
/projects/project1/wiki/WikiStart
→/projects/projects1/wiki/WikiStart
wiki/WikiStart
→/projects/project1/wiki/WikiStart
(when in theproject1
environment).
This is not the case however. An href
beginning with /
is treated as project-relative. There does not seem to be a way to create an interproject link in a multiproject/multienvironment setup sharing the same base url link without using the base url in the href
or using ..
in the href
(e.g. ../project2/wiki/WikiStart
).
Using an href
such as wiki/WikiStart
results in repeated clicks on the mainnav button mapping to /projects/project1/wiki/WikiStart
→ /projects/project1/wiki/WikiStart/wiki/WikiStart
→ /projects/project1/wiki/WikiStart/wiki/WikiStart/wiki/WikiStart
.
Unfortunately I think the proper fix would change the behavior for existing users:
-
trac/web/chrome.py
diff --git a/trac/web/chrome.py b/trac/web/chrome.py index f627ae5..7b392f3 100644
a b class Chrome(Component): 724 724 label = category_section.get(name + '.label') 725 725 href = category_section.get(name + '.href') 726 726 if href: 727 if href.startswith('/'): 727 if not href.startswith(('http://', 728 'https://', '/')): 728 729 href = req.href + href 729 730 if label: 730 731 item = tag.a(label) # create new label
Attachments (0)
Change History (8)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Milestone: | next-stable-1.0.x → next-dev-1.1.x |
---|---|
Owner: | set to |
Status: | new → assigned |
Since either the documentation needs to be changed or the patch needs to be applied, I vote for applying the patch on the trunk since it make the configuration more flexible, and documenting the behavior for Trac < 1.2. That will avoid breaking configurations on 1.0-stable and earlier.
For example, after the patch is applied a user that has an href = /wiki/WikiStart
with a base URL for the project http://example.com/proj1
will need to change to href = wiki/WikiStart
otherwise the link will direct to http://example.com/wiki/WikiStart
. However, after the patch a link can be created to another project using href = /proj2/wiki/WikiStart
, which will map to http://example.com/proj2/wiki/WikiStart
. See th:#11443 for a related issue.
I'll wait for feedback from the other Trac devs before proceeding.
comment:3 by , 11 years ago
A backwards-compatible alternative for interproject links might be href = //proj2/wiki/WikiStart
. Personally I would find that + the current behavior less surprising than resolving relative links to the project base.
(Though perhaps //
should be interpreted as a protocol-relative absolute URL, as it would be if seen directly in a browser. It currently just becomes http://example.com/proj1//proj2/wiki/WikiStart
which is almost certainly never useful.)
Granted, relative links don't seem like a very desirable feature for the mainnav. I can imagine (maybe still unlikely) uses for relative links in the metanav though, in plugins that also implement IRequestHandler
— e.g. contextual help, or "create a ticket linked to the page I'm on", or "show me API functions available for this resource".
comment:4 by , 10 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
comment:5 by , 10 years ago
Keywords: | bitesized added |
---|
comment:6 by , 9 years ago
Milestone: | next-dev-1.1.x → next-dev-1.3.x |
---|
Replying to rjollos: […]
yes
afaik , no … unless InterTrac or a custom TracLinks expression is installed .
wiki/WikiStart is a relative wiki path , varies depending on (wiki) context
yep, I'm not very sure about it …
[…]