Fix accessibility.

This commit is contained in:
BoHung Chiu 2020-05-17 21:30:39 +08:00
parent 9708c378e0
commit c6e54e202a
3 changed files with 45 additions and 5 deletions

View File

@ -0,0 +1,16 @@
body{
margin: 0px;
background: #0e0e0e;
}
img{
-webkit-user-select: none;
margin: auto;
display: block;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
h3{
display: none;
}

View File

@ -188,11 +188,24 @@ class ArchivesController < ApplicationController
file_id = params[:file]
file = ArchiveFileMultiple.find(file_id) rescue nil
if !file.nil?
file.download_count = file.download_count + 1
file.save
redirect_to file.file.url and return
end
render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found
file.download_count = file.download_count + 1
file.save
@url = file.file.url
begin
@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"
render "download_file",:layout=>false
else
send_file(@path)
end
rescue
redirect_to @url
end
else
render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found
end
end
def group_by_category

View File

@ -0,0 +1,11 @@
<html lang="<%= I18n.locale.to_s%>">
<head>
<meta name="viewport" content="width=device-width, minimum-scale=0.1">
<title><%=@filename%></title>
<link href="/assets/archive/download_file.css" rel="stylesheet" media="all">
</head>
<body>
<h3 style="display: none;"><%=@filename%></h3>
<img alt="<%=@filename%>" src="<%=@url%>">
</body>
</html>>