4 Print a nice footer. add the top of the ChangeLog file (up to the ********)
20 mail_address = '(address unknown)'
22 mail_address= os.environ['MAILADDRESS']
26 webmaster= mail_address
28 webmaster= os.environ['WEBMASTER']
37 default_footer = r"""<hr>Please take me <a href=@INDEX@>back to the index</a>
43 This page was built from @PACKAGE_NAME@-@PACKAGE_VERSION@ by<br>
45 <address><font size="-1">@GCOS@ <<a href="mailto:%s">@MAIL_ADDRESS@</a>>,
46 @LOCALTIME@.</font></address>"""
56 sys.stderr.write ("can't open file: %s\n" % f)
60 sys.stderr.write ("gulped empty file: %s\n" % f)
65 sys.stdout.write (r"""Usage: add-html-footer [OPTION]... HTML-FILE
66 Add header, footer and top of ChangLog file (up to the ********) to HTML-FILE
69 --changelog=FILE use FILE as ChangeLog [ChangeLog]
70 --footer=FILE use FILE as footer
71 --header=FILE use FILE as header
72 -h, --help print this help
73 --index=URL set homepage to URL
74 --name=NAME set package_name to NAME
75 --version=VERSION set package version to VERSION
79 (options, files) = getopt.getopt(sys.argv[1:], 'h', [
80 'changelog=', 'footer=', 'header=', 'help', 'index=',
86 if o == '--changelog':
92 elif o == '-h' or o == '--help':
99 elif o == '--version':
102 raise 'unknown opt ', o
107 os.environ["CONFIGSUFFIX"] = 'www';
110 pw = ntpwd.getpwname(os.environ['USERNAME'])
113 if os.environ.has_key('FAKEROOTKEY'):
114 pw = pwd.getpwnam (os.environ['LOGNAME'])
116 pw = pwd.getpwuid (os.getuid())
119 f = string.split (f, ',')[0]
122 def compose (default, file):
129 localtime = time.strftime ('%c %Z', time.localtime (time.time ()))
131 if os.path.basename (index_url) != "index.html":
132 index_url = os.path.join (index_url , "index.html")
133 top_url = os.path.dirname (index_url) + "/"
135 header = compose (default_header, header_file)
136 footer = compose (default_footer, footer_file) + built
137 header_tag = '<!-- header_tag -->'
138 footer_tag = '<!-- footer_tag -->'
144 changes = gulp_file (changelog_file)
146 #m = re.search ('^\\\\*\\\\*', changes)
147 m = re.search (r'\*\*\*', changes)
149 changes = changes[:m.start (0)]
150 s = re.sub ('top_of_ChangeLog', '<pre>\n'+ changes + '\n</pre>\n', s)
152 if re.search (header_tag, s) == None:
153 body = '<BODY BGCOLOR=WHITE TEXT=BLACK>'
154 s = re.sub ('(?i)<body>', body, s)
155 if re.search ('(?i)<BODY', s):
156 s = re.sub ('(?i)<body[^>]*>', body + header, s, 1)
157 elif re.search ('(?i)<html', s):
158 s = re.sub ('(?i)<html>', '<HTML>' + header, s, 1)
162 s = header_tag + '\n' + s
164 if re.search ('(?i)<!DOCTYPE', s) == None:
165 doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n'
168 if re.search (footer_tag, s) == None:
169 s = s + footer_tag + '\n'
171 if re.search ('(?i)</body', s):
172 s = re.sub ('(?i)</body>', footer + '</BODY>', s, 1)
173 elif re.search ('(?i)</html', s):
174 s = re.sub ('(?i)</html>', footer + '</HTML>', s, 1)
181 if os.path.basename (f) == "index.html":
183 if os.path.basename (cwd) == "topdocs":
187 # don't cause ///////index.html entries in log files.
188 # index = "./index.html"
191 s = re.sub ('@INDEX@', index, s)
192 s = re.sub ('@TOP@', top, s)
193 s = re.sub ('@PACKAGE_NAME@', package_name, s)
194 s = re.sub ('@PACKAGE_VERSION@', package_version, s)
195 s = re.sub ('@WEBMASTER@', webmaster, s)
196 s = re.sub ('@GCOS@', gcos, s)
197 s = re.sub ('@LOCALTIME@', localtime, s)
198 s = re.sub ('@MAIL_ADDRESS@', mail_address, s)
200 open (f, 'w').write (s)