Modify

Opened 3 years ago

Last modified 2 years ago

#10004 new enhancement

support of pdf file ressource path for Apache location

Reported by: falkb Owned by: ursaw
Priority: high Component: PdfImagePlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

Since my Apache webserver 192.168.1.10 also offers a location /Foo (which is a mapping to another network resource), I can access pdf files in the browser by typing https://192.168.1.10/Foo/example.pdf in the address line of the browser. Also [//Foo/example.pdf My PDF file] works as Trac link.

Now I want to use this path for PdfImg

[[PdfImg(//Foo/example.pdf)]]

but it just gives me the following error:

Error: Macro PdfImg(//Foo/example.pdf) failed
Der Anhang 'wiki:WikiStart: //Foo/example.pdf' existiert nicht.

Attachments (0)

Change History (5)

comment:1 Changed 3 years ago by ursaw

I think in your case you should try to use the Plugin with the file: protocol.

[[PdfImg(file:example.pdf)]]

You first need to add in the tracenv/conf/trac.ini. the mapping to the other network resource with see pdfimg.py parse_file() Line 277

[pdfimg]
file.prepath = /relative/entry/directory
file.preurl  = http://example.com/entrydir

I think this would be in your case something like:

[pdfimg]
# see your apache conf abize
file.prepath = /a/mapping/to/another/network/resource/Foo
file.preurl  = https://192.168.1.10/Foo

the plugin must known the physical location in the fileystem. you must therfore do the mapping a second time in the tracenv/conf/trac.ini.

comment:2 follow-up: Changed 3 years ago by falkb

I set

file.preurl = https://192.168.1.10

and tried

[[PdfImg(file:/the/rest/of/the/url/path/myfile%20test.pdf)]]

but get

Error: Macro PdfImg(/the/rest/of/the/url/path/myfile%20test.pdf) failed
asciifile:/the/rest/of/the/url/path/myfile%20test.pdf6162ordinal not in range(128)

I also don't understand why I must cut the whole thing into 3 pieces (prepath, preurl, path in macro)... Seems, it is important to know about the internals to get it where to cut my path into 3 pieces...

comment:3 in reply to: ↑ 2 ; follow-ups: Changed 3 years ago by ursaw

Replying to falkb:

PdfImg(file:/the/rest/of/the/url/path/myfile%20test.pdf)? }}} but get

Error: Macro PdfImg(/the/rest/of/the/url/path/myfile%20test.pdf) failed
asciifile:/the/rest/of/the/url/path/myfile%20test.pdf6162ordinal not in range(128)

This is an interesting case: Your file "myfile%20test.pdf" contains a blank "%20" apache resolves this correct, but if convert try to use "%20" on the filesystem this is not the same than a blank!

Please try a filename without a blank, or try

PdfImg(/the/rest/of/the/url/path/myfile test.pdf)

The Internals

This plugin an trac itself always distinguish between the external path and the internal path.

The mapping for the internal path in for tickets is implicit by the location of the tracenvironment on the harddrive and the external is done by the keyword "ticket:". If you have a look to Subversion-Resources, the external is "browser:" or "source:" and you find the internal in the trac configuration like:

[trac]
repository_type = svn
repository_dir = /path/to/the/svn

Something simular is done with the "file:" Resource. file.prepath is the internal, which is using convert, the external, which displays the png is relative to the tracenvironment and file.preurl is used as a (external) link for the PDF.

comment:4 in reply to: ↑ 3 Changed 2 years ago by ursaw

Replying to ursaw:

Replying to falkb:

PdfImg(file:/the/rest/of/the/url/path/myfile%20test.pdf)?

.....

Hey falkb does this explantion helped you? Can you close the ticket and may write a documentation for this, that is understandable for externals?

comment:5 in reply to: ↑ 3 Changed 2 years ago by falkb

ursaw, thank you for your reply.

Replying to ursaw:

The mapping for the internal path in for tickets is implicit by the location of the tracenvironment on the harddrive

What is "location of the tracenvironment on the harddrive"? The root path of the Trac system? The path of the Trac user project?

the external, which displays the png is relative to the tracenvironment

How can an external URL be relative to the trac environment? Not understood.

and file.preurl is used as a (external) link for the PDF.

If the file is at https://192.168.1.10/Foo/test.pdf , do I have to set file.preurl = https://192.168.1.10/Foo and then call [[PdfImg(test.pdf)]] ; or rather file.preurl = and [[PdfImg(https://192.168.1.10/Foo/test.pdf)]] ?

Add Comment

Modify Ticket

Action
as new The owner will remain ursaw.
Author


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

 
Note: See TracTickets for help on using tickets.