4 Print a nice footer. add the top of the ChangeLog 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:], 'c:hp:', ['changelog=', 'help', 'news=', 'index=', 'package='])
39 sys.stderr.write ("can't open file: %s\n" % f)
43 sys.stderr.write ("gulped emty file: %s\n" % f)
48 sys.stdout.write (r"""Usage: add-html-footer [OPTION]... HTML-FILE
49 Add a nice footer, add the top of the ChangLog file (up to the ********)
51 -h, --help print this help
52 -p, --package package name (ugh. Junkme.)
59 if o == '--news' or o == '--changelog' or o == '-c':
63 elif o == '-h' or o == '--help':
65 elif o == '-p' or o == '--package':
68 sys.path.append (topdir + '/stepmake/bin')
69 from packagepython import *
70 package = Package (topdir)
71 packager = Packager ()
73 if package.NAME == 'LILYPOND':
74 package.Name = 'GNU LilyPond'
77 os.environ["CONFIGSUFFIX"] = 'www';
80 pw = ntpwd.getpwname(os.environ['USERNAME'])
83 pw = pwd.getpwuid (os.getuid());
85 __main__.fullname=pw[4]
91 footer = gulp_file (package.topdir + '/Documentation/footer.html.in')
94 s = footer % (index, package.Name, packager.webmaster, packager.webmaster)
95 s = s + builtstr % (package.Name,
96 version_tuple_to_str (package.version), fullname,
97 packager.mail, packager.mail,
98 time.strftime ('%c %Z', time.localtime (time.time ())))
101 banner = footstr (index_file)
102 banner_id = '<! banner_id >'
106 changes = gulp_file (changelog_file)
107 i = regex.search ('^\*\*', changes)
108 changes = changes[:i]
110 def check_tag (tag, sub, s, bottom):
111 tag = string.lower (tag)
112 TAG = string.upper (tag)
113 s = regsub.sub (tag, TAG, s)
114 i = regex.search (TAG, s)
126 s = regsub.sub ('top_of_ChangeLog', '<XMP>\n'+ changes + '\n</XMP>\n', s)
128 s = check_tag ('<body', '', s, 0)
129 if regex.search ('<BODY', s) == -1:
131 s = regsub.sub ('<BODY>', '<BODY BGCOLOR=WHITE><FONT COLOR=BLACK>', s)
132 if regex.search (banner_id, s) == -1:
133 s = regsub.sub ('</body>', '</BODY>', s)
134 s = regsub.sub ('</BODY>', banner_id + banner + '</BODY>', s)
136 s = check_tag ('</body>', '</BODY>', s, 1)
138 title = '<HEAD><TITLE>' \
139 + package.Name + ' -- ' + os.path.basename (os.path.splitext(f)[0]) \
141 s = check_tag ('<title>', title, s, 0)
143 s = check_tag ('<html', '', s, 0)
144 if regex.search ('<HTML', s) == -1:
146 s = check_tag ('</html>', '</HTML>', s, 1)