summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extensions/MozReview/template/en/default/hook/attachment/edit-view.html.tmpl16
-rw-r--r--template/en/default/attachment/edit.html.tmpl135
2 files changed, 86 insertions, 65 deletions
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
index 000000000..571d69b50
--- /dev/null
+++ b/extensions/MozReview/template/en/default/hook/attachment/edit-view.html.tmpl
@@ -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>
diff --git a/template/en/default/attachment/edit.html.tmpl b/template/en/default/attachment/edit.html.tmpl
index 8dc29c1e6..c7d85e270 100644
--- a/template/en/default/attachment/edit.html.tmpl
+++ b/template/en/default/attachment/edit.html.tmpl
@@ -175,73 +175,78 @@
</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>