4 Print a nice footer. add the top of the NEWS file (up to the ********)
7 program_name = 'add-html-footer'
24 footer = '\n<hr>Please take me <a href=%s>back to the index</a>\n\
26 builtstr = '\n<hr><font size=-1>\n\
27 This page was built from %s-%s by\
28 <address><br>%s <<a href=mailto:%s>%s</a>>, at %s.</address><p></font>'
30 (options, files) = getopt.getopt(sys.argv[1:], 'hp:', ['help', 'news=', 'index=', 'package='])
37 sys.stdout.write (r"""Usage: add-html-footer [OPTION]... HTML-FILE
38 Add a nice footer, add the top of the NEWS file (up to the ********)
40 -h, --help print this help
41 -p, --package package name (ugh. Junkme.)
52 elif o == '-h' or o == '--help':
54 elif o == '-p' or o == '--package':
57 sys.path.append (topdir + '/stepmake/bin')
58 from packagepython import *
59 package = Package (topdir)
60 packager = Packager ()
62 if package.NAME == 'LILYPOND':
63 package.Name = 'GNU LilyPond'
66 os.environ["CONFIGSUFFIX"] = 'www';
69 pw = ntpwd.getpwname(os.environ['USERNAME'])
72 pw = pwd.getpwuid (os.getuid());
74 __main__.fullname=pw[4]
80 footer = gulp_file (package.topdir + '/Documentation/footer.html.in')
83 s = footer % (index, package.Name, packager.webmaster, packager.webmaster)
84 s = s + builtstr % (package.Name,
85 version_tuple_to_str (package.version), fullname,
86 packager.mail, packager.mail,
87 time.strftime ('%c %Z', time.localtime (time.time ())))
90 banner = footstr (index_file)
91 banner_id = '<! banner_id >'
95 news = gulp_file (news_file)
96 i = regex.search ('^\*\*', news)
99 def check_tag (tag, sub, s, bottom):
100 tag = string.lower (tag)
101 TAG = string.upper (tag)
102 s = regsub.sub (tag, TAG, s)
103 i = regex.search (TAG, s)
115 s = regsub.sub ('top_of_NEWS', '<XMP>\n'+ news + '\n</XMP>\n', s)
117 s = check_tag ('<body', '', s, 0)
118 if regex.search ('<BODY', s) == -1:
120 s = regsub.sub ('<BODY>', '<BODY BGCOLOR=WHITE><FONT COLOR=BLACK>', s)
121 if regex.search (banner_id, s) == -1:
122 s = regsub.sub ('</body>', '</BODY>', s)
123 s = regsub.sub ('</BODY>', banner_id + banner + '</BODY>', s)
125 s = check_tag ('</body>', '</BODY>', s, 1)
127 title = '<HEAD><TITLE>' \
128 + package.Name + ' -- ' + os.path.basename (os.path.splitext(f)[0]) \
130 s = check_tag ('<title>', title, s, 0)
132 s = check_tag ('<html', '', s, 0)
133 if regex.search ('<HTML', s) == -1:
135 s = check_tag ('</html>', '</HTML>', s, 1)