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

@ -190,10 +190,23 @@ class ArchivesController < ApplicationController
if !file.nil? if !file.nil?
file.download_count = file.download_count + 1 file.download_count = file.download_count + 1
file.save file.save
redirect_to file.file.url and return @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 end
rescue
redirect_to @url
end
else
render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found
end end
end
def group_by_category def group_by_category
cat_id = OrbitHelper.widget_categories.map {|cat_id| cat_id.to_s} cat_id = OrbitHelper.widget_categories.map {|cat_id| cat_id.to_s}

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>>