4 Print a nice footer. add the top of the NEWS file (up to the ********)
7 program_name = 'add-html-footer'
23 (options, files) = getopt.getopt(sys.argv[1:], 'hp:', ['help', 'news=', 'index=', 'package='])
26 sys.stdout.write ("Usage: add-html-footer [OPTION]... HTML-FILE\n"
27 "Add a nice footer, add the top of the NEWS file (up to the ********)\n\n"
29 + " -h, --help print this help\n"
30 + " -p, --package=DIR specify package\n"
41 elif o == '-h' or o == '--help':
43 elif o == '-p' or o == '--package':
46 sys.path.append (topdir + '/stepmake/bin')
47 from packagepython import *
48 package = Package (topdir)
49 packager = Packager ()
52 os.environ["CONFIGSUFFIX"] = 'www';
55 pw = ntpwd.getpwname(os.environ['USERNAME'])
58 pw = pwd.getpwuid (os.getuid());
60 __main__.fullname=pw[4]
64 backstr = '\n<hr>Please take me <a href=%s>back to the index</a>\n\
65 of ' + package.Name + '\n'
66 builtstr = '\n<hr><font size=-1>\n\
67 This page was built from ' + package.name + '-%s by <p>\n\
68 <address><br>%s <<a href=mailto:%s>%s</a>></address>\n\
73 s = s + builtstr % (version_tuple_to_str (package.version), fullname,
74 packager.mail, packager.mail)
77 banner = footstr (index_file)
78 banner_id = '<! banner_id >'
82 news = gulp_file (news_file)
83 i = regex.search ('^\*\*', news)
86 def check_tag (tag, sub, s, bottom):
89 s = regsub.sub (tag, TAG, s)
90 i = regex.search (TAG, s)
102 s = regsub.sub ('top_of_NEWS', '<XMP>\n'+ news + '\n</XMP>\n', s)
104 s = check_tag ('<body', '', s, 0)
105 if regex.search ('<BODY', s) == -1:
107 s = regsub.sub ('<BODY>', '<BODY BGCOLOR=WHITE><FONT COLOR=BLACK>', s)
108 if regex.search (banner_id, s) == -1:
109 s = regsub.sub ('</body>', '</BODY>', s)
110 s = regsub.sub ('</BODY>', banner_id + banner + '</BODY>', s)
112 s = check_tag ('</body>', '</BODY>', s, 1)
114 title = '<HEAD><TITLE>' \
115 + package.Name + ' -- ' + os.path.basename (os.path.splitext(f)[0]) \
117 s = check_tag ('<title>', title, s, 0)
119 s = check_tag ('<html>', '<HTML>', s, 0)
120 s = check_tag ('</html>', '</HTML>', s, 1)
123 if regex.search ('@COUNTER_REF@', s) != -1:
126 counter = os.environ[package.NAME + '_COUNTERPATH']
127 counter = '<hr><img src="' + counter + '">\n'
130 s = regsub.gsub ('@COUNTER_REF@', counter, s)