comparison MoinMoin/items/__init__.py @ 202:9ffa82e550ba

highlight view: move dom conversion code to Item method
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 30 Apr 2011 16:06:18 +0200
parents 19e92e1ff286
children 1d416427b7be
comparison
equal deleted inserted replaced
201:159473d3b7e7 202:9ffa82e550ba
258 xlink.namespace: 'xlink', 258 xlink.namespace: 'xlink',
259 html.namespace: 'html', 259 html.namespace: 'html',
260 }, 260 },
261 method='xml') 261 method='xml')
262 return out.tounicode() 262 return out.tounicode()
263
264 def _render_data_highlight(self):
265 # override this in child classes
266 return ''
263 267
264 def _do_modify_show_templates(self): 268 def _do_modify_show_templates(self):
265 # call this if the item is still empty 269 # call this if the item is still empty
266 rev_nos = [] 270 rev_nos = []
267 item_templates = self.get_templates(self.mimetype) 271 item_templates = self.get_templates(self.mimetype)
1031 oldlines = self.data_storage_to_internal(oldrev.read()).split('\n') 1035 oldlines = self.data_storage_to_internal(oldrev.read()).split('\n')
1032 newlines = self.data_storage_to_internal(newrev.read()).split('\n') 1036 newlines = self.data_storage_to_internal(newrev.read()).split('\n')
1033 difflines = diff_text.diff(oldlines, newlines) 1037 difflines = diff_text.diff(oldlines, newlines)
1034 return '\n'.join(difflines) 1038 return '\n'.join(difflines)
1035 1039
1040 def _render_data_highlight(self):
1041 from MoinMoin.converter import default_registry as reg
1042 from MoinMoin.util.mime import Type, type_moin_document
1043 from MoinMoin.util.tree import html
1044 data_text = self.data_storage_to_internal(self.data)
1045 # TODO: use registry as soon as it is in there
1046 from MoinMoin.converter.pygments_in import Converter as PygmentsConverter
1047 pygments_conv = PygmentsConverter(mimetype=self.mimetype)
1048 doc = pygments_conv(data_text.split(u'\n'))
1049 # TODO: Real output format
1050 html_conv = reg.get(type_moin_document, Type('application/x-xhtml-moin-page'))
1051 doc = html_conv(doc)
1052 from array import array
1053 out = array('u')
1054 doc.write(out.fromunicode, namespaces={html.namespace: ''}, method='xml')
1055 return out.tounicode()
1056
1036 def do_modify(self, template_name): 1057 def do_modify(self, template_name):
1037 form = TextChaizedForm.from_defaults() 1058 form = TextChaizedForm.from_defaults()
1038 TextCha(form).amend_form() 1059 TextCha(form).amend_form()
1039 if template_name is None and isinstance(self.rev, DummyRev): 1060 if template_name is None and isinstance(self.rev, DummyRev):
1040 return self._do_modify_show_templates() 1061 return self._do_modify_show_templates()