]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1251236 - Please show the diff on the attachment details page when a patch has...
authorByron Jones <glob@mozilla.com>
Wed, 23 Mar 2016 03:25:52 +0000 (11:25 +0800)
committerByron Jones <glob@mozilla.com>
Wed, 23 Mar 2016 03:25:52 +0000 (11:25 +0800)
extensions/MozReview/template/en/default/hook/attachment/edit-view.html.tmpl [new file with mode: 0644]
template/en/default/attachment/edit.html.tmpl

diff --git a/extensions/MozReview/template/en/default/hook/attachment/edit-view.html.tmpl b/extensions/MozReview/template/en/default/hook/attachment/edit-view.html.tmpl
new file mode 100644 (file)
index 0000000..571d69b
--- /dev/null
@@ -0,0 +1,16 @@
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+  # License, v. 2.0. If a copy of the MPL was not distributed with this
+  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+  #
+  # This Source Code Form is "Incompatible With Secondary Licenses", as
+  # defined by the Mozilla Public License, v. 2.0.
+  #%]
+
+[%
+  RETURN UNLESS attachment.mimetype == "text/x-review-board-request" && attachment.external_redirect;
+  custom_attachment_viewer = 1;
+  url = attachment.data;
+%]
+<h3>
+  <a href="[% url FILTER none %]" title="[% url FILTER html %]">Show review on MozReview</a><br>
+</h3>
index 8dc29c1e6fed1f3830df472f51feb053f25de531..c7d85e270cd5bb4656860085cd8cfa024c74e812 100644 (file)
             </b></p>
           </div>
         [% ELSIF attachment.is_viewable %]
