I've changed some code in the wikiprint.py in order to enable the local access to the images, fonts and other ressources instead of downloading them via webserver. This can be usefull if you are using IIS on Windows, or you have SSON authentication enabled...
It's a draft, I don't have the time to submit it to SVN, but I hope, someone will take care of it :)
Code
def getFileName(self, name, relative=''):
try:
self.env.log.debug('WikiPrint.linkLoader => Orignal name: %s' % name)
if name.startswith('http://') or name.startswith('https://'):
self.env.log.debug('WikiPrint.linkLoader => Resolving URL: %s' % name)
url = urlparse.urljoin(relative, name)
rawpost = url.find('/raw-attachment/')
if rawpost > -1:
if self.env.config.get('wikiprint', 'raw_attachment_path'):
raw_attachment_path = self.env.config.get('wikiprint', 'raw_attachment_path')
self.env.log.debug('WikiPrint.linkLoader => raw_attachment_path will be applied')
name = url[rawpost+16:]
self.env.log.debug('WikiPrint.linkLoader => Stripped name: %s' % name)
name1=os.path.join(raw_attachment_path, name)
self.env.log.debug('WikiPrint.linkLoader => Changed name: %s' % name1)
inj_control=name1.find(raw_attachment_path)
if inj_control == 0:
return name1
else:
self.env.log.error('WikiPrint.linkLoader => Injection found!' % name1)
return ''
self.env.log.debug('WikiPrint.linkLoader => urljoined URL: %s' % url)
elif self.allow_local:
self.req.perm.assert_permission('WIKIPRINT_FILESYSTEM')
self.env.log.debug("WikiPrint.linkLoader => Resolve local filesystem %s", name)
return name
else:
#Relative path
if self.env.config.get('wikiprint', 'relative_path'):
self.env.log.debug("WikiPrint.linkLoader => Using path %s ",self.env.config.get('wikiprint', 'relative_path'))
url = os.path.join(self.env.config.get('wikiprint', 'relative_path'), name)
self.env.log.debug("WikiPrint.linkLoader => Substituing relative path %s to %s", name, url)
return url
else:
self.env.log.debug("WikiPrint.linkLoader => Relative path %s to %s", name, urlparse.urljoin(self.req.abs_href(), name))
url = urlparse.urljoin(self.req.abs_href(), name)
path = urlparse.urlsplit(url)[2]
Usage
Add following rows in to [wikiprint] section of trac.ini :
raw_attachment_path = D:\Support\Projects\ABC\attachments\
relative_path = D:\FontStorage\
The raw_attachment_path is the path to wiki and ticket attachments in the trac project directory
relative_path is the path to ressource storage... (like fonts used in css etc..)