On Sat, 2007-02-17 at 02:50 -0500, Karsten Wade wrote: > Author: kwade > > Update of /cvs/fedora/web/html/docs/install-guide/fc6/en > In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv21817 > > Modified Files: > ch-rootpassword.php ch-timezone.php sn-utc.php > Log Message: > ... and we keep ignoring this bug in the script because we keep hoping > this PHP based f.r.c is going to go away soon, and it just seems to > keep coming back around like funky smelling in-laws. Let's *docs* > this and file a bug and stuff, might as well get the fix in so we > don't have to wake people with alerts for the umpteenth time. Well, not quite ignored. :-) I fixed the Python script that converts our files some time ago, but it didn't replace the old flawed one, probably because I forgot to remind him to do it. I'm attaching the script here. I've used it on everything I've published since the Red Hat Summit, and it's had no problems. (Last night's error was caused by my failing to remember I'd replaced my web sandbox, and thus was using the old, buggy script.) -- Paul W. Frields, RHCE http://paul.frields.org/ gpg fingerprint: 3DA6 A0AC 6D58 FEC4 0233 5906 ACDB C937 BD11 3717 Fedora Project Board: http://fedoraproject.org/wiki/Board Fedora Docs Project: http://fedoraproject.org/wiki/DocsProject
#!/usr/bin/python # # Convert HTML generated from DocBook (i.e. xmlto) to PHP files for # fedora.redhat.com website # Copyright (C) 2006 Paul W. Frields <stickster@xxxxxxxxx> # This script is licensed under the GNU General Public License (GPL) v2.0. # # Designed after Tammy Fox's original script (C) 2003. import sys, os import re from glob import glob _debug = 0 html_files = sys.argv[1:] mungelist = [] def mungeFileRefs(fname, htmlfilename): try: f = open(fname, 'r') except: print "Cannot open file", fname sys.exit(10) else: data = f.read() f.close() try: f = open(fname, 'w') except: print "Cannot write to file", fname sys.exit(11) else: f.write(data.replace(htmlfilename, htmlfilename.replace('.html', '.php'))) f.close() if html_files == []: print "Usage: docbookhtml2php.py <html_files>" sys.exit(2) if _debug: print html_files for file in html_files: try: infile = open(file, "r") except: print "Could not open file", file sys.exit(3) else: content = infile.read() infile.close() header_include = ''.join(['<?\n\n', 'include("site.inc");\n', '$template = new Page;\n', '$template->initCommon();\n', '$template->displayHeader();\n\n', '?>\n\n']) # The PHP "Date" string is broken up to prevent CVS from seeing it footer_include = ''.join(['\n', '<?\n\n', '$template->displayFooter(', "'$", 'Date', "$'", ');\n\n', '?>\n']) content = re.sub('<.*alink.*?>', header_include, content) content = re.sub('<\/body.*>', footer_include, content) phpfilename = file.split('.html')[0] + '.php' try: outfile = open(phpfilename, 'w') except: print "Could not open output file", phpfilename sys.exit(4) else: outfile.write(content) outfile.close() mungelist.append(file) if _debug: print mungelist phpfiles = glob("*.php") for phpfile in phpfiles: for m in mungelist: mungeFileRefs(phpfile, m)
Attachment:
signature.asc
Description: This is a digitally signed message part