-          <div>
-            [% INCLUDE global/textarea.html.tmpl
-              id      = 'editFrame'
-              name    = 'comment'
-              classes   = 'bz_default_hidden'
-              minrows = 10
-              cols    = 80
-              wrap    = 'soft'
-              disabled = 'disabled'
-              defaultcontent = (attachment.contenttype.match('^text\/')) ?
-                                 attachment.data.replace('(.*\n|.+)', '>$1') : undef
-            %]
-            [% IF attachment.contenttype == 'text/plain' AND is_safe_url(attachment.data) %]
-              <p>
-                <a href="[% attachment.data FILTER html %]">
-                  [% IF attachment.datasize < 120 %]
-                    [% attachment.data FILTER html %]
-                  [% ELSE %]
-                    [% attachment.data FILTER truncate(80) FILTER html %]
-                    ...
-                    [% attachment.data.match('.*(.{20})$').0 FILTER html %]
-                  [% END %]
-                </a>
-              </p>
-            [% ELSIF attachment.contenttype == "text/html" %]
-              [%# For security reasons (clickjacking, embedded scripts), we never
-                # render HTML pages from here. The source code is displayed instead. %]
+          [%# to override attachment viewing, hook edit-view and set custom_attachment_viewer to 1 %]
+          [% custom_attachment_viewer = 0 %]
+          [% Hook.process('view') %]
+          [% UNLESS custom_attachment_viewer %]
+            <div>
               [% INCLUDE global/textarea.html.tmpl
-                 id      = 'viewFrame'
-                 minrows = 10
-                 cols    = 80
-                 defaultcontent = attachment.data
-                 readonly = 'readonly'
+                id      = 'editFrame'
+                name    = 'comment'
+                classes   = 'bz_default_hidden'
+                minrows = 10
+                cols    = 80
+                wrap    = 'soft'
+                disabled = 'disabled'
+                defaultcontent = (attachment.contenttype.match('^text\/')) ?
+                                  attachment.data.replace('(.*\n|.+)', '>$1') : undef
               %]
-            [% ELSE %]
-              <iframe id="viewFrame" src="attachment.cgi?id=[% attachment.id %]
-                [%- "&amp;content_type=text/plain" IF attachment.contenttype.match('^text/x-') %]">
-                <b>You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
-                <a href="attachment.cgi?id=[% attachment.id %]">View the attachment on a separate page</a>.</b>
-              </iframe>
-            [% END %]
-            <script type="text/javascript">
-              <!--
-              var patchviewerinstalled = 0;
-              var attachment_id = [% attachment.id %];
-              if (typeof document.getElementById == "function") {
-                [% IF use_patchviewer %]
-                  var patchviewerinstalled = 1;
-                  document.write('<iframe id="viewDiffFrame" class="bz_default_hidden"><\/iframe>');
-                [% END %]
-                [% IF user.id %]
-                  document.write('<button type="button" id="editButton" onclick="editAsComment(patchviewerinstalled);">Edit Attachment As Comment<\/button>');
-                  document.write('<button type="button" id="undoEditButton" onclick="undoEditAsComment(patchviewerinstalled);" class="bz_default_hidden">Undo Edit As Comment<\/button>');
-                  document.write('<button type="button" id="redoEditButton" onclick="redoEditAsComment(patchviewerinstalled);" class="bz_default_hidden">Redo Edit As Comment<\/button>');
-                  var editFrame = document.getElementById('editFrame');
-                  if (editFrame) {
-                    editFrame.disabled = false;
-                  }
-                [% END %]
-                [% IF use_patchviewer %]
-                  document.write('<button type="button" id="viewDiffButton" onclick="viewDiff(attachment_id, patchviewerinstalled);">View Attachment As Diff<\/button>');
-                [% END %]
-                document.write('<button type="button" id="viewRawButton" onclick="viewRaw(patchviewerinstalled);" class="bz_default_hidden">View Attachment As Raw<\/button>');
-              }
-              //-->
-            </script>
-          </div>
+              [% IF attachment.contenttype == 'text/plain' AND is_safe_url(attachment.data) %]
+                <p>
+                  <a href="[% attachment.data FILTER html %]">
+                    [% IF attachment.datasize < 120 %]
+                      [% attachment.data FILTER html %]
+                    [% ELSE %]
+                      [% attachment.data FILTER truncate(80) FILTER html %]
+                      ...
+                      [% attachment.data.match('.*(.{20})$').0 FILTER html %]
+                    [% END %]
+                  </a>
+                </p>
+              [% ELSIF attachment.contenttype == "text/html" %]
+                [%# For security reasons (clickjacking, embedded scripts), we never
+                  # render HTML pages from here. The source code is displayed instead. %]
+                [% INCLUDE global/textarea.html.tmpl
+                  id      = 'viewFrame'
+                  minrows = 10
+                  cols    = 80
+                  defaultcontent = attachment.data
+                  readonly = 'readonly'
+                %]
+              [% ELSE %]
+                <iframe id="viewFrame" src="attachment.cgi?id=[% attachment.id %]
+                  [%- "&amp;content_type=text/plain" IF attachment.contenttype.match('^text/x-') %]">
+                  <b>You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
+                  <a href="attachment.cgi?id=[% attachment.id %]">View the attachment on a separate page</a>.</b>
+                </iframe>
+              [% END %]
+              <script type="text/javascript">
+                <!--
+                var patchviewerinstalled = 0;
+                var attachment_id = [% attachment.id %];
+                if (typeof document.getElementById == "function") {
+                  [% IF use_patchviewer %]
+                    var patchviewerinstalled = 1;
+                    document.write('<iframe id="viewDiffFrame" class="bz_default_hidden"><\/iframe>');
+                  [% END %]
+                  [% IF user.id %]
+                    document.write('<button type="button" id="editButton" onclick="editAsComment(patchviewerinstalled);">Edit Attachment As Comment<\/button>');
+                    document.write('<button type="button" id="undoEditButton" onclick="undoEditAsComment(patchviewerinstalled);" class="bz_default_hidden">Undo Edit As Comment<\/button>');
+                    document.write('<button type="button" id="redoEditButton" onclick="redoEditAsComment(patchviewerinstalled);" class="bz_default_hidden">Redo Edit As Comment<\/button>');
+                    var editFrame = document.getElementById('editFrame');
+                    if (editFrame) {
+                      editFrame.disabled = false;
+                    }
+                  [% END %]
+                  [% IF use_patchviewer %]
+                    document.write('<button type="button" id="viewDiffButton" onclick="viewDiff(attachment_id, patchviewerinstalled);">View Attachment As Diff<\/button>');
+                  [% END %]
+                  document.write('<button type="button" id="viewRawButton" onclick="viewRaw(patchviewerinstalled);" class="bz_default_hidden">View Attachment As Raw<\/button>');
+                }
+                //-->
+              </script>
+            </div>
+          [% END %]
         [% ELSE %]
           <div id="noview">
             <p><b>