diff MoinMoin/items/__init__.py @ 1197:98ff5e7a0bec

Improved atom feed for page history
author Shitiz Garg <mail@dragooon.net>
date Tue, 03 Jan 2012 19:39:04 +0530
parents 1c5a013b9ebd
children 2aa4f4ec6a94
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Wed Jan 04 02:54:28 2012 +0530
+++ b/MoinMoin/items/__init__.py	Tue Jan 03 19:39:04 2012 +0530
@@ -736,7 +736,8 @@
 
     _render_data_diff_text = _render_data_diff
     _render_data_diff_raw = _render_data_diff
-
+    _render_data_diff_atom = _render_data_diff
+    
     def _convert(self, doc):
         return _("Impossible to convert the data to the contenttype: %(contenttype)s",
                  contenttype=request.values.get('contenttype'))
@@ -1111,20 +1112,27 @@
     def data_storage_to_internal(self, data):
         """ convert data from storage format to memory format """
         return data.decode(config.charset).replace(u'\r\n', u'\n')
-
-    def _render_data_diff(self, oldrev, newrev):
+ 
+    def _get_data_diff_html(self, oldrev, newrev, template):
         from MoinMoin.util.diff_html import diff
         old_text = self.data_storage_to_internal(oldrev.data.read())
         new_text = self.data_storage_to_internal(newrev.data.read())
         storage_item = flaskg.storage[self.name]
         diffs = [(d[0], Markup(d[1]), d[2], Markup(d[3])) for d in diff(old_text, new_text)]
-        return Markup(render_template('diff_text.html',
-                                      item_name=self.name,
-                                      oldrev=oldrev,
-                                      newrev=newrev,
-                                      diffs=diffs,
-                                     ))
+        return render_template(template,
+                               item_name=self.name,
+                               oldrev=oldrev,
+                               newrev=newrev,
+                               diffs=diffs,
+                               )
+                               
+    def _render_data_diff_atom(self, oldrev, newrev):
+        """ renders diff in HTML for atom feed """
+        return self._get_data_diff_html(oldrev, newrev, 'diff_text_atom.html')
 
+    def _render_data_diff(self, oldrev, newrev):
+        return Markup(self._get_data_diff_html(oldrev, newrev, 'diff_text.html'))
+                                      
     def _render_data_diff_text(self, oldrev, newrev):
         from MoinMoin.util import diff_text
         oldlines = self.data_storage_to_internal(oldrev.data.read()).split('\n')