Make separate template for send and receive mode

This commit is contained in:
Micah Lee 2018-03-06 02:06:44 -08:00
parent fa9f714651
commit baede53632
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
3 changed files with 120 additions and 5 deletions

View File

@ -147,7 +147,7 @@ class Web(object):
# If download is allowed to continue, serve download page # If download is allowed to continue, serve download page
r = make_response(render_template_string( r = make_response(render_template_string(
open(common.get_resource_path('html/index.html')).read(), open(common.get_resource_path('html/send.html')).read(),
favicon_b64=self.favicon_b64, favicon_b64=self.favicon_b64,
logo_b64=self.logo_b64, logo_b64=self.logo_b64,
folder_b64=self.folder_b64, folder_b64=self.folder_b64,
@ -275,7 +275,17 @@ class Web(object):
""" """
@self.app.route("/<slug_candidate>") @self.app.route("/<slug_candidate>")
def index(slug_candidate): def index(slug_candidate):
return "Receive Mode" self.check_slug_candidate(slug_candidate)
# If download is allowed to continue, serve download page
r = make_response(render_template_string(
open(common.get_resource_path('html/receive.html')).read(),
favicon_b64=self.favicon_b64,
logo_b64=self.logo_b64,
slug=self.slug))
for header, value in self.security_headers:
r.headers.set(header, value)
return r
def common_routes(self): def common_routes(self):
@ -293,7 +303,7 @@ class Web(object):
self.error404_count += 1 self.error404_count += 1
if self.error404_count == 20: if self.error404_count == 20:
self.add_request(self.REQUEST_RATE_LIMIT, request.path) self.add_request(self.REQUEST_RATE_LIMIT, request.path)
force_shutdown() self.force_shutdown()
print(strings._('error_rate_limit')) print(strings._('error_rate_limit'))
r = make_response(render_template_string( r = make_response(render_template_string(
@ -309,8 +319,8 @@ class Web(object):
""" """
Stop the flask web server, from the context of an http request. Stop the flask web server, from the context of an http request.
""" """
check_slug_candidate(slug_candidate, shutdown_slug) self.check_slug_candidate(slug_candidate, shutdown_slug)
force_shutdown() self.force_shutdown()
return "" return ""
def set_file_info(self, filenames, processed_size_callback=None): def set_file_info(self, filenames, processed_size_callback=None):

105
share/html/receive.html Normal file
View File

@ -0,0 +1,105 @@
<!DOCTYPE html>
<html>
<head>
<title>OnionShare</title>
<link href="data:image/x-icon;base64,{{favicon_b64}}" rel="icon" type="image/x-icon" />
<style type="text/css">
.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
body {
margin: 0;
font-family: Helvetica;
}
header {
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
background: #fcfcfc;
background: -webkit-linear-gradient(top, #fcfcfc 0%, #f2f2f2 100%);
padding: 0.8rem;
}
header .logo {
vertical-align: middle;
width: 45px;
height: 45px;
}
header h1 {
display: inline-block;
margin: 0 0 0 0.5rem;
vertical-align: middle;
font-weight: normal;
font-size: 1.5rem;
color: #666666;
}
header .right {
float: right;
font-size: .75rem;
}
header .right ul li {
display: inline;
margin: 0 0 0 .5rem;
font-size: 1rem;
}
header .button {
color: #ffffff;
background-color: #4e064f;
padding: 10px;
border-radius: 5px;
text-decoration: none;
margin-left: 1rem;
cursor: pointer;
}
table.file-list {
width: 100%;
margin: 0 auto;
border-collapse: collapse;
}
table.file-list th {
text-align: left;
text-transform: uppercase;
font-weight: normal;
color: #666666;
padding: 0.5rem;
}
table.file-list tr {
border-bottom: 1px solid #e0e0e0;
}
table.file-list td {
white-space: nowrap;
padding: 0.5rem 10rem 0.5rem 0.8rem;
}
table.file-list td img {
vertical-align: middle;
margin-right: 0.5rem;
}
table.file-list td:last-child {
width: 100%;
}
</style>
</head>
<body>
<header class="clearfix">
<img class="logo" src="data:image/png;base64,{{logo_b64}}" title="OnionShare">
<h1>OnionShare</h1>
</header>
</body>
</html>