29 class html_to_html(Transform): |
29 class html_to_html(Transform): |
30 inputs = HTML_MIMETYPES |
30 inputs = HTML_MIMETYPES |
31 output = 'text/html' |
31 output = 'text/html' |
32 def _convert(self, trdata): |
32 def _convert(self, trdata): |
33 return html_publish(trdata.appobject, trdata.data) |
33 return html_publish(trdata.appobject, trdata.data) |
34 |
34 |
35 class ept_to_html(Transform): |
|
36 inputs = ('text/cubicweb-page-template',) |
|
37 output = 'text/html' |
|
38 output_encoding = 'utf-8' |
|
39 def _convert(self, trdata): |
|
40 from cubicweb.common.tal import compile_template |
|
41 value = trdata.encode(self.output_encoding) |
|
42 return trdata.appobject.tal_render(compile_template(value), {}) |
|
43 |
|
44 |
35 |
45 # Instantiate and configure the transformation engine |
36 # Instantiate and configure the transformation engine |
46 |
37 |
47 mtconverter.UNICODE_POLICY = 'replace' |
38 mtconverter.UNICODE_POLICY = 'replace' |
48 |
39 |
49 ENGINE = TransformEngine() |
40 ENGINE = TransformEngine() |
50 ENGINE.add_transform(rest_to_html()) |
41 ENGINE.add_transform(rest_to_html()) |
51 ENGINE.add_transform(html_to_html()) |
42 ENGINE.add_transform(html_to_html()) |
52 ENGINE.add_transform(ept_to_html()) |
43 |
|
44 try: |
|
45 from cubicweb.common.tal import compile_template |
|
46 except ImportError: |
|
47 HAS_TAL = False |
|
48 else: |
|
49 HAS_TAL = True |
|
50 |
|
51 class ept_to_html(Transform): |
|
52 inputs = ('text/cubicweb-page-template',) |
|
53 output = 'text/html' |
|
54 output_encoding = 'utf-8' |
|
55 def _convert(self, trdata): |
|
56 value = trdata.encode(self.output_encoding) |
|
57 return trdata.appobject.tal_render(compile_template(value), {}) |
|
58 |
|
59 ENGINE.add_transform(ept_to_html()) |
53 |
60 |
54 if register_pil_transforms(ENGINE, verb=False): |
61 if register_pil_transforms(ENGINE, verb=False): |
55 HAS_PIL_TRANSFORMS = True |
62 HAS_PIL_TRANSFORMS = True |
56 else: |
63 else: |
57 HAS_PIL_TRANSFORMS = False |
64 HAS_PIL_TRANSFORMS = False |