# HG changeset patch # User gibus # Date 1337856410 -7200 # Node ID d5d3bcd26a0ba1d5588887b444a14db727e90718 # Parent 0d2d10bc47bd4b8ff89bb8bcd002d8359cf7d032 Fixes export with abiword when attached images are served by co-ment diff -r 0d2d10bc47bd -r d5d3bcd26a0b src/cm/views/export.py --- a/src/cm/views/export.py Thu May 24 10:03:52 2012 +0200 +++ b/src/cm/views/export.py Thu May 24 12:46:50 2012 +0200 @@ -57,6 +57,18 @@ if USE_ABI: from cm.converters.abi_converters import AbiFileConverter converter = AbiFileConverter() + + # replaces images url by their actual path + from django.conf import settings + site_url = settings.SITE_URL + import re + attach_re = r'/attach/(?P\w*)/' + attach_str = r'%s/attach/%s/' + for match in re.findall(attach_re, fix_content): + link = attach_str %(site_url, match) + attach = Attachment.objects.get(key=match) + fix_content = fix_content.replace(link, attach.data.path) + export_content = converter.convert_from_html(fix_content, format) else: from cm.converters.oo_converters import convert_html as oo_convert