Skip to content

Commit b25e0b0

Browse files
committed
show google previews on file show page if supported
Google previews weren't being shown Test Plan: * only enable google docs locally * upload a pdf to the course * link a module to that file * click the module link * the file should be previewed with google docs refs #11219 Change-Id: I75da7ba9fbfbd4051f3d5493a4bbb99c076cddc5 Reviewed-on: https://gerrit.instructure.com/14653 Reviewed-by: Cameron Matheson <cameron@instructure.com> Tested-by: Jenkins <jenkins@instructure.com>
1 parent 4be0c71 commit b25e0b0

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

app/helpers/attachment_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def doc_preview_attributes(attachment, attrs={})
3636
ErrorReport.log_exception('scribd', e)
3737
end
3838
end
39+
attrs[:attachment_id] = attachment.id
40+
attrs[:mimetype] = attachment.mimetype
3941
attrs.inject("") { |s,(attr,val)| s << "data-#{attr}=#{val} " }
4042
end
4143
end

app/views/files/show.html.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@
4141
<span style="font-size: 1.2em;">
4242
<%= link_to "Download #{@attachment.display_name}", download_url %>
4343
</span> (<%= @attachment.readable_size %>)
44-
<% if @attachment.crocodoc_available? || @attachment.scribdable? %>
45-
<div id="doc_preview" <%= doc_preview_attributes(@attachment, :attachment_view_inline_ping_url => context_url(@context, :context_file_inline_view_url, @attachment.id)) %>></div>
46-
<% end %>
44+
<div id="doc_preview" <%= doc_preview_attributes(@attachment, :attachment_view_inline_ping_url => context_url(@context, :context_file_inline_view_url, @attachment.id)) %>></div>
4745
<% end %>
4846
<% end %>
4947
<%= render :partial => 'shared/sequence_footer', :locals => {:asset => @attachment} %>

public/javascripts/jquery.doc_previews.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ define([
136136
}
137137
// END COPIED SNIPPETT
138138

139-
} else if (!INST.disableGooglePreviews && (!opts.mimeType || $.isPreviewable(opts.mimeType, 'google')) && opts.attachment_id || opts.public_url){
139+
} else if (!INST.disableGooglePreviews && (!opts.mimetype || $.isPreviewable(opts.mimetype, 'google')) && opts.attachment_id || opts.public_url){
140140
// else if it's something google docs preview can handle and we can get a public url to this document.
141141
function loadGooglePreview(){
142142
// this handles both ssl and plain http.
@@ -164,9 +164,9 @@ define([
164164
}
165165
});
166166
}
167-
} else {
167+
} else if ($.filePreviewsEnabled()) {
168168
// else fall back with a message that the document can't be viewed inline
169-
$this.html('<p>' + htmlEscape(I18n.t('errors.cannot_view_document_inline', 'This document cannot be viewed inline, you might not have permission to view it or it might have been deleted.')) + '</p>');
169+
$this.html('<p>' + htmlEscape(I18n.t('errors.cannot_view_document_inline', 'This document cannot be viewed inline.')) + '</p>');
170170
}
171171
});
172172
};

0 commit comments

Comments
 (0)