show.mustache 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <%
  2. # Copyright (C) 2011 - present Instructure, Inc.
  3. #
  4. # This file is part of Canvas.
  5. #
  6. # Canvas is free software: you can redistribute it and/or modify it under
  7. # the terms of the GNU Affero General Public License as published by the Free
  8. # Software Foundation, version 3 of the License.
  9. #
  10. # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License along
  16. # with this program. If not, see <http://www.gnu.org/licenses/>.
  17. %>
  18. <% content_for :page_title do %>
  19. <%= join_title @attachment.display_name, @context.name %>
  20. <% end %>
  21. <% add_crumb @attachment.display_name, context_url(@context, :context_file_url, @attachment) %>
  22. <% download_url = context_url(@context, :context_file_download_url, @attachment.id, download_frd: 1) %>
  23. <% js_bundle 'module_sequence_footer' %>
  24. <% if !can_do(@attachment.context, @current_user, :manage_files) && (locked = @attachment.locked_for?(@current_user)) %>
  25. <div style="margin: 10px 50px;">
  26. <% if @attachment.folder && @attachment.folder.locked? %>
  27. <%= t 'messages.folder_locked', "The folder \"%{folder},\" which includes this file, has been locked.", :folder => @attachment.folder.name %>
  28. <% else %>
  29. <%= locked.is_a?(Hash) ? lock_explanation(locked, 'file', @context) : t('messages.file_locked', "This file has not been unlocked yet.") %>
  30. <% end %>
  31. </div>
  32. <% else %>
  33. <h2><%= @attachment.display_name %></h2>
  34. <div>
  35. <span style="font-size: 1.2em;">
  36. <%= link_to "Download #{@attachment.display_name}", download_url %>
  37. </span> (<%= @attachment.readable_size %>)
  38. </div>
  39. <% if @attachment.content_type == "application/x-shockwave-flash" %>
  40. <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" class="embedded_swf">
  41. <param name="movie" value="<%= safe_domain_file_url(@attachment) %>" />
  42. <param name="wmode" value="transparent" />
  43. <param name="salign" value="t" />
  44. <param name="allowscriptaccess" value="never" />
  45. <!--[if !IE]>-->
  46. <object type="application/x-shockwave-flash" data="<%= safe_domain_file_url(@attachment) %>" class="embedded_swf">
  47. <param name="wmode" value="transparent" />
  48. <param name="salign" value="t" />
  49. <param name="allowscriptaccess" value="never" />
  50. <!--<![endif]-->
  51. <!--[if !IE]>-->
  52. </object>
  53. <!--<![endif]-->
  54. </object>
  55. <% elsif @attachment.inline_content? && !@attachment.canvadocable? %>
  56. <% js_bundle :file_inline %>
  57. <iframe id="file_content" src="<%= safe_domain_file_url(@attachment) %>" style="width: 100%; height: 400px;" title="{{#t}}File Content{{/t}}"></iframe>
  58. <% elsif @attachment.content_type && @attachment.content_type.match(/\Aimage\//) %>
  59. <%= link_to(image_tag(download_url, :alt => @attachment.display_name), download_url) %>
  60. <% elsif @attachment.content_type && @attachment.content_type.match(/\Avideo\/|audio\//) %>
  61. <% js_bundle :file_preview %>
  62. <div id="media_preview" <%= media_preview_attributes(@attachment) %>></div>
  63. <% else %>
  64. <% js_bundle :file_show %>
  65. <div id="doc_preview" <%= doc_preview_attributes(@attachment) %>></div>
  66. <% end %>
  67. <% end %>
  68. {{> views/shared/sequence_footer}}