Edgewall Software
Modify

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#11294 closed enhancement (fixed)

Allow Image macro to serve files from the shared htdocs directory

Reported by: oblio.leitch@… Owned by: Ryan J Ollos
Priority: normal Milestone: 1.0.2
Component: rendering Version:
Severity: normal Keywords: image macro
Cc: Branch:
Release Notes:

The shared prefix can be used with the Image macro to serve files from the shared htdocs directory (TracIni#GlobalConfiguration).

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)

comment:1 by Ryan J Ollos, 11 years ago

Keywords: image macro added

Proposed changes can be found in rjollos.git:t11294. I'm thinking about whether the prefix should be shared or shared-htdocs. Since "shared" is an htdocs directory, it might make more sense to have prefixes site-htdocs and shared-htdocs, with htdocs being a backward-compatible alias for site-htdocs.

comment:2 by Ryan J Ollos, 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.

Last edited 11 years ago by Ryan J Ollos (previous) (diff)

comment:3 by Ryan J Ollos, 11 years ago

Milestone: 1.0.2
Owner: set to Ryan J Ollos
Status: newassigned

Some minor Image macro documentation changes in a795b44/rjollos.git, including a note about when the shared prefix was added: (since 1.0.2).

Last edited 11 years ago by Ryan J Ollos (previous) (diff)

comment:4 by Ryan J Ollos, 11 years ago

Summary: add module for Image macro: sharedAllow Image macro to serve files from the shared htdocs directory

in reply to:  1 ; comment:5 by Ryan J Ollos, 11 years ago

Replying to rjollos:

… I'm thinking about whether the prefix should be shared or shared-htdocs. Since "shared" is an htdocs directory, it might make more sense to have prefixes site-htdocs and shared-htdocs, with htdocs being a backward-compatible alias for site-htdocs.

Or we could have the prefixes be site and shared, with htdocs a backward compatible alias for site.

comment:6 by Ryan J Ollos, 11 years ago

I created #11295 for dealing with the findings from comment:2. I'll wait a few days, and then likely implement the changes described in comment:5, provided there are no suggestions to approach this differently.

in reply to:  5 comment:7 by Jun Omae, 11 years ago

Replying to rjollos:

Or we could have the prefixes be site and shared, with htdocs a backward compatible alias for site.

I like this approach or just adding shared prefix.

comment:8 by Ryan J Ollos, 11 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed to 1.0-stable in [12045:12046]. Merged to trunk in [12047]. Thank for reviewing Jun!

Version 0, edited 11 years ago by Ryan J Ollos (next)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.