Modify

Opened 4 years ago

Closed 22 months ago

#8066 closed defect (fixed)

TracLink to a PDF in the repository is not redirected

Reported by: boleslaw.tokarski@… Owned by: rjollos
Priority: normal Component: PdfRedirectorPlugin
Severity: normal Keywords: source browser, preview
Cc: hasienda Trac Release: 0.12

Description

Hello,

I gave the plugin a try. It looks good when the file referenced is an attachment.
However when you use [source:file.pdf] then the preview is still generated. I tried that on a git repository, but I suppose that svn behaves the same way.
It would be cool to have that straight. Thanks for your good work!

Cheers!

Attachments (0)

Change History (9)

comment:1 Changed 4 years ago by rjollos

  • Summary changed from PDF preview in repository browser to TracLink to a PDF in the repository is not redirected

comment:2 Changed 3 years ago by zgoey@…

Yes, svn behaves in the same way. I agree that this would be a nice enhancement.

comment:3 Changed 2 years ago by rjollos

  • Cc hasienda added
  • Owner changed from nicholasbs to rjollos
  • Status changed from new to assigned

comment:4 Changed 2 years ago by rjollos

Proposed patch, which is nearly a complete rewrite of this tiny plugin.

  • trunk/pdfredirector/pdfredirector.py

     
    1313        return template, data, content_type 
    1414 
    1515    def pre_process_request(self, req, handler): 
     16         
    1617        path = req.path_info.strip('/').split('/') 
    17         if len(path) < 2 or path[0] != 'attachment' or req.args.get('action') == 'delete': 
    18             return handler 
    19  
    20         if not path[-1].lower().endswith('.pdf'): 
    21             return handler 
    22  
    23         filename = req.href(*(['raw-attachment'] + path[1:])) 
    24  
    25         req.redirect(filename)  
     18                 
     19        if len(path) > 1 and path[-1].lower().endswith('.pdf'): 
     20            if path[0] == 'attachment' and not req.args.get('action') == 'delete': 
     21                filepath = req.href(*(['raw-attachment'] + path[1:])) 
     22                req.redirect(filepath) 
     23            elif path[0] == 'browser': 
     24                path[0] = 'export' 
     25                rev = req.args.get('rev', 'HEAD') 
     26                path.insert(1, rev) 
     27                filepath = req.href('/'.join(path)) 
     28                req.redirect(filepath) 
    2629 
    27  
    28  
    29  
    30  
     30        return handler 

comment:5 Changed 2 years ago by rjollos

(In [11799]) Refs #8066: Redirect TracLink to a PDF in the repository.

comment:6 Changed 2 years ago by rjollos

Code review and feedback welcomed and appreciated.

comment:7 Changed 22 months ago by rjollos

I think it is time to bump the revision and create a tag for this. Anyone r11799 or later that can give some feedback?

comment:8 Changed 22 months ago by rjollos

(In [12181]) Refs #8066: Bumped version to 0.3. Added tags directory.

comment:9 Changed 22 months ago by rjollos

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [12182]) Fixes #8066: Tagged version 0.3.

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from rjollos. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.