Skip to content

Commit

Permalink
serve site specific favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
mishfit committed Oct 21, 2016
1 parent 4ac933f commit 84ea168
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Ui/UiRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ def route(self, path):

if path == "/":
return self.actionIndex()
elif path.endswith("favicon.ico"):
return self.actionFile("src/Ui/media/img/favicon.ico")
# Media
elif path.startswith("/uimedia/"):
return self.actionUiMedia(path)
Expand Down Expand Up @@ -198,6 +196,10 @@ def actionWrapper(self, path, extra_headers=None):
(not site.getReachableBadFiles() or site.settings["own"])
): # Its downloaded or own
title = site.content_manager.contents["content.json"]["title"]
try:
favicon = site.content_manager.contents["content.json"]["favicon"]
except KeyError:
favicon = "src/Ui/media/img/favicon.ico"
else:
title = "Loading %s..." % address
site = SiteManager.site_manager.need(address) # Start download site
Expand All @@ -206,13 +208,13 @@ def actionWrapper(self, path, extra_headers=None):
return False

self.sendHeader(extra_headers=extra_headers[:])
return iter([self.renderWrapper(site, path, inner_path, title, extra_headers)])
return iter([self.renderWrapper(site, path, inner_path, title, favicon, extra_headers)])
# Dont know why wrapping with iter necessary, but without it around 100x slower

else: # Bad url
return False

def renderWrapper(self, site, path, inner_path, title, extra_headers):
def renderWrapper(self, site, path, inner_path, title, favicon, extra_headers):
file_inner_path = inner_path
if not file_inner_path:
file_inner_path = "index.html" # If inner path defaults to index.html
Expand Down Expand Up @@ -272,6 +274,7 @@ def renderWrapper(self, site, path, inner_path, title, extra_headers):
file_inner_path=re.escape(file_inner_path),
address=site.address,
title=cgi.escape(title, True),
favicon=re.escape(favicon),
body_style=body_style,
meta_tags=meta_tags,
query_string=re.escape(query_string),
Expand Down
1 change: 1 addition & 0 deletions src/Ui/template/wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<html>
<head>
<title>{title} - ZeroNet</title>
<link rel="icon" href="{favicon}">
<meta charset="utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/uimedia/all.css?rev={rev}" />
Expand Down

0 comments on commit 84ea168

Please sign in to comment.