#11294 closed enhancement (fixed)
Allow Image macro to serve files from the shared htdocs directory
Reported by: | Owned by: | Ryan J Ollos | |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.2 |
Component: | rendering | Version: | |
Severity: | normal | Keywords: | image macro |
Cc: | Branch: | ||
Release Notes: |
The |
||
API Changes: | |||
Internal Changes: |
Description
It would be really helpful if the Image macro could be extended to accept "shared" as a possible module. Right now, the documentation says I can pull an image from a wiki page, ticket, the project's htdocs directory or a repository. It would be nice to put images in the "shared" location and refer to them there.
Attachments (0)
Change History (8)
follow-up: 5 comment:1 by , 11 years ago
Keywords: | image macro added |
---|
comment:2 by , 11 years ago
I think this is unrelated to the changes proposed in this ticket, but I noticed that if [inherit] htdocs_dir
is empty or doesn't exist, then the following traceback can be seen in the console when we try to load a page that uses an image from shared:
02:45:12 PM Trac[main] ERROR: Internal Server Error: Traceback (most recent call last): File "/home/user/Workspace/t11294/teo-rjollos.git/trac/web/main.py", line 497, in _dispatch_request dispatcher.dispatch(req) File "/home/user/Workspace/t11294/teo-rjollos.git/trac/web/main.py", line 214, in dispatch resp = chosen_handler.process_request(req) File "/home/user/Workspace/t11294/teo-rjollos.git/trac/web/chrome.py", line 621, in process_request assert os.path.commonprefix([dir, path]) == dir AssertionError:
If I'm using the Image
macro to display trac_logo.png
from the shared directory, but that directory doesn't exist, I see:
03:05:29 PM Trac[chrome] WARNING: File trac_logo.png not found in any of [u'/var/www/shared/htdocs']
However, if [inherit] htdocs_dir =
, or the option isn't defined in trac.ini, the traceback results.
If I change the code slightly to show the values being asserted:
03:09:21 PM Trac[main] ERROR: Internal Server Error: Traceback (most recent call last): File "/home/user/Workspace/t11294/teo-rjollos.git/trac/web/main.py", line 497, in _dispatch_request dispatcher.dispatch(req) File "/home/user/Workspace/t11294/teo-rjollos.git/trac/web/main.py", line 214, in dispatch resp = chosen_handler.process_request(req) File "/home/user/Workspace/t11294/teo-rjollos.git/trac/web/chrome.py", line 621, in process_request assert os.path.commonprefix([dir, path]) == dir, [os.path.commonprefix([dir, path]), dir] AssertionError: ['', '.']
Another way to reproduce the traceback is to set [header_logo] src
to a file in the shared htdocs_dir and leave [inherit] htdocs_dir
empty.
If we remove the assertion, we get a more useful error in the log:
03:22:34 PM Trac[chrome] WARNING: File trac_logo.png not found in any of ['.'] 03:22:34 PM Trac[main] WARNING: [127.0.0.1] HTTPNotFound: 404 Not Found (File trac_logo.png not found)
I'm not sure what the purpose of that assert
statement is. It was added in [1888], and I can't come up with a case for which the assertion could have been false in [1188]. However, after [1892] the assertion can be false if os.normpath(dir) != dir
.
comment:3 by , 11 years ago
Milestone: | → 1.0.2 |
---|---|
Owner: | set to |
Status: | new → assigned |
Some minor Image
macro documentation changes in a795b44/rjollos.git, including a note about when the shared
prefix was added: (since 1.0.2).
comment:4 by , 11 years ago
Summary: | add module for Image macro: shared → Allow Image macro to serve files from the shared htdocs directory |
---|
follow-up: 7 comment:5 by , 11 years ago
Replying to rjollos:
… I'm thinking about whether the prefix should be
shared
orshared-htdocs
. Since "shared" is anhtdocs
directory, it might make more sense to have prefixessite-htdocs
andshared-htdocs
, withhtdocs
being a backward-compatible alias forsite-htdocs
.
Or we could have the prefixes be site
and shared
, with htdocs
a backward compatible alias for site
.
comment:6 by , 11 years ago
comment:7 by , 11 years ago
Replying to rjollos:
Or we could have the prefixes be
site
andshared
, withhtdocs
a backward compatible alias forsite
.
I like this approach or just adding shared
prefix.
comment:8 by , 11 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Committed to 1.0-stable in [12045:12046]. Merged to trunk in [12047]. Thanks for reviewing Jun!
Proposed changes can be found in rjollos.git:t11294. I'm thinking about whether the prefix should be
shared
orshared-htdocs
. Since "shared" is anhtdocs
directory, it might make more sense to have prefixessite-htdocs
andshared-htdocs
, withhtdocs
being a backward-compatible alias forsite-htdocs
.