55 from cm.converters.oo_converters import combine_css_body |
55 from cm.converters.oo_converters import combine_css_body |
56 fix_content = combine_css_body(content, '') |
56 fix_content = combine_css_body(content, '') |
57 if USE_ABI: |
57 if USE_ABI: |
58 from cm.converters.abi_converters import AbiFileConverter |
58 from cm.converters.abi_converters import AbiFileConverter |
59 converter = AbiFileConverter() |
59 converter = AbiFileConverter() |
|
60 |
|
61 # replaces images url by their actual path |
|
62 from django.conf import settings |
|
63 site_url = settings.SITE_URL |
|
64 import re |
|
65 attach_re = r'/attach/(?P<attach_key>\w*)/' |
|
66 attach_str = r'%s/attach/%s/' |
|
67 for match in re.findall(attach_re, fix_content): |
|
68 link = attach_str %(site_url, match) |
|
69 attach = Attachment.objects.get(key=match) |
|
70 fix_content = fix_content.replace(link, attach.data.path) |
|
71 |
60 export_content = converter.convert_from_html(fix_content, format) |
72 export_content = converter.convert_from_html(fix_content, format) |
61 else: |
73 else: |
62 from cm.converters.oo_converters import convert_html as oo_convert |
74 from cm.converters.oo_converters import convert_html as oo_convert |
63 export_content = oo_convert(fix_content, format) |
75 export_content = oo_convert(fix_content, format) |
64 |
76 |