Add preview pdf for accessibilty.

This commit is contained in:
BoHung Chiu 2020-05-20 11:52:25 +08:00
parent c6e54e202a
commit faf8d57a31
2 changed files with 11 additions and 4 deletions

View File

@ -195,7 +195,7 @@ class ArchivesController < ApplicationController
@path = file.file.file.file rescue ""
@filename = @path.split("/").last
@ext = @path.split("/").last.to_s.split(".").last
if @ext == "png" || @ext == "jpg" || @ext == "bmp"
if @ext == "png" || @ext == "jpg" || @ext == "bmp" || @ext == "pdf"
render "download_file",:layout=>false
else
send_file(@path)

View File

@ -1,4 +1,4 @@
<html lang="<%= I18n.locale.to_s%>">
<html lang="<%= I18n.locale.to_s%>" style="margin: 0em; padding: 0em; width: 100%; height: 100%; overflow: hidden; background-color: rgb(230, 230, 230);">
<head>
<meta name="viewport" content="width=device-width, minimum-scale=0.1">
<title><%=@filename%></title>
@ -6,6 +6,13 @@
</head>
<body>
<h3 style="display: none;"><%=@filename%></h3>
<img alt="<%=@filename%>" src="<%=@url%>">
<% if @ext != "png" && @ext != "jpg" && @ext != "bmp" %>
<object data="<%=@url%>" height="100%" type="application/<%=@ext%>" width="100%">
<iframe height="100%" src="<%=@url%>" title="<%=@filename%>" width="100%"></iframe>
</object>
<embed height="100%" src="<%=@url%>" title="<%=@filename%>" width="100%" type="application/pdf"></embed>
<% else %>
<img alt="<%=@filename%>" src="<%=@url%>">
<% end %>
</body>
</html>>
</html>