Add onionshare favicon to all HTML pages

This commit is contained in:
Micah Lee 2018-02-10 12:50:23 -08:00
parent 62a3b7d93c
commit 094041a4b6
6 changed files with 23 additions and 6 deletions

View File

@ -201,6 +201,7 @@ Section "install"
File "${BINPATH}\share\html\index.html" File "${BINPATH}\share\html\index.html"
SetOutPath "$INSTDIR\share\images" SetOutPath "$INSTDIR\share\images"
File "${BINPATH}\share\images\favicon.ico"
File "${BINPATH}\share\images\file_delete.png" File "${BINPATH}\share\images\file_delete.png"
File "${BINPATH}\share\images\logo.png" File "${BINPATH}\share\images\logo.png"
File "${BINPATH}\share\images\logo_transparent.png" File "${BINPATH}\share\images\logo_transparent.png"
@ -379,6 +380,7 @@ FunctionEnd
Delete "$INSTDIR\share\html\404.html" Delete "$INSTDIR\share\html\404.html"
Delete "$INSTDIR\share\html\denied.html" Delete "$INSTDIR\share\html\denied.html"
Delete "$INSTDIR\share\html\index.html" Delete "$INSTDIR\share\html\index.html"
Delete "$INSTDIR\share\images\favicon.ico"
Delete "$INSTDIR\share\images\file_delete.png" Delete "$INSTDIR\share\images\file_delete.png"
Delete "$INSTDIR\share\images\logo.png" Delete "$INSTDIR\share\images\logo.png"
Delete "$INSTDIR\share\images\logo_transparent.png" Delete "$INSTDIR\share\images\logo_transparent.png"

View File

@ -26,6 +26,7 @@ import queue
import socket import socket
import sys import sys
import tempfile import tempfile
import base64
from distutils.version import LooseVersion as Version from distutils.version import LooseVersion as Version
from urllib.request import urlopen from urllib.request import urlopen
@ -125,6 +126,9 @@ def add_request(request_type, path, data=None):
}) })
# Load favicon.ico and base64 encode it, to pass into templates
favicon_b64 = base64.b64encode(open(common.get_resource_path('images/favicon.ico'), 'rb').read()).decode()
slug = None slug = None
@ -206,7 +210,10 @@ def index(slug_candidate):
global stay_open, download_in_progress global stay_open, download_in_progress
deny_download = not stay_open and download_in_progress deny_download = not stay_open and download_in_progress
if deny_download: if deny_download:
r = make_response(render_template_string(open(common.get_resource_path('html/denied.html')).read())) r = make_response(render_template_string(
open(common.get_resource_path('html/denied.html')).read(),
favicon_b64=favicon_b64
))
for header, value in security_headers: for header, value in security_headers:
r.headers.set(header, value) r.headers.set(header, value)
return r return r
@ -215,6 +222,7 @@ def index(slug_candidate):
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/index.html')).read(),
favicon_b64=favicon_b64,
slug=slug, slug=slug,
file_info=file_info, file_info=file_info,
filename=os.path.basename(zip_filename), filename=os.path.basename(zip_filename),
@ -243,7 +251,10 @@ def download(slug_candidate):
global stay_open, download_in_progress, done global stay_open, download_in_progress, done
deny_download = not stay_open and download_in_progress deny_download = not stay_open and download_in_progress
if deny_download: if deny_download:
r = make_response(render_template_string(open(common.get_resource_path('html/denied.html')).read())) r = make_response(render_template_string(
open(common.get_resource_path('html/denied.html')).read(),
favicon_b64=favicon_b64
))
for header,value in security_headers: for header,value in security_headers:
r.headers.set(header, value) r.headers.set(header, value)
return r return r
@ -355,7 +366,10 @@ def page_not_found(e):
force_shutdown() force_shutdown()
print(strings._('error_rate_limit')) print(strings._('error_rate_limit'))
r = make_response(render_template_string(open(common.get_resource_path('html/404.html')).read()), 404) r = make_response(render_template_string(
open(common.get_resource_path('html/404.html')).read(),
favicon_b64=favicon_b64
), 404)
for header, value in security_headers: for header, value in security_headers:
r.headers.set(header, value) r.headers.set(header, value)
return r return r

View File

@ -2,6 +2,7 @@
<html> <html>
<head> <head>
<title>Error 404</title> <title>Error 404</title>
<link href="data:image/x-icon;base64,{{favicon_b64}}" rel="icon" type="image/x-icon" />
<style type="text/css"> <style type="text/css">
body { body {
background-color: #FFC4D5; background-color: #FFC4D5;

View File

@ -2,6 +2,7 @@
<html> <html>
<head> <head>
<title>OnionShare</title> <title>OnionShare</title>
<link href="data:image/x-icon;base64,{{favicon_b64}}" rel="icon" type="image/x-icon" />
<style> <style>
body { body {
background-color: #222222; background-color: #222222;
@ -15,4 +16,4 @@
<body> <body>
<p>OnionShare download in progress</p> <p>OnionShare download in progress</p>
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

BIN
share/images/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB