Opened 13 years ago
Last modified 10 years ago
#10670 new enhancement
Image macro references inconsistent with attachment links
Reported by: | Mikael Relbe | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | next-major-releases |
Component: | wiki system | Version: | 0.13dev |
Severity: | normal | Keywords: | imagemacro bitesized |
Cc: | Ryan J Ollos | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
The format of the reference for Image macro is not aligned with that of attachment:
links.
External reference to attachment is stated as "attachment:file:module:id
". It would be nice if one could copy an attachment link to the Image macro by just ripping away "attachment:
"
Now, one has to swap parts of the attachment reference to suit the Image macro:
attachment:file:module:id
>[[Image(module:id:file)]]
This is annoying/confusing.
My view is that the Image macro is fault since both attachment:
and comment:
links use the same pattern. (Hard to accept, I imagine, since that would break existing image references to external resources.)
Attachments (0)
Change History (7)
comment:1 by , 13 years ago
Type: | defect → enhancement |
---|
comment:2 by , 12 years ago
Cc: | added |
---|
comment:3 by , 12 years ago
Milestone: | → next-dev-1.1.x |
---|
So we should support [[Image(file:module:id)]]
↔ attachment:file:module:id
.
As a first step, it shouldn't be that problematic to try supporting both.
Given 1:2:3
, check whether:
2:3
refers to a resource (usingextract_link
) (new syntax)- if not, that
1:2
refers to a resource (old syntax)
comment:4 by , 12 years ago
Keywords: | bitesized added |
---|
comment:5 by , 12 years ago
It looks like module:id:file
is a legacy TracLink syntax, supported by the attachment module trunk/trac/attachment.py@11112:966-975#L962. From the documentation for the attachment TracLink: Note that the older way, putting the filename at the end, is still supported: attachment:ticket:753:the_file.txt
.
I started an implementation that is patterned after that for the attachment module. I couldn't see a way to do it using extract_link
that was as clean. There seems to be some undocumented intertrac support, however it doesn't seem to work, and I can't understand how the ImageMacro could even benefit from intertrac support.
So here is a partial patch that would not preserve the existing intertrac functionality, but I'm hoping to get some feedback on how to deal with that before proceeding.
-
trac-trunk/trac/wiki/macros.py
26 26 27 27 from trac.core import * 28 28 from trac.resource import ( 29 Resource, ResourceNotFound, get_resource_name, get_resource_summary,30 get_resource_ url29 Resource, ResourceNotFound, ResourceSystem, get_resource_name, 30 get_resource_summary, get_resource_url 31 31 ) 32 32 from trac.util.datefmt import format_date, from_utimestamp, user_time 33 33 from trac.util.html import escape, find_element … … 595 595 if params: 596 596 url += '?' + params 597 597 raw_url, desc = url, filespec 598 elif len(parts) == 3: # realm:id:attachment-filename 599 # # or intertrac:realm:id 600 realm, id, filename = parts 598 elif len(parts) == 3: 599 known_realms = ResourceSystem(self.env).get_known_realms() 600 if parts[1] in known_realms: # new-style: filename:realm:id 601 filename, realm, id = parts 602 else: # old-style: realm:id:filename 603 realm, id, filename = parts 601 604 intertrac_target = "%s:%s" % (id, filename) 602 it = formatter.get_intertrac_url(realm, intertrac_target) 605 it = formatter.get_intertrac_url(realm, intertrac_target) # intertrac:realm:id 603 606 if it: 604 607 url, desc = it 605 608 raw_url = url + unicode_quote('?format=raw')
comment:7 by , 10 years ago
Cc: | added; removed |
---|
comment:8 by , 10 years ago
Milestone: | next-dev-1.1.x → next-major-releases |
---|
Retargetting tickets to narrow focus for milestone:1.2. Please move the ticket back to milestone:next-dev-1.1.x if you intend to resolve it by milestone:1.2.
Sorry, didn't mean to report this as a defect, this is of cource an enhancement proposal (however painful…)