Shitiz Garg avatar Shitiz Garg committed 92d8f07

Improve handling of other data types in atom feed, also remove anchor tags from line numbers

Comments (0)

Files changed (4)

MoinMoin/apps/feed/views.py

                     content = hl_item._render_data_diff_atom(previous_rev, this_rev)
                 else:
                     # full html rendering for new items
-                    content = render_template('atom.html', get='first_revision', content=Markup(hl_item._render_data()), revision=this_revid)
+                    content = render_template('atom.html', get='first_revision', rev=this_rev, content=Markup(hl_item._render_data()), revision=this_revid)
                 content_type = 'html'
             except Exception as e:
                 logging.exception("content rendering crashed")
                 feed_title = "{0} - {1}".format(author.get(NAME, ''), rev_comment)
             else:
                 feed_title = "{0}".format(author.get(NAME, ''))
+            if not item_name:
+                feed_title = "{0} - {1}".format(name, feed_title)
             feed.add(title=feed_title, title_type='text',
                      summary=content, summary_type=content_type,
                      author=author,

MoinMoin/items/__init__.py

 
     _render_data_diff_text = _render_data_diff
     _render_data_diff_raw = _render_data_diff
-    _render_data_diff_atom = _render_data_diff
+    
+    def _render_data_diff_atom(self, oldrev, newrev):
+        url = url_for('frontend.get_item', _external=True, item_name=self.name, rev=newrev.revid)
+        return render_template('atom.html', url=url, 
+                               oldrev=oldrev, newrev=newrev, get='binary',
+                               content=Markup(self._render_data()))
 
     def _convert(self, doc):
         return _("Impossible to convert the data to the contenttype: %(contenttype)s",
 
 class Image(Binary):
     """ Base class for image/* """
-
+    def _render_data_diff(self, oldrev, newrev):
+        print 'test'
+        print self._internal_representation()
 item_registry.register(Image._factory, Type('image/*'))
 
 

MoinMoin/templates/atom.html

+{% import "utils.html" as utils %}
+{% macro show_meta(rev) %}
+    <div class="moin-diff-info moin-diff-info-rev-id">
+        <span class="moin-diff-info-caption">{{ _('Revision') }}:</span>
+        <span class="moin-diff-info-value">{{ rev.meta['revid'] | shorten_id }}</span>
+    </div>
+    <div class="moin-diff-info moin-diff-info-rev-size">
+        <span class="moin-diff-info-caption">{{ _('Size') }}:</span>
+        <span class="moin-diff-info-value">{{ rev.meta['size'] }}</span>
+    </div>
+    <div class="moin-diff-info moin-diff-info-rev-comment">
+        <span class="moin-diff-info-caption">{{ _('Comment') }}:</span>
+        <span class="moin-diff-info-value">{{ rev.meta['comment'] }}</span>
+    </div>
+{% endmacro %}
+
+{% macro safe_style() %}
+    <style type="text/css">
+        img {
+            max-width: 100%;
+        }
+        td {
+            padding-right: 10px;
+        }
+        table {
+            width: 100%;
+        }
+    </style>
+{% endmacro %}
+
 {%- if get == 'xml' -%}
     <?xml-stylesheet type="text/xsl" href="{{ theme_static('atom.xslt') }}"?>
 {%- elif get == 'comment_cont_merge' -%}
     <p style="font-size: 14px">...{{ comment }}</p> <br /> {{ content }}
 {%- elif get == 'first_revision' -%}
-    <div class="moin-diff-info moin-diff-info-rev-id">
-        <span class="moin-diff-info-caption"><strong>Revision: {{ revision | shorten_id }}</strong> - <i>{{ _('First revision') }}</i></span>
-    </div><br />
+    <table class="moin-diff" cellpadding="10" width="100%">
+        <tr>
+            <td class="moin-diff-header" style="width: 100%;">
+                <strong>{{ show_meta(rev) }}</strong>
+            </td>
+        </tr>
+    </table>
+    <br />
     {{ content }}
+    <strong>{{ safe_style() }}</strong>
+{%- elif get == 'binary' -%}
+    <table class="moin-diff" cellpadding="10" width="100%">
+        <tr>
+            <td class="moin-diff-header" style="width: 50%;">
+                <strong>{{ show_meta(oldrev) }}</strong>
+            </td>
+            <td class="moin-diff-header" style="width: 50%;">
+                <strong>{{ show_meta(newrev) }}</strong>
+            </td>
+        </tr>
+    </table>
+    <br />
+    {{ content }}
+    {{ safe_style() }}
 {%- endif -%}

MoinMoin/templates/diff_text_atom.html

 
 {% macro show_meta(rev) %}
     <div class="moin-diff-info moin-diff-info-rev-id">
-        <span class="moin-diff-info-caption">Revision:</span>
+        <span class="moin-diff-info-caption">{{ _('Revision') }}:</span>
         <span class="moin-diff-info-value">{{ rev.meta['revid'] | shorten_id }}</span>
     </div>
+    <div class="moin-diff-info moin-diff-info-rev-size">
+        <span class="moin-diff-info-caption">{{ _('Size') }}:</span>
+        <span class="moin-diff-info-value">{{ rev.meta['size'] }}</span>
+    </div>
+    <div class="moin-diff-info moin-diff-info-rev-comment">
+        <span class="moin-diff-info-caption">{{ _('Comment') }}:</span>
+        <span class="moin-diff-info-value">{{ rev.meta['comment'] }}</span>
+    </div>
 {% endmacro %}
 <table class="moin-diff" style="width: 100%;">
     <tr>
         </td>    </tr>
     {% for llineno, lcontent, rlineno, rcontent in diffs %}
         <tr>
-            <td style="vertical-align: top;"><a href="#{{ llineno }}">{{ llineno }}:</a></td>
+            <td style="vertical-align: top;">{{ llineno }}:</td>
             <td class="moin-diff-removed" style="vertical-align: top; background-color:#ff9; word-wrap: break-word;"><blockquote>{{ lcontent }}</blockquote></td>
-            <td style="vertical-align: top;"><a href="#{{ rlineno }}">{{ rlineno }}:</a></td>
+            <td style="vertical-align: top;">{{ rlineno }}:</td>
             <td class="moin-diff-added" style="vertical-align: top; background-color: #cfc; word-wrap: break-word;"><blockquote>{{ rcontent }}</blockquote></td>
         </tr>
     {% endfor %}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.