Commit b07216b4 authored by Fred Drake's avatar Fred Drake

Added support for --favicon.

Fix support for the Aesop Meta Type.
parent 56c8c27b
...@@ -8,6 +8,7 @@ __version__ = '$Revision$' ...@@ -8,6 +8,7 @@ __version__ = '$Revision$'
import getopt import getopt
import os.path
import sys import sys
...@@ -18,7 +19,7 @@ class Options: ...@@ -18,7 +19,7 @@ class Options:
"columns=", "help", "output=", "columns=", "help", "output=",
# content components # content components
"address=", "iconserver=", "address=", "iconserver=", "favicon=",
"title=", "uplink=", "uptitle="] "title=", "uplink=", "uptitle="]
outputfile = "-" outputfile = "-"
...@@ -26,6 +27,7 @@ class Options: ...@@ -26,6 +27,7 @@ class Options:
letters = 0 letters = 0
uplink = "index.html" uplink = "index.html"
uptitle = "Python Documentation Index" uptitle = "Python Documentation Index"
favicon = None
# The "Aesop Meta Tag" is poorly described, and may only be used # The "Aesop Meta Tag" is poorly described, and may only be used
# by the Aesop search engine (www.aesop.com), but doesn't hurt. # by the Aesop search engine (www.aesop.com), but doesn't hurt.
...@@ -89,6 +91,8 @@ class Options: ...@@ -89,6 +91,8 @@ class Options:
self.uptitle = val.strip() self.uptitle = val.strip()
elif opt == "--iconserver": elif opt == "--iconserver":
self.variables["iconserver"] = val.strip() or "." self.variables["iconserver"] = val.strip() or "."
elif opt == "--favicon":
self.favicon = val.strip()
else: else:
self.handle_option(opt, val) self.handle_option(opt, val)
if self.uplink and self.uptitle: if self.uplink and self.uptitle:
...@@ -114,11 +118,20 @@ class Options: ...@@ -114,11 +118,20 @@ class Options:
repl = " %s\n</head>" % link repl = " %s\n</head>" % link
s = s.replace("</head>", repl, 1) s = s.replace("</head>", repl, 1)
if self.aesop_type: if self.aesop_type:
meta = '\n <meta name="aesop" content="%s">' meta = '<meta name="aesop" content="%s">\n ' % self.aesop_type
# Insert this in the middle of the head that's been # Insert this in the middle of the head that's been
# generated so far, keeping <meta> and <link> elements in # generated so far, keeping <meta> and <link> elements in
# neat groups: # neat groups:
s = s.replace("<link ", meta + "<link ", 1) s = s.replace("<link ", meta + "<link ", 1)
if self.favicon:
ext = os.path.splitext(self.favicon)[1]
if ext in (".gif", ".png"):
type = ' type="image/%s"' % ext[1:]
else:
type = ''
link = ('<link rel="SHORTCUT ICON" href="%s"%s>\n '
% (self.favicon, type))
s = s.replace("<link ", link + "<link ", 1)
return s return s
def get_footer(self): def get_footer(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment