Modify

Opened 16 years ago

Closed 15 years ago

#3493 closed enhancement (fixed)

Support for downloading dynamic images through the webserver

Reported by: Nickolas Grigoriadis Owned by: Nickolas Grigoriadis
Priority: normal Component: TracWikiToPdfPlugin
Severity: normal Keywords:
Cc: andreasgebhardt@… Trac Release: 0.11

Description

Since a significant number of images in our wiki is dynamicly generated images, such as emoticons and latex-math or similar, and there is no way to configure the current wikitopdf plugon to do it, I did a quick hack to wikitopdf.py to download the images to a temporary location and then use those.

Excuse the script oddness, I have never programmed in python before (I used wget to download the images)

Attached is the modified mikitopdf.py

Attachments (7)

wikitopdf.py (3.6 KB) - added by Nickolas Grigoriadis 16 years ago.
modified version to download all images from the webserver
wikitopdf_2.2_dynimg_css.patch (11.8 KB) - added by Nickolas Grigoriadis 16 years ago.
Patch to add Downloading Images & enable Code highlighting wht using HTMLDoc 1.9
TestPage.txt (1.7 KB) - added by Nickolas Grigoriadis 16 years ago.
Sample input
TestPage.pdf (156.7 KB) - added by Nickolas Grigoriadis 16 years ago.
Sample Output - HTMLDoc 1.9
tracwikitopdfplugin.img-patch (4.2 KB) - added by andreasgebhardt@… 16 years ago.
support for TracMathPlugin and Graphviz Plugin, base_dir substituion
wikitopdf_2.2.2_dynimg_css.patch (12.4 KB) - added by Nickolas Grigoriadis 16 years ago.
Update of patch for WikiToPdf 2.2.2
tracwikitopdf-dynimg.patch (13.4 KB) - added by iamer@… 15 years ago.
Patch to fix downloading images that have params in their name like "?width=" for example like the ones generated by google charts plugin.

Download all attachments as: .zip

Change History (18)

Changed 16 years ago by Nickolas Grigoriadis

Attachment: wikitopdf.py added

modified version to download all images from the webserver

comment:1 Changed 16 years ago by Nickolas Grigoriadis

Type: defectenhancement

comment:2 Changed 16 years ago by Diorgenes Felipe Grzesiuk

Trac Release: 0.100.11

Hi Nickolas,

Please, I need a patch file with your code. Which trac version are you using?

Regards

Diorgenes F. Grzesiuk

comment:3 Changed 16 years ago by Nickolas Grigoriadis

Hi Diorgenes

I'll re-do the code for that tomorrow, I was using Trac 0.11. I'll see if I can do the code a bit cleaner. (and optional)

I also have some other changes where I work around some HTMLDoc limitations, and if using HTMLDoc 1.9 (unstable) it even does code highlighting.

Changed 16 years ago by Nickolas Grigoriadis

Patch to add Downloading Images & enable Code highlighting wht using HTMLDoc 1.9

Changed 16 years ago by Nickolas Grigoriadis

Attachment: TestPage.txt added

Sample input

Changed 16 years ago by Nickolas Grigoriadis

Attachment: TestPage.pdf added

Sample Output - HTMLDoc 1.9

comment:4 Changed 16 years ago by Nickolas Grigoriadis

Hi Diorgenes

Added trac.ini options:

[wikitopdf] tmp_dir = /tmp/wikitopdf trac_uri = http://trac.blah.is.co.za css_file = /var/lib/trac/IS/conf/htmldoc.css

both trac_uri and tmp_dir has to be defined for the dynamic image downloading to work. (Otherwise it uses the existing method, to not break upgrades) the css_file points to a css file (included in patch) for HTMLDoc 1.9, so that code highlighting can work.

The patch also adds tables around div frames, so that the output looks closer to the wiki pages.

I know that there is a lot of changes, but you can take your time evaluating them.

Thanks, Nickolas

comment:5 Changed 16 years ago by Nickolas Grigoriadis

[wikitopdf]
tmp_dir = /tmp/wikitopdf
trac_uri = http://trac.blah.is.co.za
css_file = /var/lib/trac/IS/conf/htmldoc.css

comment:6 in reply to:  5 Changed 16 years ago by Diorgenes Felipe Grzesiuk

Status: newassigned

Replying to grigi:

[wikitopdf]
tmp_dir = /tmp/wikitopdf
trac_uri = http://trac.blah.is.co.za
css_file = /var/lib/trac/IS/conf/htmldoc.css

Hi

I need more time for study your contribution. Just for now thank you.

Regards

Diorgenes F. Grzesiuk

comment:7 in reply to:  description Changed 16 years ago by andreasgebhardt@…

Cc: andreasgebhardt@… added; anonymous removed
Type: enhancementdefect

Replying to nagrigoriadis@gmail.com:

Since a significant number of images in our wiki is dynamicly generated images, such as emoticons and latex-math or similar, and there is no way to configure the current wikitopdf plugon to do it, I did a quick hack to wikitopdf.py to download the images to a temporary location and then use those.

Hi everyone,

i had similar problems. In wikitopdf.py (45-50) the base_dir is set as prefix for image source.

45 	    imgpos = page.find('<img')
46 	
47 	    while imgpos != -1:
48 	        addrpos = page.find('src=',imgpos)
49 	        page = page[:addrpos+5] + base_dir + page[addrpos+5:]
50 	        imgpos = page.find('<img', addrpos)

But the image source is like https://localhost:8443/trac/sandbox/attachment/wiki/WikiStart/image.jpg. After adding base_dir, which points to the trac project, i had base_dirhttps://localhost:8443/trac/sandbox/attachment/wiki/WikiStart/071small.jpg which isn't the right image source. So i substitute the base trac uri by base_dir

abs_ref = (req or env).abs_href.base
href = (req or env).href.base

As result now i get !base_dir/attachment/wiki/WikiStart/image.jpg.

By the way i also added two options for supporting TracMathPlugin and GraphvizPlugin without downloading via wget. The options are

[wikitopdf]
graphviz_dir = 
tracmath_dir =

These are the direcories where the both plugins save there images. A patch file is added as attachment.

Best regards,
Andreas Gebhardt

Changed 16 years ago by andreasgebhardt@…

support for TracMathPlugin and Graphviz Plugin, base_dir substituion

Changed 16 years ago by Nickolas Grigoriadis

Update of patch for WikiToPdf 2.2.2

comment:8 Changed 16 years ago by Nickolas Grigoriadis

diorgenes, Do you need me to split the patch into several small parts? I would like to get as much of this into the mainline version.

Changed 15 years ago by iamer@…

Attachment: tracwikitopdf-dynimg.patch added

Patch to fix downloading images that have params in their name like "?width=" for example like the ones generated by google charts plugin.

comment:9 Changed 15 years ago by Nickolas Grigoriadis

Just a note: htmldoc version htmldoc-1.9.x-r1586 has broken headers/footers, version htmldoc-1.9.x-r1563 works fine.

You only need the unstable 1.9 version if you want syntax highlighting and/or css support.

comment:10 Changed 15 years ago by Nickolas Grigoriadis

Owner: changed from Diorgenes Felipe Grzesiuk to Nickolas Grigoriadis
Status: assignednew
Type: defectenhancement

This ticket's patches has been added to the svn repos. Leaving ticket open until updating documentation.

comment:11 Changed 15 years ago by Nickolas Grigoriadis

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Nickolas Grigoriadis.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.