Skip to content
Snippets Groups Projects
Commit 08d5c4c5 authored by Pregmodder's avatar Pregmodder
Browse files

Merge branch 'embed_favicon' into 'pregmod-master'

fix encoding: embed favicons after meta charset tag

See merge request pregmodfan/fc-pregmod!2145
parents e2510559 2247c2f6
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ def data_uri_from_file(filename, mimetype): ...@@ -32,7 +32,7 @@ def data_uri_from_file(filename, mimetype):
if __name__ == "__main__": if __name__ == "__main__":
# find project root directory path # find project root directory path
# (script file is expected to reside in devTools) # (script file is expected to reside in devTools)
project_root_path = os.path.dirname(os.path.dirname(__file__)) project_root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# path to SugarCube's header.html # path to SugarCube's header.html
header_html_path = os.path.join( header_html_path = os.path.join(
project_root_path, project_root_path,
...@@ -78,12 +78,12 @@ if __name__ == "__main__": ...@@ -78,12 +78,12 @@ if __name__ == "__main__":
lines_in = hf.readlines() # read whole file lines_in = hf.readlines() # read whole file
lines_out = [] lines_out = []
for line in lines_in: for line in lines_in:
# embed favicons into head
if (line.startswith('</head>')):
lines_out.extend(favicons_html)
# remove all currently embedded favicons # remove all currently embedded favicons
if (not (line.startswith('<link') and 'icon' in line)): if (not (line.startswith('<link') and 'icon' in line)):
lines_out.append(line) lines_out.append(line)
# embed favicons into head
if (line.startswith('<head>')):
lines_out.extend(favicons_html)
hf.seek(0) # move to beginning of file hf.seek(0) # move to beginning of file
hf.write(''.join(lines_out)) # overwrite with new data hf.write(''.join(lines_out)) # overwrite with new data
hf.truncate() # remove trailing old data hf.truncate() # remove trailing old data
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment